Skip to content

Commit

Permalink
Added command to test for race conditions (#586)
Browse files Browse the repository at this point in the history
Co-authored-by: James Hunt <jameshunt@microsoft.com>
  • Loading branch information
huntj88 and James Hunt authored May 15, 2023
1 parent 07ab6e9 commit bfca3b8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/live-share/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"build": "tsc -p tsconfig.build.json",
"test": "ts-mocha --config ./src/test/.mocharc.js src/**/*.spec.ts --timeout 10000",
"test:debug": "ts-mocha --config ./src/test/.mocharc.js src/**/*.spec.ts --inspect-brk",
"test:coverage": "nyc --reporter=html --reporter=text --reporter=text-summary npm test"
"test:coverage": "nyc --reporter=html --reporter=text --reporter=text-summary npm test",
"test:race": "node test-for-race-conditions.js"
},
"dependencies": {
"uuid": "^9.0.0"
Expand Down
12 changes: 12 additions & 0 deletions packages/live-share/test-for-race-conditions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* This file runs tests 50 times or until failure, and is intended to be used to find race conditions, or validate that they do not exist.
*/

const execSync = require("child_process").execSync;

for (var i = 0; i < 50; i++) {
console.log("starting run:", i);
const output = execSync("npm run test", { encoding: "utf-8" });
console.log("Output was:\n", output);
console.log("finished run:", i);
}

0 comments on commit bfca3b8

Please sign in to comment.