Skip to content

Commit 0d7a3c2

Browse files
Fix GenType path test on CI
Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
1 parent 00b1b55 commit 0d7a3c2

3 files changed

Lines changed: 27 additions & 14 deletions

File tree

‎rewatch/src/build/parse.rs‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -436,18 +436,10 @@ fn generate_ast(
436436
// generate the dir of the ast_path (it mirrors the source file dir)
437437
let ast_parent_path = package.get_build_path().join(ast_path.parent().unwrap());
438438
helpers::create_path(&ast_parent_path);
439-
// Keep absolute source locations in the AST in the same path form as the
440-
// canonical project root passed during compilation. This matters for
441-
// Windows paths that have both short and expanded representations.
442-
let parse_working_dir = build_path_abs
443-
.canonicalize()
444-
.map(helpers::StrippedVerbatimPath::to_stripped_verbatim_path)
445-
.unwrap_or_else(|_| build_path_abs.clone());
446-
447439
/* Create .ast */
448440
let result = match Some(
449441
Command::new(&build_state.compiler_info.bsc_path)
450-
.current_dir(&parse_working_dir)
442+
.current_dir(&build_path_abs)
451443
.args(parser_args)
452444
.output()
453445
.map_err(|e| {

‎rewatch/src/config.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ impl Config {
10291029
}
10301030

10311031
pub fn get_project_root_args(&self) -> Vec<String> {
1032-
// The parser records locations from a canonical working directory.
1032+
// Package discovery gives the parser a canonical working directory.
10331033
// Use the same representation here so GenType can strip this prefix,
10341034
// including when Windows supplied the project through an 8.3 path.
10351035
let root = self

‎rewatch/tests/gentype/project-root.mjs‎

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,28 @@ import {join} from "node:path";
66

77
const executable = process.env.REWATCH_EXECUTABLE;
88
assert(executable, "REWATCH_EXECUTABLE must be set");
9-
const executableForNode =
10-
process.platform === "win32" && existsSync(`${executable}.cmd`) ? `${executable}.cmd` : executable;
9+
10+
function getBuildInvocation() {
11+
if (process.platform !== "win32") {
12+
return {command: executable, args: ["build"], env: process.env};
13+
}
14+
15+
const executablePath = executable.endsWith(".exe") ? executable : `${executable}.exe`;
16+
if (existsSync(executablePath)) {
17+
return {command: executablePath, args: ["build"], env: process.env};
18+
}
19+
20+
const commandShim = executable.endsWith(".cmd") ? executable : `${executable}.cmd`;
21+
if (existsSync(commandShim)) {
22+
return {
23+
command: process.env.ComSpec ?? "cmd.exe",
24+
args: ["/d", "/s", "/c", '"%REWATCH_TEST_EXECUTABLE%" build'],
25+
env: {...process.env, REWATCH_TEST_EXECUTABLE: commandShim},
26+
};
27+
}
28+
29+
return {command: executable, args: ["build"], env: process.env};
30+
}
1131

1232
function getBuildDirectory(projectDir) {
1333
if (process.platform !== "win32") {
@@ -55,10 +75,11 @@ try {
5575
);
5676

5777
const buildDirectory = getBuildDirectory(projectDir);
58-
const result = spawnSync(executableForNode, ["build"], {
78+
const {command, args, env} = getBuildInvocation();
79+
const result = spawnSync(command, args, {
5980
cwd: buildDirectory,
6081
encoding: "utf8",
61-
env: process.env,
82+
env,
6283
timeout: 30_000,
6384
});
6485

0 commit comments

Comments
 (0)