mirror of https://github.com/vladmandic/human
more automated tests
parent
ccd5ba1e46
commit
57f5fd391f
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue