Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added some windows-specific launch fixes. #1

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions scripts/percli-testrun
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env node

const process = require('process');
const args = require('commander');
const Codeceptjs = require( 'codeceptjs' ).codecept;
const { spawn, spawnSync } = require('child_process');
const { spawn, spawnSync, execSync } = require('child_process');

args.version('1.0.0')
.option("-p, --pattern [pattern]", 'run tests that match pattern')
Expand All @@ -17,6 +18,7 @@ args.version('1.0.0')
.parse(process.argv);

let overrides = {};
let isWin = process.platform === "win32";

function showMessage(message) {
console.log("--" + message);
Expand Down Expand Up @@ -84,7 +86,13 @@ let spawnArgs;
if(runMode == "shell") {
spawnArgs = ['codeceptjs', runMode];
} else {
spawnArgs = ['codeceptjs', runMode, '-o', JSON.stringify(overrides)].concat(additionalArgs);
let jsonString = JSON.stringify(overrides);
if(isWin) {
//The json needs to be surrounded with quotes and have its internal quotes escaped on windows
jsonString = '"' + jsonString.replace(/"/g, '\\"') + '"';
}

spawnArgs = ['codeceptjs', runMode, '-o', jsonString].concat(additionalArgs);
}

let dockerContainerId = "peregrine-cms-" + Math.floor(Math.random() * 1000000);
Expand Down Expand Up @@ -127,9 +135,18 @@ if(args.dockerinstance) {

showMessage("Spawning: npx " + spawnArgs.join(" "));

spawnSync('npx', spawnArgs, {
stdio: [process.stdin, process.stdout, process.stderr]
});

if(isWin) {
//spawnSync fails silently in the windows command prompt,
//but execSync works if the arguments are escaped and added to the command
execSync('npx ' + spawnArgs.join(" "), {
stdio: [process.stdin, process.stdout, process.stderr]
});
} else {
spawnSync('npx', spawnArgs, {
stdio: [process.stdin, process.stdout, process.stderr]
});
}


if(args.dockerinstance) {
Expand Down