diff --git a/Cargo.lock b/Cargo.lock index 6b49ee6651ba..26c836d239c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,12 +78,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.9.1" @@ -99,30 +93,12 @@ dependencies = [ "shlex", ] -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - [[package]] name = "cfg-if" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" -[[package]] -name = "ctest" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f18c94d081f9a0355affbeee3f8e677ce206e9aea89b952421f0be6bc588dde" -dependencies = [ - "cc", - "garando_syntax", - "indoc", - "rustc_version", -] - [[package]] name = "ctest" version = "0.5.0-beta.0" @@ -134,7 +110,7 @@ dependencies = [ "quote", "syn", "tempfile", - "thiserror 2.0.12", + "thiserror", ] [[package]] @@ -142,7 +118,7 @@ name = "ctest-test" version = "0.1.0" dependencies = [ "cc", - "ctest 0.5.0-beta.0", + "ctest", "libc 1.0.0-alpha.1", ] @@ -152,27 +128,6 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" -[[package]] -name = "dirs" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" -dependencies = [ - "cfg-if 0.1.10", - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" -dependencies = [ - "libc 0.2.174", - "redox_users", - "winapi", -] - [[package]] name = "errno" version = "0.3.13" @@ -189,64 +144,16 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" -[[package]] -name = "garando_errors" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18495ec4aced5922809efe4d2862918ff0e8d75e122bde57bba9bae45965256a" -dependencies = [ - "garando_pos", - "libc 0.2.174", - "serde", - "term", - "unicode-xid", -] - -[[package]] -name = "garando_pos" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9386fc75dca486daefbbf5a8d2ea6f379237f95c9b982776159cd66f220aaf" -dependencies = [ - "serde", -] - -[[package]] -name = "garando_syntax" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d8a383861d12fc78c251bbcb1ec252dd8338714ce02ab0cc393cfd02f40d32b" -dependencies = [ - "bitflags 1.3.2", - "garando_errors", - "garando_pos", - "log", - "serde", - "serde_json", - "unicode-xid", -] - -[[package]] -name = "getrandom" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" -dependencies = [ - "cfg-if 1.0.1", - "libc 0.2.174", - "wasi 0.11.1+wasi-snapshot-preview1", -] - [[package]] name = "getrandom" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" dependencies = [ - "cfg-if 1.0.1", + "cfg-if", "libc 0.2.174", "r-efi", - "wasi 0.14.2+wasi-0.2.4", + "wasi", ] [[package]] @@ -255,12 +162,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" -[[package]] -name = "indoc" -version = "2.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd" - [[package]] name = "itoa" version = "1.0.15" @@ -286,9 +187,8 @@ version = "0.1.0" dependencies = [ "annotate-snippets", "cc", - "cfg-if 1.0.1", - "ctest 0.4.11", - "ctest 0.5.0-beta.0", + "cfg-if", + "ctest", "glob", "libc 1.0.0-alpha.1", "proc-macro2", @@ -296,28 +196,12 @@ dependencies = [ "syn", ] -[[package]] -name = "libredox" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1580801010e535496706ba011c15f8532df6b42297d2e471fec38ceadd8c0638" -dependencies = [ - "bitflags 2.9.1", - "libc 0.2.174", -] - [[package]] name = "linux-raw-sys" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" -[[package]] -name = "log" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" - [[package]] name = "memchr" version = "2.7.5" @@ -370,17 +254,6 @@ version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" -[[package]] -name = "redox_users" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" -dependencies = [ - "getrandom 0.2.16", - "libredox", - "thiserror 1.0.69", -] - [[package]] name = "regex" version = "1.11.1" @@ -422,22 +295,13 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa9c45b374136f52f2d6311062c7146bff20fec063c3f5d46a410bd937746955" -[[package]] -name = "rustc_version" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" -dependencies = [ - "semver", -] - [[package]] name = "rustix" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" dependencies = [ - "bitflags 2.9.1", + "bitflags", "errno", "libc 0.2.174", "linux-raw-sys", @@ -450,12 +314,6 @@ version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" -[[package]] -name = "semver" -version = "1.0.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" - [[package]] name = "serde" version = "1.0.219" @@ -512,49 +370,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" dependencies = [ "fastrand", - "getrandom 0.3.3", + "getrandom", "once_cell", "rustix", "windows-sys 0.59.0", ] -[[package]] -name = "term" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0863a3345e70f61d613eab32ee046ccd1bcc5f9105fe402c61fcd0c13eeb8b5" -dependencies = [ - "dirs", - "winapi", -] - -[[package]] -name = "thiserror" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" -dependencies = [ - "thiserror-impl 1.0.69", -] - [[package]] name = "thiserror" version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ - "thiserror-impl 2.0.12", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "thiserror-impl", ] [[package]] @@ -580,18 +408,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a1a07cc7db3810833284e8d372ccdc6da29741639ecc70c9ec107df0fa6154c" -[[package]] -name = "unicode-xid" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" - -[[package]] -name = "wasi" -version = "0.11.1+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" - [[package]] name = "wasi" version = "0.14.2+wasi-0.2.4" @@ -601,28 +417,6 @@ dependencies = [ "wit-bindgen-rt", ] -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows-sys" version = "0.59.0" @@ -784,7 +578,7 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ - "bitflags 2.9.1", + "bitflags", ] [[package]] diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 63d396f8a5c1..66940ee8db16 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -20,7 +20,6 @@ annotate-snippets = { version = "0.11.5", features = ["testing-colors"] } [build-dependencies] cc = "1.2.29" -ctest-old = { version = "0.4.11", package = "ctest" } ctest = { path = "../ctest" } regex = "1.11.1" diff --git a/libc-test/build.rs b/libc-test/build.rs index c7f707d68d7a..3146ce669b84 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -6,10 +6,6 @@ use std::io::{BufRead, BufReader, BufWriter, Write}; use std::path::{Path, PathBuf}; use std::{env, io}; -fn src_hotfix_dir() -> PathBuf { - Path::new(&env::var_os("OUT_DIR").unwrap()).join("src-hotfix") -} - fn do_cc() { let target = env::var("TARGET").unwrap(); if cfg!(unix) || target.contains("cygwin") { @@ -73,10 +69,6 @@ fn do_ctest() { } } -fn ctest_old_cfg() -> ctest_old::TestGenerator { - ctest_old::TestGenerator::new() -} - fn ctest_cfg() -> ctest::TestGenerator { let mut cfg = ctest::TestGenerator::new(); cfg.skip_private(true); @@ -161,39 +153,11 @@ fn main() { // Avoid unnecessary re-building. println!("cargo:rerun-if-changed=build.rs"); - let hotfix_dir = src_hotfix_dir(); - if std::fs::exists(&hotfix_dir).unwrap() { - std::fs::remove_dir_all(&hotfix_dir).unwrap(); - } - - // FIXME(ctest): ctest cannot parse `crate::` in paths, so replace them with `::` - let re = regex::bytes::Regex::new(r"(?-u:\b)crate::").unwrap(); - copy_dir_hotfix(Path::new("../src"), &hotfix_dir, &re, b"::"); - do_cc(); do_ctest(); do_semver(); } -// FIXME(clippy): removing `replace` somehow fails the `Test tier1 (x86_64-pc-windows-msvc, windows-2022)` CI job -#[allow(clippy::only_used_in_recursion)] -fn copy_dir_hotfix(src: &Path, dst: &Path, regex: ®ex::bytes::Regex, replace: &[u8]) { - std::fs::create_dir(dst).unwrap(); - for entry in src.read_dir().unwrap() { - let entry = entry.unwrap(); - let src_path = entry.path(); - let dst_path = dst.join(entry.file_name()); - if entry.file_type().unwrap().is_dir() { - copy_dir_hotfix(&src_path, &dst_path, regex, replace); - } else { - // Replace "crate::" with "::" - let src_data = std::fs::read(&src_path).unwrap(); - let dst_data = regex.replace_all(&src_data, b"::"); - std::fs::write(&dst_path, &dst_data).unwrap(); - } - } -} - macro_rules! headers { ($cfg:ident: [$m:expr]: $header:literal) => { if $m { @@ -5077,11 +5041,11 @@ fn which_freebsd() -> Option { fn test_haiku(target: &str) { assert!(target.contains("haiku")); - let mut cfg = ctest_old_cfg(); + let mut cfg = ctest_cfg(); cfg.flag("-Wno-deprecated-declarations"); cfg.define("__USE_GNU", Some("1")); cfg.define("_GNU_SOURCE", None); - cfg.language(ctest_old::Lang::CXX); + cfg.language(ctest::Language::CXX); // POSIX API headers! { cfg: @@ -5216,11 +5180,12 @@ fn test_haiku(target: &str) { "support/TypeConstants.h" } - cfg.skip_struct(move |ty| { - if ty.starts_with("__c_anonymous_") { + cfg.skip_union(|union_| union_.ident().starts_with("__c_anonymous_")); + cfg.skip_struct(move |struct_| { + if struct_.ident().starts_with("__c_anonymous_") { return true; } - match ty { + match struct_.ident() { // FIXME(haiku): locale_t does not exist on Haiku "locale_t" => true, // FIXME(haiku): rusage has a different layout on Haiku @@ -5248,8 +5213,8 @@ fn test_haiku(target: &str) { } }); - cfg.skip_type(move |ty| { - match ty { + cfg.skip_alias(move |ty| { + match ty.ident() { // FIXME(haiku): locale_t does not exist on Haiku "locale_t" => true, // These cause errors, to be reviewed in the future @@ -5262,9 +5227,9 @@ fn test_haiku(target: &str) { } }); - cfg.skip_fn(move |name| { + cfg.skip_fn(move |func| { // skip those that are manually verified - match name { + match func.ident() { // FIXME(haiku): does not exist on haiku "open_wmemstream" => true, "mlockall" | "munlockall" => true, @@ -5287,8 +5252,8 @@ fn test_haiku(target: &str) { } }); - cfg.skip_const(move |name| { - match name { + cfg.skip_const(move |constant| { + match constant.ident() { // FIXME(haiku): these constants do not exist on Haiku "DT_UNKNOWN" | "DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" | "DT_LNK" | "DT_SOCK" => true, @@ -5313,8 +5278,8 @@ fn test_haiku(target: &str) { } }); - cfg.skip_field(move |struct_, field| { - match (struct_, field) { + cfg.skip_struct_field(move |struct_, field| { + match (struct_.ident(), field.ident()) { // FIXME(time): the stat struct actually has timespec members, whereas // the current representation has these unpacked. ("stat", "st_atime") => true, @@ -5348,7 +5313,14 @@ fn test_haiku(target: &str) { _ => false, }); - cfg.type_name(move |ty, is_struct, is_union| { + let c_enums = [ + "directory_which", + "path_base_directory", + "cpu_platform", + "cpu_vendor", + ]; + cfg.alias_is_c_enum(move |e| c_enums.contains(&e)); + cfg.rename_struct_ty(move |ty| { match ty { // Just pass all these through, no need for a "struct" prefix "area_info" @@ -5372,34 +5344,29 @@ fn test_haiku(target: &str) { | "cpu_topology_node_info" | "cpu_topology_root_info" | "cpu_topology_package_info" - | "cpu_topology_core_info" => ty.to_string(), + | "cpu_topology_core_info" => Some(ty.to_string()), - // enums don't need a prefix - "directory_which" | "path_base_directory" | "cpu_platform" | "cpu_vendor" => { - ty.to_string() - } - - t if is_union => format!("union {t}"), - t if t.ends_with("_t") => t.to_string(), - t if is_struct => format!("struct {t}"), - t => t.to_string(), + t if t.ends_with("_t") => Some(t.to_string()), + _ => None, } }); - cfg.field_name(move |struct_, field| { - match field { + cfg.rename_struct_field(move |struct_, field| { + let struct_ = struct_.ident(); + match field.ident() { // Field is named `type` in C but that is a Rust keyword, // so these fields are translated to `type_` in the bindings. - "type_" if struct_ == "object_wait_info" => "type".to_string(), - "type_" if struct_ == "sem_t" => "type".to_string(), - "type_" if struct_ == "attr_info" => "type".to_string(), - "type_" if struct_ == "index_info" => "type".to_string(), - "type_" if struct_ == "cpu_topology_node_info" => "type".to_string(), - "image_type" if struct_ == "image_info" => "type".to_string(), - s => s.to_string(), + "type_" if struct_ == "object_wait_info" => Some("type".to_string()), + "type_" if struct_ == "sem_t" => Some("type".to_string()), + "type_" if struct_ == "attr_info" => Some("type".to_string()), + "type_" if struct_ == "index_info" => Some("type".to_string()), + "type_" if struct_ == "cpu_topology_node_info" => Some("type".to_string()), + "image_type" if struct_ == "image_info" => Some("type".to_string()), + _ => None, } }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); + + ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } fn test_aix(target: &str) {