mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2024-10-29 21:42:20 +00:00
Allow running cargo compiletest
from any sub-directory in the workspace.
This commit is contained in:
parent
27a1705d2e
commit
e6a9dcec1c
@ -4,4 +4,4 @@
|
||||
rustflags = "-C prefer-dynamic"
|
||||
|
||||
[alias]
|
||||
compiletest = "run --release --manifest-path=tests/Cargo.toml"
|
||||
compiletest = "run --release -p compiletests"
|
||||
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -345,7 +345,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "compiletest_rs"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/Manishearth/compiletest-rs.git?rev=1f4a4c4#1f4a4c40e06ba36fef63909ddfaa76edcb2ac620"
|
||||
source = "git+https://github.com/Manishearth/compiletest-rs.git?rev=9257f6d#9257f6dd0a9687dd36897684ae18a124ac34016b"
|
||||
dependencies = [
|
||||
"diff",
|
||||
"filetime",
|
||||
|
@ -26,6 +26,7 @@ codegen-units = 16
|
||||
spirv-std = { path = "./crates/spirv-std" }
|
||||
spirv-std-macros = { path = "./crates/spirv-std-macros" }
|
||||
glam = { git = "https://github.com/bitshifter/glam-rs.git", rev ="b3e94fb" }
|
||||
# TODO: Needed for handling SPIR-V extension across platforms. Remove once
|
||||
# next version is released.
|
||||
compiletest_rs= { git = "https://github.com/Manishearth/compiletest-rs.git", rev = "1f4a4c4" }
|
||||
# TODO: Remove once next version is released - needed to include these two PRs:
|
||||
# * Manishearth/compiletest-rs#240 (for handling SPIR-V extension across platforms)
|
||||
# * Manishearth/compiletest-rs#241 (for the `$TEST_BUILD_DIR` path normalization)
|
||||
compiletest_rs = { git = "https://github.com/Manishearth/compiletest-rs.git", rev = "9257f6d" }
|
||||
|
@ -29,7 +29,9 @@ impl DepKind {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let original_target_dir = Path::new("./target");
|
||||
let tests_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
|
||||
let workspace_root = tests_dir.parent().unwrap();
|
||||
let original_target_dir = workspace_root.join("target");
|
||||
let deps_target_dir = original_target_dir.join("compiletest-deps");
|
||||
let compiletest_build_dir = original_target_dir.join("compiletest-results");
|
||||
|
||||
@ -40,6 +42,7 @@ fn main() {
|
||||
|
||||
run_mode(
|
||||
"ui",
|
||||
tests_dir,
|
||||
compiletest_build_dir,
|
||||
&deps_target_dir,
|
||||
&codegen_backend_path,
|
||||
@ -53,6 +56,7 @@ fn main() {
|
||||
/// backend provided by `codegen_backend_path`.
|
||||
fn run_mode(
|
||||
mode: &'static str,
|
||||
tests_dir: &Path,
|
||||
compiletest_build_dir: PathBuf,
|
||||
deps_target_dir: &Path,
|
||||
codegen_backend_path: &Path,
|
||||
@ -105,7 +109,7 @@ fn run_mode(
|
||||
config.target_rustcflags = Some(flags);
|
||||
config.mode = mode.parse().expect("Invalid mode");
|
||||
config.target = String::from(TARGET);
|
||||
config.src_base = PathBuf::from(format!("./tests/{}", mode));
|
||||
config.src_base = tests_dir.join(mode);
|
||||
config.build_base = compiletest_build_dir;
|
||||
config.bless = std::env::args().any(|a| a == "--bless");
|
||||
config.clean_rmeta();
|
||||
@ -115,6 +119,11 @@ fn run_mode(
|
||||
|
||||
/// Runs the processes needed to build `spirv-std` & other deps.
|
||||
fn build_deps(deps_target_dir: &Path, codegen_backend_path: &Path) -> TestDeps {
|
||||
// HACK(eddyb) this is only needed until we enable `resolver = "2"`, as the
|
||||
// old ("1") resolver has a bug where it picks up extra features based on the
|
||||
// current directory (and so we always set the working dir as a workaround).
|
||||
let old_cargo_resolver_workaround_cwd = deps_target_dir.parent().unwrap();
|
||||
|
||||
// Build compiletests-deps-helper
|
||||
std::process::Command::new("cargo")
|
||||
.args(&[
|
||||
@ -127,6 +136,7 @@ fn build_deps(deps_target_dir: &Path, codegen_backend_path: &Path) -> TestDeps {
|
||||
.arg("--target-dir")
|
||||
.arg(deps_target_dir)
|
||||
.env("RUSTFLAGS", rust_flags(&codegen_backend_path))
|
||||
.current_dir(old_cargo_resolver_workaround_cwd)
|
||||
.stderr(std::process::Stdio::inherit())
|
||||
.stdout(std::process::Stdio::inherit())
|
||||
.status()
|
||||
|
@ -7,7 +7,7 @@ error: pointer has non-null integer address
|
||||
error: invalid binary:0:0 - No OpEntryPoint instruction was found. This is only allowed if the Linkage capability is being used.
|
||||
|
|
||||
= note: spirv-val failed
|
||||
= note: module "./target/compiletest-results/lang/core/ptr/allocate_const_scalar.stage-id.spv"
|
||||
= note: module "$TEST_BUILD_DIR/lang/core/ptr/allocate_const_scalar.stage-id.spv"
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user