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

refactor: Fix test:consumer pipeline randomly failing #4793

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions testing/consumer-test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests/generated/*
32 changes: 32 additions & 0 deletions testing/consumer-test/generateTests.ts
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("','")}']);
`,
);
}
10 changes: 5 additions & 5 deletions testing/consumer-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"version": "1.0.0",
"scripts": {
"lint": "eslint .",
"test": "ts-node run.ts --verbose"
"test": "npm-run-all test:gen test:mocha",
"test:gen": "ts-node ./generateTests.ts",
"test:mocha": "mocha ./tests/generated/*.test.js --parallel"
},
"dependencies": {
"adaptive-expressions": "4.1.6",
Expand Down Expand Up @@ -35,11 +37,9 @@
"botframework-connector": "4.1.6",
"botframework-schema": "4.1.6",
"botframework-streaming": "4.1.6",
"eslint-plugin-only-warn": "^1.1.0",
"minimist": "^1.2.6",
"p-map": "^4.0.0"
"eslint-plugin-only-warn": "^1.1.0"
},
"devDependencies": {
"@types/minimist": "^1.2.5"
"mocha": "^10.7.3"
}
}
65 changes: 0 additions & 65 deletions testing/consumer-test/run.ts

This file was deleted.

5 changes: 5 additions & 0 deletions testing/consumer-test/test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/

import * as adaptiveExpressions from 'adaptive-expressions';
import * as adaptiveExpressionsIE11 from 'adaptive-expressions-ie11';
import * as botbuilder from 'botbuilder';
Expand Down
20 changes: 20 additions & 0 deletions testing/consumer-test/tests/typescript.js
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}`);
});
}
});
};
Loading