-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor test:consumer script to use Mocha for better formatting and …
…retries in case of failure
- Loading branch information
1 parent
dccf589
commit db8cca5
Showing
6 changed files
with
63 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tests/generated/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
|
||
/** | ||
* This script generates test files for each version of TypeScript, so the test can run in parallel. | ||
*/ | ||
|
||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
const versions = ['4.7', '4.8', '4.9', '5.0', '5.1', '5.2', '5.3', '5.4', '5.5', '5.6']; | ||
const targets = ['es6', 'esnext']; | ||
|
||
const testsDir = path.resolve(__dirname, 'tests/generated'); | ||
|
||
if (fs.existsSync(testsDir)) { | ||
fs.rmSync(testsDir, { recursive: true }); | ||
} | ||
|
||
fs.mkdirSync(testsDir); | ||
|
||
for (const version of versions) { | ||
fs.writeFileSync( | ||
path.resolve(testsDir, `typescript.${version}.test.js`), | ||
` | ||
const testVersion = require('../typescript'); | ||
testVersion('${version}', ['${targets.join("','")}']); | ||
`, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
|
||
const { exec } = require('child_process'); | ||
const { promisify } = require('util'); | ||
const execp = promisify(exec); | ||
|
||
module.exports = function testVersion(version, targets) { | ||
describe(`typescript:${version}`, function () { | ||
this.timeout(300000); // 5 minutes | ||
this.retries(1); | ||
for (const target of targets) { | ||
it(`target:${target}`, async function () { | ||
await execp(`npx -p typescript@${version} tsc -p tsconfig-test.json --target ${target}`); | ||
}); | ||
} | ||
}); | ||
}; |