Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions fixtures/custom-target/my-target-2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"arch": "x86_64",
"cpu": "x86-64",
"crt-static-respected": true,
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
"dynamic-linking": true,
"env": "gnu",
"has-rpath": true,
"has-thread-local": true,
"llvm-target": "x86_64-unknown-linux-gnu",
"max-atomic-width": 64,
"os": "linux",
"position-independent-executables": true,
"pre-link-args": {
"gcc": [
"-m64"
]
},
"relro-level": "full",
"stack-probes": {
"kind": "inline-or-call",
"min-llvm-version-for-inline": [
16,
0,
0
]
},
"static-position-independent-executables": true,
"supported-sanitizers": [
"address",
"cfi",
"leak",
"memory",
"thread"
],
"supported-split-debuginfo": [
"packed",
"unpacked",
"off"
],
"supports-xray": true,
"target-family": [
"unix"
],
"target-pointer-width": 64
}
4 changes: 4 additions & 0 deletions nextest-filtering/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Copyright (c) The nextest Contributors
// SPDX-License-Identifier: MIT OR Apache-2.0

// rust nightly 2025-10-12 complains that "value assigned to `kind` is never
// read", and this is the nearest location this works in. Maybe a miette issue?
#![allow(unused_assignments)]

use crate::expression::FiltersetKind;
use miette::{Diagnostic, SourceSpan};
use std::fmt;
Expand Down
177 changes: 98 additions & 79 deletions nextest-runner/tests/integration/target_triple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,109 +44,128 @@ fn parses_cargo_env() {
}

static MY_TARGET_TRIPLE_STR: &str = "my-target";
static MY_TARGET_2_TRIPLE_STR: &str = "my-target-2";
static MY_TARGET_JSON_PATH: &str = "../custom-target/my-target.json";
static MY_TARGET_2_JSON_PATH: &str = "../custom-target/my-target-2.json";
static MY_TARGET_PATHS: &[(&str, &str)] = &[
(MY_TARGET_JSON_PATH, MY_TARGET_TRIPLE_STR),
(MY_TARGET_2_JSON_PATH, MY_TARGET_2_TRIPLE_STR),
];

#[test]
fn parses_custom_target_cli() {
// SAFETY:
// https://nexte.st/docs/configuration/env-vars/#altering-the-environment-within-tests
unsafe { std::env::set_var("CARGO_BUILD_TARGET", "x86_64-unknown-linux-musl") };
let expected_path = workspace_root()
.join(MY_TARGET_JSON_PATH)
.canonicalize_utf8()
.expect("canonicalization succeeded");
let triple = target_triple(Some(MY_TARGET_JSON_PATH), Vec::new())
.unwrap()
.expect("platform found");
assert_eq!(
triple.platform.triple_str(),
MY_TARGET_TRIPLE_STR,
"custom platform name"
);

assert!(triple.platform.is_custom(), "custom platform");
assert_eq!(triple.source, TargetTripleSource::CliOption);
assert_eq!(
triple.location,
TargetDefinitionLocation::DirectPath(expected_path)
);
for (target_path, expected_triple) in MY_TARGET_PATHS {
eprintln!("** testing: {}", target_path);
let expected_path = workspace_root()
.join(target_path)
.canonicalize_utf8()
.expect("canonicalization succeeded");
let triple = target_triple(Some(target_path), Vec::new())
.unwrap()
.expect("platform found");
assert_eq!(
triple.platform.triple_str(),
*expected_triple,
"custom platform name"
);

assert!(triple.platform.is_custom(), "custom platform");
assert_eq!(triple.source, TargetTripleSource::CliOption);
assert_eq!(
triple.location,
TargetDefinitionLocation::DirectPath(expected_path)
);
}
}

#[test]
fn parses_custom_target_env() {
// SAFETY:
// https://nexte.st/docs/configuration/env-vars/#altering-the-environment-within-tests
unsafe { std::env::set_var("CARGO_BUILD_TARGET", MY_TARGET_JSON_PATH) };
let expected_path = workspace_root()
.join(MY_TARGET_JSON_PATH)
.canonicalize_utf8()
.expect("canonicalization succeeded");
let triple = target_triple(None, Vec::new())
.unwrap()
.expect("platform found");
assert_eq!(
triple.platform.triple_str(),
MY_TARGET_TRIPLE_STR,
"custom platform name"
);

assert!(triple.platform.is_custom(), "custom platform");
assert_eq!(triple.source, TargetTripleSource::Env);
assert_eq!(
triple.location,
TargetDefinitionLocation::DirectPath(expected_path)
);
for (target_path, expected_triple) in MY_TARGET_PATHS {
eprintln!("** testing: {}", target_path);
unsafe { std::env::set_var("CARGO_BUILD_TARGET", target_path) };
let expected_path = workspace_root()
.join(target_path)
.canonicalize_utf8()
.expect("canonicalization succeeded");
let triple = target_triple(None, Vec::new())
.unwrap()
.expect("platform found");
assert_eq!(
triple.platform.triple_str(),
*expected_triple,
"custom platform name"
);

assert!(triple.platform.is_custom(), "custom platform");
assert_eq!(triple.source, TargetTripleSource::Env);
assert_eq!(
triple.location,
TargetDefinitionLocation::DirectPath(expected_path)
);
}
}

#[test]
fn parses_custom_target_cli_from_rust_target_path() {
let target_paths = vec![workspace_root().join("../custom-target")];
let expected_path = workspace_root()
.join(MY_TARGET_JSON_PATH)
.canonicalize_utf8()
.expect("canonicalization succeeded");
let triple = target_triple(Some(MY_TARGET_TRIPLE_STR), target_paths)
.unwrap()
.expect("platform found");
assert_eq!(
triple.platform.triple_str(),
MY_TARGET_TRIPLE_STR,
"custom platform name"
);

assert!(triple.platform.is_custom(), "custom platform");
assert_eq!(triple.source, TargetTripleSource::CliOption);
assert_eq!(
triple.location,
TargetDefinitionLocation::RustTargetPath(expected_path)
);
for (target_path, expected_triple) in MY_TARGET_PATHS {
eprintln!("** testing: {}", expected_triple);
let expected_path = workspace_root()
.join(target_path)
.canonicalize_utf8()
.expect("canonicalization succeeded");
let triple = target_triple(Some(expected_triple), target_paths.clone())
.unwrap()
.expect("platform found");
assert_eq!(
triple.platform.triple_str(),
*expected_triple,
"custom platform name"
);

assert!(triple.platform.is_custom(), "custom platform");
assert_eq!(triple.source, TargetTripleSource::CliOption);
assert_eq!(
triple.location,
TargetDefinitionLocation::RustTargetPath(expected_path)
);
}
}

#[test]
fn parses_custom_target_env_from_rust_target_path() {
// SAFETY:
// https://nexte.st/docs/configuration/env-vars/#altering-the-environment-within-tests
unsafe { std::env::set_var("CARGO_BUILD_TARGET", MY_TARGET_TRIPLE_STR) };
let target_paths = vec![workspace_root().join("../custom-target")];
let expected_path = workspace_root()
.join(MY_TARGET_JSON_PATH)
.canonicalize_utf8()
.expect("canonicalization succeeded");
let triple = target_triple(None, target_paths)
.unwrap()
.expect("platform found");
assert_eq!(
triple.platform.triple_str(),
MY_TARGET_TRIPLE_STR,
"custom platform name"
);

assert!(triple.platform.is_custom(), "custom platform");
assert_eq!(triple.source, TargetTripleSource::Env);
assert_eq!(
triple.location,
TargetDefinitionLocation::RustTargetPath(expected_path)
);
for (target_path, expected_triple) in MY_TARGET_PATHS {
eprintln!("** testing: {}", expected_triple);
// SAFETY:
// https://nexte.st/docs/configuration/env-vars/#altering-the-environment-within-tests
unsafe { std::env::set_var("CARGO_BUILD_TARGET", expected_triple) };
let expected_path = workspace_root()
.join(target_path)
.canonicalize_utf8()
.expect("canonicalization succeeded");
let triple = target_triple(None, target_paths.clone())
.unwrap()
.expect("platform found");
assert_eq!(
triple.platform.triple_str(),
*expected_triple,
"custom platform name"
);

assert!(triple.platform.is_custom(), "custom platform");
assert_eq!(triple.source, TargetTripleSource::Env);
assert_eq!(
triple.location,
TargetDefinitionLocation::RustTargetPath(expected_path)
);
}
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions workspace-hack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ console = { version = "0.16.0" }
either = { version = "1.15.0", features = ["use_std"] }
form_urlencoded = { version = "1.2.2" }
getrandom = { version = "0.3.3", default-features = false, features = ["std"] }
hashbrown = { version = "0.16.0", default-features = false, features = ["allocator-api2", "inline-more"] }
hashbrown = { version = "0.15.5" }
indexmap = { version = "2.11.4", features = ["serde"] }
log = { version = "0.4.28", default-features = false, features = ["std"] }
memchr = { version = "2.7.5" }
Expand All @@ -39,7 +39,7 @@ serde = { version = "1.0.228", features = ["alloc", "derive"] }
serde_core = { version = "1.0.228", features = ["alloc"] }
serde_json = { version = "1.0.145", features = ["unbounded_depth"] }
smallvec = { version = "1.15.1", default-features = false, features = ["const_generics"] }
target-spec = { version = "3.5.2", default-features = false, features = ["custom", "summaries"] }
target-spec = { version = "3.5.4", default-features = false, features = ["custom", "summaries"] }
target-spec-miette = { version = "0.4.5", default-features = false, features = ["fixtures"] }
tokio = { version = "1.47.1", features = ["fs", "io-std", "io-util", "macros", "process", "rt-multi-thread", "signal", "sync", "time", "tracing"] }
tracing-core = { version = "0.1.34" }
Expand Down
Loading