Skip to content

Commit

Permalink
Merge pull request #383 from NeurodataWithoutBorders/improve-exe-test…
Browse files Browse the repository at this point in the history
…-file

Improve .exe test file
  • Loading branch information
CodyCBakerPhD authored Sep 25, 2023
2 parents 7a82dd3 + 9c364e6 commit f775bab
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions tests/testPyinstallerExecutable.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,25 @@ handleProcess(proc2, "spawn");

let now = Date.now();

let outputCollection = "";
const regex = /.+Error: .+/i; // Check for error messages (without case sensitivity)

const regex = /.+Error: .+/;
function onMessage(data, id) {
const message = data.toString();
if (!cmds.forever && regex.test(message)) throw new Error(message);
else console.error(`[${id}] ${message}`);
}

function handleProcess(proc, id = "process") {
if (proc != null) {
// Listen for errors from Python process
proc.stderr.on("data", function (data) {
const message = data.toString();
console.error(`[${id}] Error: ${data}`);
outputCollection += message;
if (regex.test(message)) throw new Error(outputCollection);
});
proc.stderr.on("data", (data) => onMessage(data, id));

proc.stdout.on("data", function (data) {
console.log(`Time to Start: ${(Date.now() - now).toFixed(2)}ms`);
if (!cmds.forever) process.exit();
if (cmds.forever) onMessage(data, id);
else {
console.log(`Time to Start: ${(Date.now() - now).toFixed(2)}ms`);
process.exit();
}
});

const error = () => () => {
Expand Down

0 comments on commit f775bab

Please sign in to comment.