Skip to content

Commit acb97fd

Browse files
tgross35mbyx
andcommitted
test: Add basic configuration to use ctest-next
Set up a Cargo dependency on ctest-next, which is now published as a beta version of ctest. Includes a backport of only the libc-test portions of d8cc878 ("ctest-next: miscellaneous filtering bug fixes") to reduce conflicts with future cherry picks. Co-authored-by: mbyx <[email protected]>
1 parent 0c6f708 commit acb97fd

File tree

4 files changed

+136
-4
lines changed

4 files changed

+136
-4
lines changed

Cargo.lock

Lines changed: 111 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libc-test/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ annotate-snippets = { version = "0.11.5", features = ["testing-colors"] }
2222
cc = "1.2.29"
2323
# FIXME: Use fork ctest until the maintainer gets back.
2424
ctest2 = "0.4.3"
25+
# Use the in-tree `ctest` from the `main` branch via crates.io
26+
ctest_next = { version = "0.5.0-beta.0", package = "ctest" }
2527
regex = "1.11.1"
2628

2729
[features]
@@ -35,6 +37,11 @@ name = "ctest"
3537
path = "test/ctest.rs"
3638
harness = false
3739

40+
[[test]]
41+
name = "ctest_next"
42+
path = "test/ctest_next.rs"
43+
harness = false
44+
3845
[[test]]
3946
name = "linux-fcntl"
4047
path = "test/linux_fcntl.rs"

libc-test/build.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ fn ctest_cfg() -> ctest::TestGenerator {
8484
cfg
8585
}
8686

87+
#[expect(unused)]
88+
fn ctest_next_cfg() -> ctest_next::TestGenerator {
89+
ctest_next::TestGenerator::new()
90+
}
91+
8792
fn do_semver() {
8893
let mut out = PathBuf::from(env::var("OUT_DIR").unwrap());
8994
out.push("semver.rs");
@@ -171,6 +176,14 @@ fn main() {
171176
let re = regex::bytes::Regex::new(r"(?-u:\b)crate::").unwrap();
172177
copy_dir_hotfix(Path::new("../src"), &hotfix_dir, &re, b"::");
173178

179+
// FIXME(ctest): Only needed until ctest-next supports all tests.
180+
// Provide a default for targets that don't yet use `ctest-next`.
181+
std::fs::write(
182+
format!("{}/main_next.rs", std::env::var("OUT_DIR").unwrap()),
183+
"\nfn main() { println!(\"test result: ok\"); }\n",
184+
)
185+
.unwrap();
186+
174187
do_cc();
175188
do_ctest();
176189
do_semver();

libc-test/test/ctest_next.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#[allow(deprecated)]
2+
#[allow(unused_imports)]
3+
use libc::*;
4+
5+
include!(concat!(env!("OUT_DIR"), "/main_next.rs"));

0 commit comments

Comments
 (0)