Skip to content

Commit ee3fe47

Browse files
authored
Fix broken user and docker tests (microsoft#42431)
* Add --force to npm install script for user tests * Migrate prettier to docker * Fix vscode Dockerfile * Fix stack space issue in isJSLiteralType * Use --legacy-peer-deps based on npm version * Fix xterm.js Dockerfile
1 parent 80dfc6a commit ee3fe47

File tree

7 files changed

+25
-27
lines changed

7 files changed

+25
-27
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14109,7 +14109,8 @@ namespace ts {
1410914109
return some((type as IntersectionType).types, isJSLiteralType);
1411014110
}
1411114111
if (type.flags & TypeFlags.Instantiable) {
14112-
return isJSLiteralType(getResolvedBaseConstraint(type));
14112+
const constraint = getResolvedBaseConstraint(type);
14113+
return constraint !== type && isJSLiteralType(constraint);
1411314114
}
1411414115
return false;
1411514116
}

src/testRunner/externalCompileRunner.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,31 +68,35 @@ namespace Harness {
6868

6969
cwd = config.path ? path.join(cwd, config.path) : submoduleDir;
7070
}
71+
const npmVersionText = exec("npm", ["--version"], { cwd, stdio: "pipe" })?.trim();
72+
const npmVersion = npmVersionText ? ts.Version.tryParse(npmVersionText.trim()) : undefined;
73+
const isV7OrLater = !!npmVersion && npmVersion.major >= 7;
7174
if (fs.existsSync(path.join(cwd, "package.json"))) {
7275
if (fs.existsSync(path.join(cwd, "package-lock.json"))) {
7376
fs.unlinkSync(path.join(cwd, "package-lock.json"));
7477
}
7578
if (fs.existsSync(path.join(cwd, "node_modules"))) {
7679
del.sync(path.join(cwd, "node_modules"), { force: true });
7780
}
78-
exec("npm", ["i", "--ignore-scripts"], { cwd, timeout: timeout / 2 }); // NPM shouldn't take the entire timeout - if it takes a long time, it should be terminated and we should log the failure
81+
exec("npm", ["i", "--ignore-scripts", ...(isV7OrLater ? ["--legacy-peer-deps"] : [])], { cwd, timeout: timeout / 2 }); // NPM shouldn't take the entire timeout - if it takes a long time, it should be terminated and we should log the failure
7982
}
8083
const args = [path.join(IO.getWorkspaceRoot(), "built/local/tsc.js")];
8184
if (types) {
8285
args.push("--types", types.join(","));
8386
// Also actually install those types (for, eg, the js projects which need node)
8487
if (types.length) {
85-
exec("npm", ["i", ...types.map(t => `@types/${t}`), "--no-save", "--ignore-scripts"], { cwd: originalCwd, timeout: timeout / 2 }); // NPM shouldn't take the entire timeout - if it takes a long time, it should be terminated and we should log the failure
88+
exec("npm", ["i", ...types.map(t => `@types/${t}`), "--no-save", "--ignore-scripts", ...(isV7OrLater ? ["--legacy-peer-deps"] : [])], { cwd: originalCwd, timeout: timeout / 2 }); // NPM shouldn't take the entire timeout - if it takes a long time, it should be terminated and we should log the failure
8689
}
8790
}
8891
args.push("--noEmit");
8992
Baseline.runBaseline(`${cls.kind()}/${directoryName}.log`, cls.report(cp.spawnSync(`node`, args, { cwd, timeout, shell: true }), cwd));
9093

91-
function exec(command: string, args: string[], options: { cwd: string, timeout?: number }): void {
94+
function exec(command: string, args: string[], options: { cwd: string, timeout?: number, stdio?: import("child_process").StdioOptions }): string | undefined {
9295
const res = cp.spawnSync(isWorker ? `${command} 2>&1` : command, args, { shell: true, stdio, ...options });
9396
if (res.status !== 0) {
9497
throw new Error(`${command} ${args.join(" ")} for ${directoryName} failed: ${res.stdout && res.stdout.toString()}`);
9598
}
99+
return options.stdio === "pipe" ? res.stdout.toString("utf8") : undefined;
96100
}
97101
});
98102
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node:current
2+
RUN npm i -g yarn --force
3+
RUN git clone https://github.com/prettier/prettier.git /prettier
4+
WORKDIR /prettier
5+
RUN git pull
6+
COPY --from=typescript/typescript /typescript/typescript-*.tgz /typescript.tgz
7+
RUN mkdir /typescript
8+
RUN tar -xzvf /typescript.tgz -C /typescript
9+
RUN yarn add typescript@/typescript.tgz
10+
RUN yarn
11+
ENTRYPOINT [ "yarn" ]
12+
# Build
13+
CMD [ "build" ]

tests/cases/docker/vscode/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ COPY --from=typescript/typescript /typescript/typescript-*.tgz /typescript.tgz
1010
WORKDIR /vscode/build
1111
RUN yarn add typescript@/typescript.tgz
1212
WORKDIR /vscode/extensions
13+
RUN yarn add rimraf
1314
RUN yarn add typescript@/typescript.tgz
1415
WORKDIR /vscode
1516
RUN yarn add typescript@/typescript.tgz

tests/cases/docker/xterm.js/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# node-pty doesn't build on node 12 right now, so we lock to 8 - the version xterm itself tests against :(
2-
FROM node:8
1+
# node-pty doesn't build on node 12 right now, so we lock to 10
2+
FROM node:10
33
RUN git clone https://github.com/xtermjs/xterm.js.git /xtermjs
44
WORKDIR /xtermjs
55
RUN git pull

tests/cases/user/prettier/test.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/cases/user/prettier/tsconfig.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)