Skip to content

Commit ba98cbb

Browse files
authored
User code runner draft (microsoft#19539)
* Realworld runner draft * Baseline tsc output instead of just checking exit code * use latest instead of major minor pin * Add 7 more test cases + update gitignore * Update baselines for realworld/user tests * Rename to user * Do not commit lockfiles * Add code to run user tests on CRON * Add rest of most-dependend packages to user tests Turns out levelup doesn't have types! So I removed that one.
1 parent 6a382f1 commit ba98cbb

File tree

158 files changed

+1080
-2
lines changed

Some content is hidden

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

158 files changed

+1080
-2
lines changed

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,11 @@ internal/
5959
.idea
6060
yarn.lock
6161
.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/

Jakefile.js

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ var harnessCoreSources = [
105105
"projectsRunner.ts",
106106
"loggedIO.ts",
107107
"rwcRunner.ts",
108+
"userRunner.ts",
108109
"test262Runner.ts",
109110
"./parallel/shared.ts",
110111
"./parallel/host.ts",

src/harness/runner.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
/// <reference path="fourslashRunner.ts" />
1919
/// <reference path="projectsRunner.ts" />
2020
/// <reference path="rwcRunner.ts" />
21+
/// <reference path="userRunner.ts" />
2122
/// <reference path="harness.ts" />
2223
/// <reference path="./parallel/shared.ts" />
2324

@@ -59,6 +60,8 @@ function createRunner(kind: TestRunnerKind): RunnerBase {
5960
return new RWCRunner();
6061
case "test262":
6162
return new Test262BaselineRunner();
63+
case "user":
64+
return new UserCodeRunner();
6265
}
6366
ts.Debug.fail(`Unknown runner kind ${kind}`);
6467
}
@@ -175,6 +178,9 @@ function handleTestConfig() {
175178
case "test262":
176179
runners.push(new Test262BaselineRunner());
177180
break;
181+
case "user":
182+
runners.push(new UserCodeRunner());
183+
break;
178184
}
179185
}
180186
}
@@ -196,6 +202,11 @@ function handleTestConfig() {
196202
runners.push(new FourSlashRunner(FourSlashTestType.ShimsWithPreprocess));
197203
runners.push(new FourSlashRunner(FourSlashTestType.Server));
198204
// runners.push(new GeneratedFourslashRunner());
205+
206+
// CRON-only tests
207+
if (Utils.getExecutionEnvironment() !== Utils.ExecutionEnvironment.Browser && process.env.TRAVIS_EVENT_TYPE === "cron") {
208+
runners.push(new UserCodeRunner());
209+
}
199210
}
200211
if (runUnitTests === undefined) {
201212
runUnitTests = runners.length !== 1; // Don't run unit tests when running only one runner if unit tests were not explicitly asked for
@@ -215,8 +226,9 @@ function beginTests() {
215226
}
216227
}
217228

229+
let isWorker: boolean;
218230
function startTestEnvironment() {
219-
const isWorker = handleTestConfig();
231+
isWorker = handleTestConfig();
220232
if (Utils.getExecutionEnvironment() !== Utils.ExecutionEnvironment.Browser) {
221233
if (isWorker) {
222234
return Harness.Parallel.Worker.start();

src/harness/runnerbase.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// <reference path="harness.ts" />
22

33

4-
type TestRunnerKind = CompilerTestKind | FourslashTestKind | "project" | "rwc" | "test262";
4+
type TestRunnerKind = CompilerTestKind | FourslashTestKind | "project" | "rwc" | "test262" | "user";
55
type CompilerTestKind = "conformance" | "compiler";
66
type FourslashTestKind = "fourslash" | "fourslash-shims" | "fourslash-shims-pp" | "fourslash-server";
77

src/harness/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"projectsRunner.ts",
9393
"loggedIO.ts",
9494
"rwcRunner.ts",
95+
"userRunner.ts",
9596
"test262Runner.ts",
9697
"./parallel/shared.ts",
9798
"./parallel/host.ts",

src/harness/userRunner.ts

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/// <reference path="harness.ts"/>
2+
/// <reference path="runnerbase.ts" />
3+
class UserCodeRunner extends RunnerBase {
4+
private static readonly testDir = "tests/cases/user/";
5+
public enumerateTestFiles() {
6+
return Harness.IO.getDirectories(UserCodeRunner.testDir);
7+
}
8+
9+
public kind(): TestRunnerKind {
10+
return "user";
11+
}
12+
13+
/** Setup the runner's tests so that they are ready to be executed by the harness
14+
* The first test should be a describe/it block that sets up the harness's compiler instance appropriately
15+
*/
16+
public initializeTests(): void {
17+
// Read in and evaluate the test list
18+
const testList = this.tests && this.tests.length ? this.tests : this.enumerateTestFiles();
19+
20+
describe(`${this.kind()} code samples`, () => {
21+
for (let i = 0; i < testList.length; i++) {
22+
this.runTest(testList[i]);
23+
}
24+
});
25+
}
26+
27+
private runTest(directoryName: string) {
28+
describe(directoryName, () => {
29+
const cp = require("child_process");
30+
const path = require("path");
31+
32+
it("should build successfully", () => {
33+
const cwd = path.join(__dirname, "../../", UserCodeRunner.testDir, directoryName);
34+
const timeout = 600000; // 10 minutes
35+
const stdio = isWorker ? "pipe" : "inherit";
36+
const install = cp.spawnSync(`npm`, ["i"], { cwd, timeout, shell: true, stdio });
37+
if (install.status !== 0) throw new Error(`NPM Install for ${directoryName} failed!`);
38+
Harness.Baseline.runBaseline(`${this.kind()}/${directoryName}.log`, () => {
39+
const result = cp.spawnSync(`node`, ["../../../../built/local/tsc.js"], { cwd, timeout, shell: true });
40+
return `Exit Code: ${result.status}
41+
Standard output:
42+
${result.stdout.toString().replace(/\r\n/g, "\n")}
43+
44+
45+
Standard error:
46+
${result.stderr.toString().replace(/\r\n/g, "\n")}`;
47+
});
48+
});
49+
});
50+
}
51+
}
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Exit Code: 2
2+
Standard output:
3+
node_modules/electron/electron.d.ts(5390,13): error TS2430: Interface 'WebviewTag' incorrectly extends interface 'HTMLElement'.
4+
Types of property 'addEventListener' are incompatible.
5+
Type '{ (event: "load-commit", listener: (event: LoadCommitEvent) => void, useCapture?: boolean | undef...' is not assignable to type '{ <K extends "error" | "waiting" | "progress" | "ended" | "change" | "input" | "select" | "abort"...'.
6+
Types of parameters 'listener' and 'listener' are incompatible.
7+
Type 'EventListenerOrEventListenerObject' is not assignable to type '(event: LoadCommitEvent) => void'.
8+
Type 'EventListenerObject' is not assignable to type '(event: LoadCommitEvent) => void'.
9+
Type 'EventListenerObject' provides no match for the signature '(event: LoadCommitEvent): void'.
10+
11+
12+
13+
Standard error:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Exit Code: 2
2+
Standard output:
3+
node_modules/abstract-leveldown/index.d.ts(2,3): error TS7010: 'open', which lacks return-type annotation, implicitly has an 'any' return type.
4+
node_modules/abstract-leveldown/index.d.ts(3,3): error TS7010: 'open', which lacks return-type annotation, implicitly has an 'any' return type.
5+
node_modules/abstract-leveldown/index.d.ts(5,3): error TS7010: 'close', which lacks return-type annotation, implicitly has an 'any' return type.
6+
node_modules/abstract-leveldown/index.d.ts(7,3): error TS7010: 'get', which lacks return-type annotation, implicitly has an 'any' return type.
7+
node_modules/abstract-leveldown/index.d.ts(7,26): error TS7006: Parameter 'err' implicitly has an 'any' type.
8+
node_modules/abstract-leveldown/index.d.ts(8,3): error TS7010: 'get', which lacks return-type annotation, implicitly has an 'any' return type.
9+
node_modules/abstract-leveldown/index.d.ts(8,39): error TS7006: Parameter 'err' implicitly has an 'any' type.
10+
node_modules/abstract-leveldown/index.d.ts(10,3): error TS7010: 'put', which lacks return-type annotation, implicitly has an 'any' return type.
11+
node_modules/abstract-leveldown/index.d.ts(11,3): error TS7010: 'put', which lacks return-type annotation, implicitly has an 'any' return type.
12+
node_modules/abstract-leveldown/index.d.ts(13,3): error TS7010: 'del', which lacks return-type annotation, implicitly has an 'any' return type.
13+
node_modules/abstract-leveldown/index.d.ts(14,3): error TS7010: 'del', which lacks return-type annotation, implicitly has an 'any' return type.
14+
node_modules/abstract-leveldown/index.d.ts(17,3): error TS7010: 'batch', which lacks return-type annotation, implicitly has an 'any' return type.
15+
node_modules/abstract-leveldown/index.d.ts(18,3): error TS7010: 'batch', which lacks return-type annotation, implicitly has an 'any' return type.
16+
node_modules/leveldown/leveldown.d.ts(66,3): error TS7010: 'seek', which lacks return-type annotation, implicitly has an 'any' return type.
17+
18+
19+
20+
Standard error:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Exit Code: 2
2+
Standard output:
3+
node_modules/rxjs/scheduler/VirtualTimeScheduler.d.ts(22,22): error TS2415: Class 'VirtualAction<T>' incorrectly extends base class 'AsyncAction<T>'.
4+
Types of property 'work' are incompatible.
5+
Type '(this: VirtualAction<T>, state?: T | undefined) => void' is not assignable to type '(this: AsyncAction<T>, state?: T | undefined) => void'.
6+
The 'this' types of each signature are incompatible.
7+
Type 'AsyncAction<T>' is not assignable to type 'VirtualAction<T>'.
8+
Property 'index' is missing in type 'AsyncAction<T>'.
9+
10+
11+
12+
Standard error:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Exit Code: 0
2+
Standard output:
3+
4+
5+
6+
Standard error:

0 commit comments

Comments
 (0)