Skip to content

Commit 08df422

Browse files
committed
compiletest: avoid invoking rustc with absolute paths.
1 parent 4a9e76c commit 08df422

13 files changed

Lines changed: 18 additions & 30 deletions

crates/rustc_codegen_spirv/src/codegen_cx/mod.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -767,25 +767,6 @@ impl CodegenArgs {
767767

768768
if self.disassemble_globals {
769769
for inst in module.global_inst_iter() {
770-
// HACK: On Windows, paths are printed like `OpString "D:\\dir\\blah"`.
771-
// Unfortunately, compiletest will only normalize `D:\dir\blah` to `$DIR/blah` -
772-
// one backslash, not two. So, when disassembling for compiletest, check if the
773-
// argument to OpString can be parsed as an absolute path, and if it is, replace it
774-
// with just the filename component of the path.
775-
if inst.class.opcode == Op::String {
776-
let path = Path::new(inst.operands[0].unwrap_literal_string());
777-
if path.is_absolute()
778-
&& let Some(file_name) = path.file_name()
779-
{
780-
let mut inst = inst.clone();
781-
inst.operands[0] = Operand::LiteralString(format!(
782-
"$OPSTRING_FILENAME/{}",
783-
file_name.to_string_lossy(),
784-
));
785-
eprintln!("{}", inst.disassemble());
786-
continue;
787-
}
788-
}
789770
eprintln!("{}", inst.disassemble());
790771
}
791772
}

tests/compiletests/src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ fn main() {
6565
let deps_target_dir = original_target_dir.join("compiletest-deps");
6666
let compiletest_build_dir = original_target_dir.join("compiletest-results");
6767

68+
// HACK(eddyb) force `compiletest` to pass `ui/...` relative paths to `rustc`,
69+
// which should always end up being the same regardless of the path that the
70+
// Rust-GPU repo is checked out at (among other things, this avoids harcoded
71+
// `compiletest` limits being hit by e.g. users with slightly longer paths).
72+
std::env::set_current_dir(tests_dir).unwrap();
73+
let tests_dir = PathBuf::from("");
74+
6875
// Pull in rustc_codegen_spirv as a dynamic library in the same way
6976
// spirv-builder does.
7077
let codegen_backend_path = find_rustc_codegen_spirv();

tests/compiletests/ui/dis/asm_op_decorate.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ OpExtension "SPV_EXT_descriptor_indexing"
44
OpMemoryModel Logical Simple
55
OpEntryPoint Fragment %1 "main"
66
OpExecutionMode %1 OriginUpperLeft
7-
%2 = OpString "$OPSTRING_FILENAME/asm_op_decorate.rs"
7+
%2 = OpString "$DIR/asm_op_decorate.rs"
88
OpName %3 "asm_op_decorate::main"
99
OpName %4 "asm_op_decorate::add_decorate"
1010
OpDecorate %5 Binding 0

tests/compiletests/ui/dis/const-float-cast-optimized.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ OpCapability Float64
33
OpMemoryModel Logical Simple
44
OpEntryPoint Fragment %1 "main" %2
55
OpExecutionMode %1 OriginUpperLeft
6-
%3 = OpString "$OPSTRING_FILENAME/const-float-cast-optimized.rs"
6+
%3 = OpString "$DIR/const-float-cast-optimized.rs"
77
OpName %2 "output"
88
OpDecorate %2 Location 0
99
%4 = OpTypeFloat 64

tests/compiletests/ui/dis/const-float-cast.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ OpCapability Float64
33
OpMemoryModel Logical Simple
44
OpEntryPoint Fragment %1 "main" %2
55
OpExecutionMode %1 OriginUpperLeft
6-
%3 = OpString "$OPSTRING_FILENAME/const-float-cast.rs"
6+
%3 = OpString "$DIR/const-float-cast.rs"
77
OpName %2 "output"
88
OpDecorate %2 Location 0
99
%4 = OpTypeFloat 32

tests/compiletests/ui/dis/const-from-cast.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ OpCapability Shader
22
OpMemoryModel Logical Simple
33
OpEntryPoint Fragment %1 "main" %2
44
OpExecutionMode %1 OriginUpperLeft
5-
%3 = OpString "$OPSTRING_FILENAME/const-from-cast.rs"
5+
%3 = OpString "$DIR/const-from-cast.rs"
66
OpName %2 "output"
77
OpDecorate %2 Location 0
88
%4 = OpTypeInt 32 0

tests/compiletests/ui/dis/const-int-cast.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ OpCapability Shader
22
OpMemoryModel Logical Simple
33
OpEntryPoint Fragment %1 "main" %2
44
OpExecutionMode %1 OriginUpperLeft
5-
%3 = OpString "$OPSTRING_FILENAME/const-int-cast.rs"
5+
%3 = OpString "$DIR/const-int-cast.rs"
66
OpName %2 "output"
77
OpDecorate %2 Location 0
88
%4 = OpTypeInt 32 0

tests/compiletests/ui/dis/const-narrowing-cast.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ OpCapability Int8
33
OpMemoryModel Logical Simple
44
OpEntryPoint Fragment %1 "main" %2
55
OpExecutionMode %1 OriginUpperLeft
6-
%3 = OpString "$OPSTRING_FILENAME/const-narrowing-cast.rs"
6+
%3 = OpString "$DIR/const-narrowing-cast.rs"
77
OpName %2 "output"
88
OpDecorate %2 Location 0
99
%4 = OpTypeInt 32 0

tests/compiletests/ui/dis/custom_entry_point.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ OpCapability Shader
22
OpMemoryModel Logical Simple
33
OpEntryPoint Fragment %1 "hello_world"
44
OpExecutionMode %1 OriginUpperLeft
5-
%2 = OpString "$OPSTRING_FILENAME/custom_entry_point.rs"
5+
%2 = OpString "$DIR/custom_entry_point.rs"
66
OpName %3 "custom_entry_point::main"
77
%4 = OpTypeVoid
88
%5 = OpTypeFunction %4

tests/compiletests/ui/dis/generic-fn-op-name.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ OpCapability Shader
22
OpMemoryModel Logical Simple
33
OpEntryPoint Fragment %1 "main"
44
OpExecutionMode %1 OriginUpperLeft
5-
%2 = OpString "$OPSTRING_FILENAME/generic-fn-op-name.rs"
5+
%2 = OpString "$DIR/generic-fn-op-name.rs"
66
OpName %3 "generic_fn_op_name::main"
77
OpName %4 "generic_fn_op_name::generic::<f32, {generic_fn_op_name::Dimensionality::TwoD}>"
88
%5 = OpTypeVoid

0 commit comments

Comments
 (0)