Skip to content

Commit e088ab5

Browse files
committed
User test runner improvements
1 parent 6f079a4 commit e088ab5

File tree

5 files changed

+10
-17
lines changed

5 files changed

+10
-17
lines changed

src/testRunner/externalCompileRunner.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ namespace Harness {
5656
ts.Debug.assert(!!config.cloneUrl, "Bad format from test.json: cloneUrl field must be present.");
5757
const submoduleDir = path.join(cwd, directoryName);
5858
if (!fs.existsSync(submoduleDir)) {
59-
exec("git", ["clone", config.cloneUrl, directoryName], { cwd });
59+
exec("git", ["--work-tree", submoduleDir, "clone", config.cloneUrl, path.join(submoduleDir, ".git")], { cwd });
6060
}
6161
else {
62-
exec("git", ["reset", "HEAD", "--hard"], { cwd: submoduleDir });
63-
exec("git", ["clean", "-f"], { cwd: submoduleDir });
64-
exec("git", ["pull", "-f"], { cwd: submoduleDir });
62+
exec("git", ["--git-dir", path.join(submoduleDir, ".git"), "--work-tree", submoduleDir, "checkout", ":/"], { cwd: submoduleDir });
63+
exec("git", ["--git-dir", path.join(submoduleDir, ".git"), "--work-tree", submoduleDir, "clean", "--force"], { cwd: submoduleDir });
64+
exec("git", ["--git-dir", path.join(submoduleDir, ".git"), "--work-tree", submoduleDir, "pull"], { cwd: submoduleDir });
6565
}
6666

6767
types = config.types;
@@ -81,7 +81,9 @@ namespace Harness {
8181
if (types) {
8282
args.push("--types", types.join(","));
8383
// Also actually install those types (for, eg, the js projects which need node)
84-
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
84+
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
86+
}
8587
}
8688
args.push("--noEmit");
8789
Baseline.runBaseline(`${cls.kind()}/${directoryName}.log`, cls.report(cp.spawnSync(`node`, args, { cwd, timeout, shell: true }), cwd));

tests/baselines/reference/user/TypeScript-Vue-Starter.log

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"cloneUrl": "https://github.com/Microsoft/TypeScript-React-Starter",
2+
"cloneUrl": "https://github.com/Microsoft/TypeScript-React-Starter.git",
33
"types": ["jest", "node"]
44
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"cloneUrl": "https://github.com/Microsoft/TypeScript-Vue-Starter.git",
3-
"types": []
3+
"types": ["jest"]
44
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"cloneUrl": "https://github.com/Microsoft/TypeScript-React-Starter",
2+
"cloneUrl": "https://github.com/Microsoft/TypeScript-WeChat-Starter.git",
33
"types": []
44
}

0 commit comments

Comments
 (0)