Skip to content

Commit 81fbe12

Browse files
authored
User runner submodule improvements (microsoft#20868)
* Add a reset and clean stage to submodule user tests, improve logging when errors occur * Also force remove node_modules, update baselines
1 parent cedcba9 commit 81fbe12

4 files changed

Lines changed: 2754 additions & 2886 deletions

File tree

src/harness/externalCompileRunner.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,29 @@ abstract class ExternalCompileRunnerBase extends RunnerBase {
4242
const stdio = isWorker ? "pipe" : "inherit";
4343
let types: string[];
4444
if (fs.existsSync(path.join(cwd, "test.json"))) {
45-
const update = cp.spawnSync("git", ["submodule", "update", "--remote"], { cwd, timeout, shell: true, stdio });
46-
if (update.status !== 0) throw new Error(`git submodule update for ${directoryName} failed!`);
45+
const submoduleDir = path.join(cwd, directoryName);
46+
const reset = cp.spawnSync("git", ["reset", "HEAD", "--hard"], { cwd: submoduleDir, timeout, shell: true, stdio });
47+
if (reset.status !== 0) throw new Error(`git reset for ${directoryName} failed: ${reset.stderr.toString()}`);
48+
const clean = cp.spawnSync("git", ["clean", "-f"], { cwd: submoduleDir, timeout, shell: true, stdio });
49+
if (clean.status !== 0) throw new Error(`git clean for ${directoryName} failed: ${clean.stderr.toString()}`);
50+
const update = cp.spawnSync("git", ["submodule", "update", "--remote", "."], { cwd: submoduleDir, timeout, shell: true, stdio });
51+
if (update.status !== 0) throw new Error(`git submodule update for ${directoryName} failed: ${update.stderr.toString()}`);
4752

4853
const config = JSON.parse(fs.readFileSync(path.join(cwd, "test.json"), { encoding: "utf8" })) as UserConfig;
4954
ts.Debug.assert(!!config.types, "Bad format from test.json: Types field must be present.");
5055
types = config.types;
5156

52-
cwd = path.join(cwd, directoryName);
57+
cwd = submoduleDir;
5358
}
5459
if (fs.existsSync(path.join(cwd, "package.json"))) {
5560
if (fs.existsSync(path.join(cwd, "package-lock.json"))) {
5661
fs.unlinkSync(path.join(cwd, "package-lock.json"));
5762
}
63+
if (fs.existsSync(path.join(cwd, "node_modules"))) {
64+
require("del").sync(path.join(cwd, "node_modules"));
65+
}
5866
const install = cp.spawnSync(`npm`, ["i"], { cwd, timeout, shell: true, stdio });
59-
if (install.status !== 0) throw new Error(`NPM Install for ${directoryName} failed!`);
67+
if (install.status !== 0) throw new Error(`NPM Install for ${directoryName} failed: ${install.stderr.toString()}`);
6068
}
6169
const args = [path.join(__dirname, "tsc.js")];
6270
if (types) {

0 commit comments

Comments
 (0)