Skip to content

Commit 74c0c48

Browse files
committed
compiletest: localize compile_test_and_save_assembly to assembly test module
1 parent f9ca420 commit 74c0c48

File tree

2 files changed

+31
-29
lines changed

2 files changed

+31
-29
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,34 +1848,6 @@ impl<'test> TestCx<'test> {
18481848
(proc_res, output_path)
18491849
}
18501850

1851-
fn compile_test_and_save_assembly(&self) -> (ProcRes, PathBuf) {
1852-
// This works with both `--emit asm` (as default output name for the assembly)
1853-
// and `ptx-linker` because the latter can write output at requested location.
1854-
let output_path = self.output_base_name().with_extension("s");
1855-
let input_file = &self.testpaths.file;
1856-
1857-
// Use the `//@ assembly-output:` directive to determine how to emit assembly.
1858-
let emit = match self.props.assembly_output.as_deref() {
1859-
Some("emit-asm") => Emit::Asm,
1860-
Some("bpf-linker") => Emit::LinkArgsAsm,
1861-
Some("ptx-linker") => Emit::None, // No extra flags needed.
1862-
Some(other) => self.fatal(&format!("unknown 'assembly-output' directive: {other}")),
1863-
None => self.fatal("missing 'assembly-output' directive"),
1864-
};
1865-
1866-
let rustc = self.make_compile_args(
1867-
input_file,
1868-
TargetLocation::ThisFile(output_path.clone()),
1869-
emit,
1870-
AllowUnused::No,
1871-
LinkToAux::Yes,
1872-
Vec::new(),
1873-
);
1874-
1875-
let proc_res = self.compose_and_run_compiler(rustc, None, self.testpaths);
1876-
(proc_res, output_path)
1877-
}
1878-
18791851
fn verify_with_filecheck(&self, output: &Path) -> ProcRes {
18801852
let mut filecheck = Command::new(self.config.llvm_filecheck.as_ref().unwrap());
18811853
filecheck.arg("--input-file").arg(output).arg(&self.testpaths.file);

src/tools/compiletest/src/runtest/assembly.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use super::TestCx;
1+
use std::path::PathBuf;
2+
3+
use super::{AllowUnused, Emit, LinkToAux, ProcRes, TargetLocation, TestCx};
24

35
impl TestCx<'_> {
46
pub(super) fn run_assembly_test(&self) {
@@ -16,4 +18,32 @@ impl TestCx<'_> {
1618
self.fatal_proc_rec("verification with 'FileCheck' failed", &proc_res);
1719
}
1820
}
21+
22+
fn compile_test_and_save_assembly(&self) -> (ProcRes, PathBuf) {
23+
// This works with both `--emit asm` (as default output name for the assembly)
24+
// and `ptx-linker` because the latter can write output at requested location.
25+
let output_path = self.output_base_name().with_extension("s");
26+
let input_file = &self.testpaths.file;
27+
28+
// Use the `//@ assembly-output:` directive to determine how to emit assembly.
29+
let emit = match self.props.assembly_output.as_deref() {
30+
Some("emit-asm") => Emit::Asm,
31+
Some("bpf-linker") => Emit::LinkArgsAsm,
32+
Some("ptx-linker") => Emit::None, // No extra flags needed.
33+
Some(other) => self.fatal(&format!("unknown 'assembly-output' directive: {other}")),
34+
None => self.fatal("missing 'assembly-output' directive"),
35+
};
36+
37+
let rustc = self.make_compile_args(
38+
input_file,
39+
TargetLocation::ThisFile(output_path.clone()),
40+
emit,
41+
AllowUnused::No,
42+
LinkToAux::Yes,
43+
Vec::new(),
44+
);
45+
46+
let proc_res = self.compose_and_run_compiler(rustc, None, self.testpaths);
47+
(proc_res, output_path)
48+
}
1949
}

0 commit comments

Comments
 (0)