Skip to content

Commit

Permalink
add debug prints
Browse files Browse the repository at this point in the history
  • Loading branch information
milahu committed Aug 31, 2023
1 parent 0c34079 commit 1ac91d8
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,28 @@ const IGNORED_FILES = ['**/node_modules'];

const debug = false;

debug && console.log("bipbip");

if (cluster.isMaster) {

debug && console.log("bipbip: cluster.isMaster == true");

// Define global variables used by scenarios
global.suite = suite;
global.scenario = scenario;

if (debug) {
global.suite = function suiteDebugWrapper(name, body) {
console.log(`bipbip: suite: ${name}`);
return suite.apply(null, [name, body]);
}

global.scenario = function scenarioDebugWrapper(name, body) {
console.log(`bipbip: scenario: ${name}`);
return scenario.apply(null, [name, body]);
}
}

debug && console.log(`bipbip: parse argv: ${JSON.stringify(process.argv)}`);

// Define command line spec
Expand All @@ -36,15 +53,25 @@ if (cluster.isMaster) {
.option('-c, --compare [file]', 'compare result with previous results')
.parse(process.argv);

debug && console.log(`bipbip: calling main`);

main().then(
() => {
debug && console.log(`bipbip: main done -> exit`);
process.exit(0);
},
error => {
debug && console.log(`bipbip: main failed -> throw`);
throw error;
}
);

debug && console.log(`bipbip: calling main done`);

} else {

debug && console.log("bipbip: cluster.isMaster == false");

const reporter = new ConsoleReporter();
process.on('message', message => {
switch (message.type) {
Expand Down Expand Up @@ -108,6 +135,7 @@ async function main() {
}

for (const filePath of paths) {
debug && console.dir({ filePath, filePath_resolved: path.resolve(process.cwd(), filePath) });
await import(path.resolve(process.cwd(), filePath));
}

Expand Down

0 comments on commit 1ac91d8

Please sign in to comment.