Skip to content

Commit 22ea3e9

Browse files
committed
User test runner improvements
1 parent 7c14aff commit 22ea3e9

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ internal/
7272
yarn.lock
7373
yarn-error.log
7474
.parallelperf.*
75-
tests/cases/user/*/package-lock.json
7675
tests/cases/user/*/node_modules/
7776
tests/cases/user/*/**/*.js
7877
tests/cases/user/*/**/*.js.map

src/testRunner/externalCompileRunner.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,20 @@ abstract class ExternalCompileRunnerBase extends RunnerBase {
5555
ts.Debug.assert(!!config.cloneUrl, "Bad format from test.json: cloneUrl field must be present.");
5656
const submoduleDir = path.join(cwd, directoryName);
5757
if (!fs.existsSync(submoduleDir)) {
58-
exec("git", ["clone", config.cloneUrl, directoryName], { cwd });
58+
exec("git", ["--work-tree", submoduleDir, "clone", config.cloneUrl, path.join(submoduleDir, ".git")], { cwd });
59+
}
60+
else {
61+
exec("git", ["--git-dir", path.join(submoduleDir, ".git"), "--work-tree", submoduleDir, "checkout", ":/"], { cwd: submoduleDir });
62+
exec("git", ["--git-dir", path.join(submoduleDir, ".git"), "--work-tree", submoduleDir, "clean", "-f"], { cwd: submoduleDir });
63+
exec("git", ["--git-dir", path.join(submoduleDir, ".git"), "--work-tree", submoduleDir, "pull", "-f"], { cwd: submoduleDir });
5964
}
60-
exec("git", ["reset", "HEAD", "--hard"], { cwd: submoduleDir });
61-
exec("git", ["clean", "-f"], { cwd: submoduleDir });
62-
exec("git", ["pull", "-f"], { cwd: submoduleDir });
6365

6466
types = config.types;
6567

6668
cwd = config.path ? path.join(cwd, config.path) : submoduleDir;
6769
}
6870
if (fs.existsSync(path.join(cwd, "package.json"))) {
69-
if (fs.existsSync(path.join(cwd, "package-lock.json"))) {
71+
if (process.env.TRAVIS_EVENT_TYPE === "cron" && fs.existsSync(path.join(cwd, "package-lock.json"))) {
7072
fs.unlinkSync(path.join(cwd, "package-lock.json"));
7173
}
7274
if (fs.existsSync(path.join(cwd, "node_modules"))) {
@@ -75,7 +77,7 @@ abstract class ExternalCompileRunnerBase extends RunnerBase {
7577
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
7678
}
7779
const args = [path.join(Harness.IO.getWorkspaceRoot(), "built/local/tsc.js")];
78-
if (types) {
80+
if (types?.length) {
7981
args.push("--types", types.join(","));
8082
// Also actually install those types (for, eg, the js projects which need node)
8183
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

0 commit comments

Comments
 (0)