Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Commit 6a39f91

Browse files
authored
Remove docker and user tests, related infra (microsoft#53118)
1 parent 967911c commit 6a39f91

File tree

247 files changed

+4
-27605
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

247 files changed

+4
-27605
lines changed

.github/workflows/accept-baselines-fix-lints.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
git config user.email "[email protected]"
1717
git config user.name "TypeScript Bot"
1818
npm install
19-
git rm -r --quiet tests/baselines/reference :^tests/baselines/reference/docker :^tests/baselines/reference/user
19+
git rm -r --quiet tests/baselines/reference
2020
npx hereby runtests-parallel --ci --fix || true
2121
npx hereby baseline-accept
2222
git add ./src

.gitignore

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ tests/webTestServer.js.map
3434
tests/webhost/*.d.ts
3535
tests/webhost/webtsc.js
3636
tests/cases/**/*.js
37-
!tests/cases/docker/*.js/
3837
tests/cases/**/*.js.map
3938
*.config
4039
scripts/eslint/built/
@@ -59,29 +58,9 @@ internal/
5958
yarn.lock
6059
yarn-error.log
6160
.parallelperf.*
62-
tests/cases/user/*/package-lock.json
63-
tests/cases/user/*/node_modules/
64-
tests/cases/user/*/**/*.js
65-
tests/cases/user/*/**/*.js.map
66-
tests/cases/user/*/**/*.d.ts
67-
!tests/cases/user/zone.js/
68-
!tests/cases/user/bignumber.js/
69-
!tests/cases/user/discord.js/
7061
tests/baselines/reference/dt
7162
.failed-tests
7263
TEST-results.xml
7364
package-lock.json
74-
tests/cases/user/npm/npm
75-
tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter
76-
tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter
77-
tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter
78-
tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter
79-
tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter
80-
tests/cases/user/create-react-app/create-react-app
81-
tests/cases/user/fp-ts/fp-ts
82-
tests/cases/user/webpack/webpack
83-
tests/cases/user/puppeteer/puppeteer
84-
tests/cases/user/axios-src/axios-src
85-
tests/cases/user/prettier/prettier
8665
.eslintcache
87-
*v8.log
66+
*v8.log

CONTRIBUTING.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,7 @@ hereby tests # Build the test infrastructure using the built compile
8181
hereby runtests # Run tests using the built compiler and test infrastructure.
8282
# You can override the specific suite runner used or specify a test for this command.
8383
# Use --tests=<testPath> for a specific test and/or --runner=<runnerName> for a specific suite.
84-
# Valid runners include conformance, compiler, fourslash, project, user, and docker
85-
# The user and docker runners are extended test suite runners - the user runner
86-
# works on disk in the tests/cases/user directory, while the docker runner works in containers.
87-
# You'll need to have the docker executable in your system path for the docker runner to work.
84+
# Valid runners include conformance, compiler, fourslash, and project
8885
hereby runtests-parallel # Like runtests, but split across multiple threads. Uses a number of threads equal to the system
8986
# core count by default. Use --workers=<number> to adjust this.
9087
hereby baseline-accept # This replaces the baseline test results with the results obtained from hereby runtests.

src/harness/runnerbase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
} from "./_namespaces/Harness";
66
import * as ts from "./_namespaces/ts";
77

8-
export type TestRunnerKind = CompilerTestKind | FourslashTestKind | "project" | "rwc" | "test262" | "user" | "dt" | "docker";
8+
export type TestRunnerKind = CompilerTestKind | FourslashTestKind | "project" | "rwc" | "test262" | "dt";
99
export type CompilerTestKind = "conformance" | "compiler";
1010
export type FourslashTestKind = "fourslash" | "fourslash-shims" | "fourslash-shims-pp" | "fourslash-server";
1111

src/testRunner/externalCompileRunner.ts

Lines changed: 0 additions & 202 deletions
Original file line numberDiff line numberDiff line change
@@ -113,180 +113,6 @@ abstract class ExternalCompileRunnerBase extends RunnerBase {
113113
}
114114
}
115115

116-
export class UserCodeRunner extends ExternalCompileRunnerBase {
117-
readonly testDir = "tests/cases/user/";
118-
kind(): TestRunnerKind {
119-
return "user";
120-
}
121-
report(result: ExecResult) {
122-
// eslint-disable-next-line no-null/no-null
123-
return result.status === 0 && !result.stdout.length && !result.stderr.length ? null : `Exit Code: ${result.status}
124-
Standard output:
125-
${sortErrors(stripAbsoluteImportPaths(result.stdout.toString().replace(/\r\n/g, "\n")))}
126-
127-
128-
Standard error:
129-
${stripAbsoluteImportPaths(result.stderr.toString().replace(/\r\n/g, "\n"))}`;
130-
}
131-
}
132-
133-
export class DockerfileRunner extends ExternalCompileRunnerBase {
134-
readonly testDir = "tests/cases/docker/";
135-
kind(): TestRunnerKind {
136-
return "docker";
137-
}
138-
override initializeTests(): void {
139-
// Read in and evaluate the test list
140-
const testList = this.tests && this.tests.length ? this.tests : this.getTestFiles();
141-
142-
// eslint-disable-next-line @typescript-eslint/no-this-alias
143-
const cls = this;
144-
describe(`${this.kind()} code samples`, function (this: Mocha.Suite) {
145-
this.timeout(cls.timeout); // 20 minutes
146-
before(() => {
147-
// cached because workspace is hashed to determine cacheability
148-
cls.exec("docker", ["build", ".", "-t", "typescript/typescript", "-f", cls.testDir + "Dockerfile"], {
149-
cwd: IO.getWorkspaceRoot(),
150-
env: { ...process.env, DOCKER_BUILDKIT: "1" }, // We need buildkit to allow Dockerfile.dockerignore to work.
151-
});
152-
});
153-
for (const test of testList) {
154-
const directory = typeof test === "string" ? test : test.file;
155-
const cwd = path.join(IO.getWorkspaceRoot(), cls.testDir, directory);
156-
it(`should build ${directory} successfully`, () => {
157-
const imageName = `tstest/${directory}`;
158-
cls.exec("docker", ["build", "--no-cache", ".", "-t", imageName], { cwd }); // --no-cache so the latest version of the repos referenced is always fetched
159-
const cp: typeof import("child_process") = require("child_process");
160-
Baseline.runBaseline(`${cls.kind()}/${directory}.log`, cls.report(cp.spawnSync(`docker`, ["run", imageName], { cwd, timeout: cls.timeout, shell: true })));
161-
});
162-
}
163-
});
164-
}
165-
166-
private timeout = 1_200_000; // 20 minutes;
167-
private exec(command: string, args: string[], options: { cwd: string; env?: NodeJS.ProcessEnv }): void {
168-
const cp: typeof import("child_process") = require("child_process");
169-
const stdio = isWorker ? "pipe" : "inherit";
170-
const res = cp.spawnSync(isWorker ? `${command} 2>&1` : command, args, { timeout: this.timeout, shell: true, stdio, ...options });
171-
if (res.status !== 0) {
172-
throw new Error(`${command} ${args.join(" ")} for ${options.cwd} failed: ${res.stdout && res.stdout.toString()}`);
173-
}
174-
}
175-
report(result: ExecResult) {
176-
// eslint-disable-next-line no-null/no-null
177-
return result.status === 0 && !result.stdout.length && !result.stderr.length ? null : `Exit Code: ${result.status}
178-
Standard output:
179-
${sanitizeDockerfileOutput(result.stdout.toString())}
180-
181-
182-
Standard error:
183-
${sanitizeDockerfileOutput(result.stderr.toString())}`;
184-
}
185-
}
186-
187-
function sanitizeDockerfileOutput(result: string): string {
188-
return [
189-
normalizeNewlines,
190-
stripANSIEscapes,
191-
stripRushStageNumbers,
192-
stripWebpackHash,
193-
sanitizeVersionSpecifiers,
194-
sanitizeTimestamps,
195-
sanitizeSizes,
196-
sanitizeUnimportantGulpOutput,
197-
stripAbsoluteImportPaths,
198-
].reduce((result, f) => f(result), result);
199-
}
200-
201-
function normalizeNewlines(result: string): string {
202-
return result.replace(/\r\n/g, "\n");
203-
}
204-
205-
function stripANSIEscapes(result: string): string {
206-
return result.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, "");
207-
}
208-
209-
function stripRushStageNumbers(result: string): string {
210-
return result.replace(/\d+ of \d+:/g, "XX of XX:");
211-
}
212-
213-
function stripWebpackHash(result: string): string {
214-
return result.replace(/Hash: \w+/g, "Hash: [redacted]");
215-
}
216-
217-
function sanitizeSizes(result: string): string {
218-
return result.replace(/\d+(\.\d+)? ((Ki|M)B|bytes)/g, "X KiB");
219-
}
220-
221-
/**
222-
* Gulp's output order within a `parallel` block is nondeterministic (and there's no way to configure it to execute in series),
223-
* so we purge as much of the gulp output as we can
224-
*/
225-
function sanitizeUnimportantGulpOutput(result: string): string {
226-
return result.replace(/^.*(\] (Starting)|(Finished)).*$/gm, "") // "gulp" task start/end messages (nondeterministic order)
227-
.replace(/^.*(\] . (finished)|(started)).*$/gm, "") // "just" task start/end messages (nondeterministic order)
228-
.replace(/^.*\] Respawned to PID: \d+.*$/gm, "") // PID of child is OS and system-load dependent (likely stableish in a container but still dangerous)
229-
.replace(/\n+/g, "\n")
230-
.replace(/\/tmp\/yarn--.*?\/node/g, "");
231-
}
232-
233-
function sanitizeTimestamps(result: string): string {
234-
return result.replace(/\[\d?\d:\d\d:\d\d (A|P)M\]/g, "[XX:XX:XX XM]")
235-
.replace(/\[\d?\d:\d\d:\d\d\]/g, "[XX:XX:XX]")
236-
.replace(/\/\d+-\d+-[\d_TZ]+-debug.log/g, "\/XXXX-XX-XXXXXXXXX-debug.log")
237-
.replace(/\d+\/\d+\/\d+ \d+:\d+:\d+ (AM|PM)/g, "XX/XX/XX XX:XX:XX XM")
238-
.replace(/\d+(\.\d+)? sec(onds?)?/g, "? seconds")
239-
.replace(/\d+(\.\d+)? min(utes?)?/g, "")
240-
.replace(/\d+(\.\d+)? ?m?s/g, "?s")
241-
.replace(/ \(\?s\)/g, "");
242-
}
243-
244-
function sanitizeVersionSpecifiers(result: string): string {
245-
return result
246-
.replace(/\d+.\d+.\d+-insiders.\d\d\d\d\d\d\d\d/g, "X.X.X-insiders.xxxxxxxx")
247-
.replace(/Rush Multi-Project Build Tool (\d+)\.\d+\.\d+/g, "Rush Multi-Project Build Tool $1.X.X")
248-
.replace(/([@v\()])\d+\.\d+\.\d+/g, "$1X.X.X")
249-
.replace(/webpack (\d+)\.\d+\.\d+/g, "webpack $1.X.X")
250-
.replace(/Webpack version: (\d+)\.\d+\.\d+/g, "Webpack version: $1.X.X");
251-
}
252-
253-
/**
254-
* Import types and some other error messages use absolute paths in errors as they have no context to be written relative to;
255-
* This is problematic for error baselines, so we grep for them and strip them out.
256-
*/
257-
function stripAbsoluteImportPaths(result: string) {
258-
const workspaceRegexp = new RegExp(IO.getWorkspaceRoot().replace(/\\/g, "\\\\"), "g");
259-
return result
260-
.replace(/import\(".*?\/tests\/cases\/user\//g, `import("/`)
261-
.replace(/Module '".*?\/tests\/cases\/user\//g, `Module '"/`)
262-
.replace(workspaceRegexp, "../../..");
263-
}
264-
265-
function sortErrors(result: string) {
266-
return ts.flatten(splitBy(result.split("\n"), s => /^\S+/.test(s)).sort(compareErrorStrings)).join("\n");
267-
}
268-
269-
const errorRegexp = /^(.+\.[tj]sx?)\((\d+),(\d+)\)(: error TS.*)/;
270-
function compareErrorStrings(a: string[], b: string[]) {
271-
ts.Debug.assertGreaterThanOrEqual(a.length, 1);
272-
ts.Debug.assertGreaterThanOrEqual(b.length, 1);
273-
const matchA = a[0].match(errorRegexp);
274-
if (!matchA) {
275-
return -1;
276-
}
277-
const matchB = b[0].match(errorRegexp);
278-
if (!matchB) {
279-
return 1;
280-
}
281-
const [, errorFileA, lineNumberStringA, columnNumberStringA, remainderA] = matchA;
282-
const [, errorFileB, lineNumberStringB, columnNumberStringB, remainderB] = matchB;
283-
return ts.comparePathsCaseSensitive(errorFileA, errorFileB) ||
284-
ts.compareValues(parseInt(lineNumberStringA), parseInt(lineNumberStringB)) ||
285-
ts.compareValues(parseInt(columnNumberStringA), parseInt(columnNumberStringB)) ||
286-
ts.compareStringsCaseSensitive(remainderA, remainderB) ||
287-
ts.compareStringsCaseSensitive(a.slice(1).join("\n"), b.slice(1).join("\n"));
288-
}
289-
290116
export class DefinitelyTypedRunner extends ExternalCompileRunnerBase {
291117
readonly testDir = "../DefinitelyTyped/types/";
292118
override workingDirectory = this.testDir;
@@ -304,31 +130,3 @@ Standard error:
304130
${result.stderr.toString().replace(/\r\n/g, "\n")}`;
305131
}
306132
}
307-
308-
/**
309-
* Split an array into multiple arrays whenever `isStart` returns true.
310-
* @example
311-
* splitBy([1,2,3,4,5,6], isOdd)
312-
* ==> [[1, 2], [3, 4], [5, 6]]
313-
* where
314-
* const isOdd = n => !!(n % 2)
315-
*/
316-
function splitBy<T>(xs: T[], isStart: (x: T) => boolean): T[][] {
317-
const result = [];
318-
let group: T[] = [];
319-
for (const x of xs) {
320-
if (isStart(x)) {
321-
if (group.length) {
322-
result.push(group);
323-
}
324-
group = [x];
325-
}
326-
else {
327-
group.push(x);
328-
}
329-
}
330-
if (group.length) {
331-
result.push(group);
332-
}
333-
return result;
334-
}

src/testRunner/runner.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
CompilerBaselineRunner,
44
CompilerTestType,
55
DefinitelyTypedRunner,
6-
DockerfileRunner,
76
FourSlashRunner,
87
GeneratedFourslashRunner,
98
IO,
@@ -14,7 +13,6 @@ import {
1413
setShards,
1514
Test262BaselineRunner,
1615
TestRunnerKind,
17-
UserCodeRunner,
1816
} from "./_namespaces/Harness";
1917
import * as project from "./_namespaces/project";
2018
import * as RWC from "./_namespaces/RWC";
@@ -80,12 +78,8 @@ export function createRunner(kind: TestRunnerKind): RunnerBase {
8078
return new RWC.RWCRunner();
8179
case "test262":
8280
return new Test262BaselineRunner();
83-
case "user":
84-
return new UserCodeRunner();
8581
case "dt":
8682
return new DefinitelyTypedRunner();
87-
case "docker":
88-
return new DockerfileRunner();
8983
}
9084
return ts.Debug.fail(`Unknown runner kind ${kind}`);
9185
}
@@ -223,15 +217,9 @@ function handleTestConfig() {
223217
case "test262":
224218
runners.push(new Test262BaselineRunner());
225219
break;
226-
case "user":
227-
runners.push(new UserCodeRunner());
228-
break;
229220
case "dt":
230221
runners.push(new DefinitelyTypedRunner());
231222
break;
232-
case "docker":
233-
runners.push(new DockerfileRunner());
234-
break;
235223
}
236224
}
237225
}
@@ -250,12 +238,6 @@ function handleTestConfig() {
250238
runners.push(new FourSlashRunner(FourSlash.FourSlashTestType.ShimsWithPreprocess));
251239
runners.push(new FourSlashRunner(FourSlash.FourSlashTestType.Server));
252240
// runners.push(new GeneratedFourslashRunner());
253-
254-
// CRON-only tests
255-
if (process.env.TRAVIS_EVENT_TYPE === "cron") {
256-
runners.push(new UserCodeRunner());
257-
runners.push(new DockerfileRunner());
258-
}
259241
}
260242
if (runUnitTests === undefined) {
261243
runUnitTests = runners.length !== 1; // Don't run unit tests when running only one runner if unit tests were not explicitly asked for

0 commit comments

Comments
 (0)