mirror of https://github.com/vladmandic/human
more automated tests
parent
b07d0e823a
commit
cadbadf52e
|
@ -74,10 +74,10 @@ function validate(defaults, config3, parent = "config", msgs = []) {
|
|||
if (typeof config3[key] === "object") {
|
||||
validate(defaults[key], config3[key], key, msgs);
|
||||
} else {
|
||||
const defined = typeof defaults[key] !== "undefined";
|
||||
const defined = defaults && typeof defaults[key] !== "undefined";
|
||||
if (!defined)
|
||||
msgs.push({ reason: "unknown property", where: `${parent}.${key} = ${config3[key]}` });
|
||||
const same = typeof defaults[key] === typeof config3[key];
|
||||
const same = defaults && typeof defaults[key] === typeof config3[key];
|
||||
if (defined && !same)
|
||||
msgs.push({ reason: "property type mismatch", where: `${parent}.${key} = ${config3[key]}`, expected: typeof defaults[key] });
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -63,10 +63,10 @@ function validate(defaults, config3, parent = "config", msgs = []) {
|
|||
if (typeof config3[key] === "object") {
|
||||
validate(defaults[key], config3[key], key, msgs);
|
||||
} else {
|
||||
const defined = typeof defaults[key] !== "undefined";
|
||||
const defined = defaults && typeof defaults[key] !== "undefined";
|
||||
if (!defined)
|
||||
msgs.push({ reason: "unknown property", where: `${parent}.${key} = ${config3[key]}` });
|
||||
const same = typeof defaults[key] === typeof config3[key];
|
||||
const same = defaults && typeof defaults[key] === typeof config3[key];
|
||||
if (defined && !same)
|
||||
msgs.push({ reason: "property type mismatch", where: `${parent}.${key} = ${config3[key]}`, expected: typeof defaults[key] });
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -119,10 +119,10 @@ function validate(defaults, config3, parent = "config", msgs = []) {
|
|||
if (typeof config3[key] === "object") {
|
||||
validate(defaults[key], config3[key], key, msgs);
|
||||
} else {
|
||||
const defined = typeof defaults[key] !== "undefined";
|
||||
const defined = defaults && typeof defaults[key] !== "undefined";
|
||||
if (!defined)
|
||||
msgs.push({ reason: "unknown property", where: `${parent}.${key} = ${config3[key]}` });
|
||||
const same = typeof defaults[key] === typeof config3[key];
|
||||
const same = defaults && typeof defaults[key] === typeof config3[key];
|
||||
if (defined && !same)
|
||||
msgs.push({ reason: "property type mismatch", where: `${parent}.${key} = ${config3[key]}`, expected: typeof defaults[key] });
|
||||
}
|
||||
|
|
|
@ -120,10 +120,10 @@ function validate(defaults, config3, parent = "config", msgs = []) {
|
|||
if (typeof config3[key] === "object") {
|
||||
validate(defaults[key], config3[key], key, msgs);
|
||||
} else {
|
||||
const defined = typeof defaults[key] !== "undefined";
|
||||
const defined = defaults && typeof defaults[key] !== "undefined";
|
||||
if (!defined)
|
||||
msgs.push({ reason: "unknown property", where: `${parent}.${key} = ${config3[key]}` });
|
||||
const same = typeof defaults[key] === typeof config3[key];
|
||||
const same = defaults && typeof defaults[key] === typeof config3[key];
|
||||
if (defined && !same)
|
||||
msgs.push({ reason: "property type mismatch", where: `${parent}.${key} = ${config3[key]}`, expected: typeof defaults[key] });
|
||||
}
|
||||
|
|
|
@ -119,10 +119,10 @@ function validate(defaults, config3, parent = "config", msgs = []) {
|
|||
if (typeof config3[key] === "object") {
|
||||
validate(defaults[key], config3[key], key, msgs);
|
||||
} else {
|
||||
const defined = typeof defaults[key] !== "undefined";
|
||||
const defined = defaults && typeof defaults[key] !== "undefined";
|
||||
if (!defined)
|
||||
msgs.push({ reason: "unknown property", where: `${parent}.${key} = ${config3[key]}` });
|
||||
const same = typeof defaults[key] === typeof config3[key];
|
||||
const same = defaults && typeof defaults[key] === typeof config3[key];
|
||||
if (defined && !same)
|
||||
msgs.push({ reason: "property type mismatch", where: `${parent}.${key} = ${config3[key]}`, expected: typeof defaults[key] });
|
||||
}
|
||||
|
|
|
@ -31,9 +31,9 @@ export function validate(defaults, config, parent = 'config', msgs: Array<{ reas
|
|||
if (typeof config[key] === 'object') {
|
||||
validate(defaults[key], config[key], key, msgs);
|
||||
} else {
|
||||
const defined = (typeof defaults[key] !== 'undefined');
|
||||
const defined = defaults && (typeof defaults[key] !== 'undefined');
|
||||
if (!defined) msgs.push({ reason: 'unknown property', where: `${parent}.${key} = ${config[key]}` });
|
||||
const same = typeof defaults[key] === typeof config[key];
|
||||
const same = defaults && typeof defaults[key] === typeof config[key];
|
||||
if (defined && !same) msgs.push({ reason: 'property type mismatch', where: `${parent}.${key} = ${config[key]}`, expected: typeof defaults[key] });
|
||||
}
|
||||
// ok = ok && defined && same;
|
||||
|
|
|
@ -22,3 +22,47 @@
|
|||
2021-09-19 13:55:51 [35mSTATE:[39m Lint: {"locations":["*.json","src/**/*.ts","test/**/*.js","demo/**/*.js"],"files":83,"errors":0,"warnings":0}
|
||||
2021-09-19 13:55:52 [35mSTATE:[39m ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"}
|
||||
2021-09-19 13:55:52 [36mINFO: [39m Done...
|
||||
2021-09-19 14:14:35 [36mINFO: [39m @vladmandic/human version 2.2.2
|
||||
2021-09-19 14:14:35 [36mINFO: [39m User: vlado Platform: linux Arch: x64 Node: v16.5.0
|
||||
2021-09-19 14:14:35 [36mINFO: [39m Application: {"name":"@vladmandic/human","version":"2.2.2"}
|
||||
2021-09-19 14:14:35 [36mINFO: [39m Environment: {"profile":"development","config":"build.json","tsconfig":true,"eslintrc":true,"git":true}
|
||||
2021-09-19 14:14:35 [36mINFO: [39m Toolchain: {"build":"0.5.2","esbuild":"0.12.28","typescript":"4.4.3","typedoc":"0.22.4","eslint":"7.32.0"}
|
||||
2021-09-19 14:14:35 [36mINFO: [39m Build: {"profile":"development","steps":["serve","watch","compile"]}
|
||||
2021-09-19 14:14:35 [35mSTATE:[39m WebServer: {"ssl":false,"port":10030,"root":"."}
|
||||
2021-09-19 14:14:35 [35mSTATE:[39m WebServer: {"ssl":true,"port":10031,"root":".","sslKey":"node_modules/@vladmandic/build/cert/https.key","sslCrt":"node_modules/@vladmandic/build/cert/https.crt"}
|
||||
2021-09-19 14:14:35 [35mSTATE:[39m Watch: {"locations":["src/**","README.md","src/**/*","tfjs/**/*"]}
|
||||
2021-09-19 14:14:35 [35mSTATE:[39m Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":102,"outputBytes":1416}
|
||||
2021-09-19 14:14:35 [35mSTATE:[39m Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":50,"inputBytes":481782,"outputBytes":408817}
|
||||
2021-09-19 14:14:35 [35mSTATE:[39m Compile: {"name":"tfjs/nodejs/gpu","format":"cjs","platform":"node","input":"tfjs/tf-node-gpu.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":110,"outputBytes":1424}
|
||||
2021-09-19 14:14:35 [35mSTATE:[39m Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":50,"inputBytes":481790,"outputBytes":408821}
|
||||
2021-09-19 14:14:35 [35mSTATE:[39m Compile: {"name":"tfjs/nodejs/wasm","format":"cjs","platform":"node","input":"tfjs/tf-node-wasm.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":149,"outputBytes":1491}
|
||||
2021-09-19 14:14:35 [35mSTATE:[39m Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":50,"inputBytes":481857,"outputBytes":408893}
|
||||
2021-09-19 14:14:35 [35mSTATE:[39m Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1063,"outputBytes":1631}
|
||||
2021-09-19 14:14:35 [35mSTATE:[39m Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":3088,"outputBytes":793}
|
||||
2021-09-19 14:14:35 [35mSTATE:[39m Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":50,"inputBytes":481159,"outputBytes":410110}
|
||||
2021-09-19 14:14:36 [35mSTATE:[39m Compile: {"name":"tfjs/browser/esm/bundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":8,"inputBytes":3088,"outputBytes":2376809}
|
||||
2021-09-19 14:14:36 [35mSTATE:[39m Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":50,"inputBytes":2857175,"outputBytes":1409415}
|
||||
2021-09-19 14:14:37 [35mSTATE:[39m Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":50,"inputBytes":2857175,"outputBytes":2614029}
|
||||
2021-09-19 14:14:37 [36mINFO: [39m Listening...
|
||||
2021-09-19 14:15:02 [36mINFO: [39m @vladmandic/human version 2.2.2
|
||||
2021-09-19 14:15:02 [36mINFO: [39m User: vlado Platform: linux Arch: x64 Node: v16.5.0
|
||||
2021-09-19 14:15:02 [36mINFO: [39m Application: {"name":"@vladmandic/human","version":"2.2.2"}
|
||||
2021-09-19 14:15:02 [36mINFO: [39m Environment: {"profile":"development","config":"build.json","tsconfig":true,"eslintrc":true,"git":true}
|
||||
2021-09-19 14:15:02 [36mINFO: [39m Toolchain: {"build":"0.5.2","esbuild":"0.12.28","typescript":"4.4.3","typedoc":"0.22.4","eslint":"7.32.0"}
|
||||
2021-09-19 14:15:02 [36mINFO: [39m Build: {"profile":"development","steps":["serve","watch","compile"]}
|
||||
2021-09-19 14:15:02 [35mSTATE:[39m WebServer: {"ssl":false,"port":10030,"root":"."}
|
||||
2021-09-19 14:15:02 [35mSTATE:[39m WebServer: {"ssl":true,"port":10031,"root":".","sslKey":"node_modules/@vladmandic/build/cert/https.key","sslCrt":"node_modules/@vladmandic/build/cert/https.crt"}
|
||||
2021-09-19 14:15:02 [35mSTATE:[39m Watch: {"locations":["src/**","README.md","src/**/*","tfjs/**/*"]}
|
||||
2021-09-19 14:15:02 [35mSTATE:[39m Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":102,"outputBytes":1416}
|
||||
2021-09-19 14:15:02 [35mSTATE:[39m Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":50,"inputBytes":481794,"outputBytes":408829}
|
||||
2021-09-19 14:15:02 [35mSTATE:[39m Compile: {"name":"tfjs/nodejs/gpu","format":"cjs","platform":"node","input":"tfjs/tf-node-gpu.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":110,"outputBytes":1424}
|
||||
2021-09-19 14:15:02 [35mSTATE:[39m Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":50,"inputBytes":481802,"outputBytes":408833}
|
||||
2021-09-19 14:15:02 [35mSTATE:[39m Compile: {"name":"tfjs/nodejs/wasm","format":"cjs","platform":"node","input":"tfjs/tf-node-wasm.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":149,"outputBytes":1491}
|
||||
2021-09-19 14:15:02 [35mSTATE:[39m Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":50,"inputBytes":481869,"outputBytes":408905}
|
||||
2021-09-19 14:15:02 [35mSTATE:[39m Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1063,"outputBytes":1631}
|
||||
2021-09-19 14:15:02 [35mSTATE:[39m Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":3088,"outputBytes":793}
|
||||
2021-09-19 14:15:02 [35mSTATE:[39m Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":50,"inputBytes":481171,"outputBytes":410122}
|
||||
2021-09-19 14:15:02 [35mSTATE:[39m Compile: {"name":"tfjs/browser/esm/bundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":8,"inputBytes":3088,"outputBytes":2376809}
|
||||
2021-09-19 14:15:03 [35mSTATE:[39m Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":50,"inputBytes":2857187,"outputBytes":1409418}
|
||||
2021-09-19 14:15:03 [35mSTATE:[39m Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":50,"inputBytes":2857187,"outputBytes":2614041}
|
||||
2021-09-19 14:15:03 [36mINFO: [39m Listening...
|
||||
|
|
|
@ -190,6 +190,14 @@ async function test(Human, inputConfig) {
|
|||
else log('state', 'passed: default result face match');
|
||||
|
||||
// test default config
|
||||
log('info', 'test sync');
|
||||
human.reset();
|
||||
config.async = false;
|
||||
res = await testDetect(human, 'samples/ai-body.jpg', 'default');
|
||||
if (!res || res?.face?.length !== 1 || res?.face[0].gender !== 'female') log('error', 'failed: default sync', res?.face?.length, res?.body?.length, res?.hand?.length, res?.gesture?.length);
|
||||
else log('state', 'passed: default sync');
|
||||
|
||||
// test object detection
|
||||
log('info', 'test object');
|
||||
human.reset();
|
||||
config.object = { enabled: true };
|
||||
|
|
22
test/test.js
22
test/test.js
|
@ -12,6 +12,14 @@ const tests = [
|
|||
'test-node-wasm.js',
|
||||
];
|
||||
|
||||
const demos = [
|
||||
'../demo/nodejs/node.js',
|
||||
'../demo/nodejs/node-canvas.js',
|
||||
'../demo/nodejs/node-env.js',
|
||||
'../demo/nodejs/node-event.js',
|
||||
'../demo/nodejs/node-multiprocess.js',
|
||||
];
|
||||
|
||||
const ignoreMessages = [
|
||||
'cpu_feature_guard.cc',
|
||||
'rebuild TensorFlow',
|
||||
|
@ -65,6 +73,19 @@ async function runTest(test) {
|
|||
});
|
||||
}
|
||||
|
||||
async function runDemo(demo) {
|
||||
log.info();
|
||||
log.info(demo, 'start');
|
||||
return new Promise((resolve) => {
|
||||
const child = fork(path.join(__dirname, demo), [], { silent: true });
|
||||
child.on('message', (data) => logMessage(demo, data));
|
||||
child.on('error', (data) => log.error(demo, ':', data.message || data));
|
||||
child.on('close', (code) => resolve(code));
|
||||
child.stdout?.on('data', (data) => logStdIO(true, demo, data));
|
||||
child.stderr?.on('data', (data) => logStdIO(false, demo, data));
|
||||
});
|
||||
}
|
||||
|
||||
async function testAll() {
|
||||
logFile = path.join(__dirname, logFile);
|
||||
if (fs.existsSync(logFile)) fs.unlinkSync(logFile);
|
||||
|
@ -73,6 +94,7 @@ async function testAll() {
|
|||
process.on('unhandledRejection', (data) => log.error('nodejs unhandled rejection', data));
|
||||
process.on('uncaughtException', (data) => log.error('nodejs unhandled exception', data));
|
||||
log.info('tests:', tests);
|
||||
for (const demo of demos) await runDemo(demo);
|
||||
for (const test of tests) await runTest(test);
|
||||
log.info();
|
||||
log.info('status:', status);
|
||||
|
|
1052
test/test.log
1052
test/test.log
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue