Skip to content

Commit

Permalink
cli testing via child_process
Browse files Browse the repository at this point in the history
  • Loading branch information
morganherlocker committed Aug 28, 2019
1 parent 748043f commit e89173d
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 5 deletions.
8 changes: 4 additions & 4 deletions example/simulate.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ exec(
);
exec("../node_modules/osrm/lib/binding/osrm-contract graph/nash.osrm");

const providers = ["Flipr", "Scoob", "BikeMe", "Spuun"];
const providers = ["Spuun"];

const days = 10;
const days = 1;

const start = 1563087600000; // Sunday, July 14, 2019 3:00:00 AM GMT-04:00

Expand All @@ -42,8 +42,8 @@ cmd += "--changes data/{provider}/changes.json ";
cmd += "--trips data/{provider}/trips.json ";
cmd += "--quiet ";

const minAgents = 115;
const maxAgents = 400;
const minAgents = 40;
const maxAgents = 40;

console.log("running simulations...");

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"bin": "./src/cli.js",
"scripts": {
"lint": "prettier config.template.json example/example.json '{,!(node_modules)/**/}*.js' templates/*.html --write",
"test": "npm run lint;"
"test": "npm run lint; tap -R spec test/*.test.js"
},
"engines": {
"node": ">=11.0.0"
Expand Down
Binary file added test/.DS_Store
Binary file not shown.
40 changes: 40 additions & 0 deletions test/cli.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const { test } = require("tap");
const { exec } = require("child_process");
const path = require("path");
const rimraf = require("rimraf");

test("cli", { timeout: 1200000 }, async t => {
const bin = path.join(__dirname, "../src/cli.js");
const config = path.join(__dirname, "./fixtures/cli/config.json");
const cache = path.join(__dirname, "./fixtures/cli/cache");
const public = path.join(__dirname, "./fixtures/cli/public");

rimraf.sync(cache);
rimraf.sync(public);

var cmd =
"node " +
bin +
" --config " +
config +
" --public " +
public +
" --cache " +
cache +
" --day 2019-07-15";
console.log(cmd);
const { error, stdout, stderr } = await exec(cmd);

/*
//console.log(error);
for await (let chunk of stderr) {
//console.log(chunk.toString());
}
for await (let chunk of stdout) {
//console.log(chunk.toString());
}*/

t.done();
});
Binary file added test/fixtures/.DS_Store
Binary file not shown.
Binary file added test/fixtures/cli/.DS_Store
Binary file not shown.
65 changes: 65 additions & 0 deletions test/fixtures/cli/Spuun/changes.json

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions test/fixtures/cli/Spuun/trips.json

Large diffs are not rendered by default.

0 comments on commit e89173d

Please sign in to comment.