Skip to content

Commit

Permalink
Refactor in global scripts/run-tests.js for clearer commands logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmilar committed Mar 17, 2020
1 parent 33c4ca0 commit 82bb1d6
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions scripts/run-tests.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const os = require("os");
const process = require("process");
const shell = require("shelljs");

process.env.FORCE_COLOR = "3";

// skip ts-node type checks (this is already covered in previous 'build-test' script)
process.env.TS_NODE_TRANSPILE_ONLY = "true";

// throw if a command fails
shell.config.fatal = true;

Expand All @@ -14,31 +16,46 @@ const isWindows = os.type() === "Windows_NT";
// only Build tests in local environment
const shouldBuildTests = !isGithubActions;

// only run Vyper tests in Linux CI environment, and ignore if using a Windows machine (since Docker Desktop is required, only available windows Pro)
const shouldIgnoreVyperTests = isGithubActions && !isLinux || isWindows;
shell.exec("npm run build");

if (shouldBuildTests) {
shell.exec("npm run build-test");
}

// ** check for packages to be ignored ** //

// only run Vyper tests in Linux CI environment,
// and ignore if using a Windows machine (since Docker Desktop is required, only available windows Pro)
const shouldIgnoreVyperTests = (isGithubActions && !isLinux) || isWindows;

// Solpp tests don't work in Windows
const shouldIgnoreSolppTests = isWindows;

shell.exec("npm run build");
const ignoredPackages = [];

if (shouldBuildTests) {
shell.exec("npm run build-test");
if (shouldIgnoreVyperTests) {
ignoredPackages.push("@nomiclabs/buidler-vyper");
}

process.env.TS_NODE_TRANSPILE_ONLY = "true";
if (shouldIgnoreSolppTests) {
ignoredPackages.push("@nomiclabs/buidler-solpp");
}

const nodeArgs = process.argv.slice(2);
const testArgs = nodeArgs.length > 0 && `-- ${nodeArgs.join(" ")}`;

const testRunCommand = `npm run test ${testArgs || ""}`;

function packagesToGlobStr(packages) {
return packages.length === 1 ? packages[0] : `{${packages.join(",")}}`;
}

const ignoredPackagesFilter =
Array.isArray(ignoredPackages) && ignoredPackages.length > 0
? `--ignore "${packagesToGlobStr(ignoredPackages)}"`
: "";

shell.exec(
`npx lerna exec ${
shouldIgnoreVyperTests ? '--ignore "@nomiclabs/buidler-vyper"' : ""
} ${
shouldIgnoreSolppTests ? '--ignore "@nomiclabs/buidler-solpp"' : ""
} --concurrency 1 -- ${testRunCommand}`
`npx lerna exec ${ignoredPackagesFilter} ` +
`--concurrency 1 -- ${testRunCommand}`
);

0 comments on commit 82bb1d6

Please sign in to comment.