From fbbc6ca29c4f60e8b3821b68e05ee1cbccc8b922 Mon Sep 17 00:00:00 2001 From: Rain Date: Sun, 26 Nov 2023 21:45:57 -0800 Subject: [PATCH] [nextest-metadata] treat proc-macro as lib for binary ID Currently, we generate something like `derive::proc-macro/derive`. A proc-macro is a kind of library, so just collapse that down to `derive`. --- .../tests/integration/fixtures.rs | 4 +-- ...ntegration__show_config_test_groups-2.snap | 3 +-- ...ntegration__show_config_test_groups-4.snap | 3 +-- ...ntegration__show_config_test_groups-6.snap | 3 +-- nextest-metadata/src/test_list.rs | 27 ++++++++++++------- nextest-runner/tests/integration/fixtures.rs | 8 ++---- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/integration-tests/tests/integration/fixtures.rs b/integration-tests/tests/integration/fixtures.rs index 053eb73994a..6002397be60 100644 --- a/integration-tests/tests/integration/fixtures.rs +++ b/integration-tests/tests/integration/fixtures.rs @@ -69,7 +69,7 @@ pub static EXPECTED_LIST: Lazy> = Lazy::new(|| { ], ), TestInfo::new( - "nextest-derive::proc-macro/nextest-derive", + "nextest-derive", BuildPlatform::Host, vec![("it_works", false)], ), @@ -419,7 +419,7 @@ pub fn check_run_output(stderr: &[u8], relocated: bool) { (true, "nextest-tests::other other_test_success"), (true, "nextest-tests::basic test_success"), (false, "nextest-tests::segfault test_segfault"), - (true, "nextest-derive::proc-macro/nextest-derive it_works"), + (true, "nextest-derive it_works"), ( true, "nextest-tests::example/other tests::other_example_success", diff --git a/integration-tests/tests/integration/snapshots/integration__show_config_test_groups-2.snap b/integration-tests/tests/integration/snapshots/integration__show_config_test_groups-2.snap index 9d75bbd1459..90ffbe6614f 100644 --- a/integration-tests/tests/integration/snapshots/integration__show_config_test_groups-2.snap +++ b/integration-tests/tests/integration/snapshots/integration__show_config_test_groups-2.snap @@ -12,7 +12,7 @@ group: @global tests::test_multiply_two_cdylib cdylib-link: test_multiply_two - nextest-derive::proc-macro/nextest-derive: + nextest-derive: it_works nextest-tests: tests::call_dylib_add_two @@ -46,4 +46,3 @@ group: @global tests::example_success nextest-tests::example/other: tests::other_example_success - diff --git a/integration-tests/tests/integration/snapshots/integration__show_config_test_groups-4.snap b/integration-tests/tests/integration/snapshots/integration__show_config_test_groups-4.snap index 73138c9e72f..12dd0d855bf 100644 --- a/integration-tests/tests/integration/snapshots/integration__show_config_test_groups-4.snap +++ b/integration-tests/tests/integration/snapshots/integration__show_config_test_groups-4.snap @@ -15,7 +15,7 @@ group: @global tests::test_multiply_two_cdylib cdylib-link: test_multiply_two - nextest-derive::proc-macro/nextest-derive: + nextest-derive: it_works nextest-tests: tests::call_dylib_add_two @@ -47,4 +47,3 @@ group: @global tests::example_success nextest-tests::example/other: tests::other_example_success - diff --git a/integration-tests/tests/integration/snapshots/integration__show_config_test_groups-6.snap b/integration-tests/tests/integration/snapshots/integration__show_config_test_groups-6.snap index 7fbed015da2..eeba532bf59 100644 --- a/integration-tests/tests/integration/snapshots/integration__show_config_test_groups-6.snap +++ b/integration-tests/tests/integration/snapshots/integration__show_config_test_groups-6.snap @@ -14,7 +14,7 @@ group: @global tests::test_multiply_two_cdylib cdylib-link: test_multiply_two - nextest-derive::proc-macro/nextest-derive: + nextest-derive: it_works nextest-tests: tests::call_dylib_add_two @@ -48,4 +48,3 @@ group: @global tests::example_success nextest-tests::example/other: tests::other_example_success - diff --git a/nextest-metadata/src/test_list.rs b/nextest-metadata/src/test_list.rs index 275d62e9ed8..24b3cd3cac4 100644 --- a/nextest-metadata/src/test_list.rs +++ b/nextest-metadata/src/test_list.rs @@ -202,8 +202,8 @@ pub struct RustTestBinarySummary { /// Information about the kind of a Rust test binary. /// -/// Kinds are used to generate binary IDs and to figure out whether some environment variables -/// should be set. +/// Kinds are used to generate [`RustBinaryId`] instances, and to figure out whether some +/// environment variables should be set. #[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Deserialize, Serialize)] #[serde(transparent)] pub struct RustTestBinaryKind(pub Cow<'static, str>); @@ -287,8 +287,9 @@ impl RustBinaryId { /// /// The algorithm is as follows: /// - /// 1. If the target is the `lib` target (for unit tests), the binary ID is the same as the - /// package name. There can only be one library per package, so this will always be unique. + /// 1. If the kind is `lib` or `proc-macro` (i.e. for unit tests), the binary ID is the same as + /// the package name. There can only be one library per package, so this will always be + /// unique. /// 2. If the target is an integration test, the binary ID is `package_name::target_name`. /// 3. Otherwise, the binary ID is `package_name::{kind}/{target_name}`. /// @@ -299,27 +300,33 @@ impl RustBinaryId { /// ``` /// use nextest_metadata::{RustBinaryId, RustTestBinaryKind}; /// + /// // The lib and proc-macro kinds. /// assert_eq!( /// RustBinaryId::from_parts("foo-lib", &RustTestBinaryKind::LIB, "foo_lib"), /// RustBinaryId::new("foo-lib"), /// ); + /// assert_eq!( + /// RustBinaryId::from_parts("foo-derive", &RustTestBinaryKind::PROC_MACRO, "derive"), + /// RustBinaryId::new("foo-derive"), + /// ); /// + /// // Integration tests. /// assert_eq!( /// RustBinaryId::from_parts("foo-lib", &RustTestBinaryKind::TEST, "foo_test"), /// RustBinaryId::new("foo-lib::foo_test"), /// ); /// + /// // Other kinds. /// assert_eq!( /// RustBinaryId::from_parts("foo-lib", &RustTestBinaryKind::BIN, "foo_bin"), - /// RustBinaryId::new("foo-lib::foo_bin"), + /// RustBinaryId::new("foo-lib::bin/foo_bin"), /// ); /// ``` pub fn from_parts(package_name: &str, kind: &RustTestBinaryKind, target_name: &str) -> Self { let mut id = package_name.to_owned(); // To ensure unique binary IDs, we use the following scheme: - if kind == &RustTestBinaryKind::LIB { - // 1. If the target is a lib, use the package name. There can only be one - // lib per package, so this will always be unique. + if kind == &RustTestBinaryKind::LIB || kind == &RustTestBinaryKind::PROC_MACRO { + // 1. The binary ID is the same as the package name. } else if kind == &RustTestBinaryKind::TEST { // 2. For integration tests, use package_name::target_name. Cargo enforces unique names // for the same kind of targets in a package, so these will always be unique. @@ -327,8 +334,8 @@ impl RustBinaryId { id.push_str(target_name); } else { // 3. For all other target kinds, use a combination of the target kind and - // the target name. For the same reason as above, these will always be - // unique. + // the target name. For the same reason as above, these will always be + // unique. write!(id, "::{kind}/{target_name}").unwrap(); } diff --git a/nextest-runner/tests/integration/fixtures.rs b/nextest-runner/tests/integration/fixtures.rs index 19b50fa4d57..8c2d0a90756 100644 --- a/nextest-runner/tests/integration/fixtures.rs +++ b/nextest-runner/tests/integration/fixtures.rs @@ -157,7 +157,7 @@ pub(crate) static EXPECTED_TESTS: Lazy>> TestFixture { name: "tests::test_execute_bin", status: FixtureStatus::Pass }, ], // Proc-macro tests - "nextest-derive::proc-macro/nextest-derive".into() => vec![ + "nextest-derive".into() => vec![ TestFixture { name: "it_works", status: FixtureStatus::Pass }, ], // Dynamic library tests @@ -182,11 +182,7 @@ pub(crate) fn get_expected_test(binary_id: &RustBinaryId, test_name: &str) -> &' } pub(crate) static EXPECTED_BINARY_LIST: [(&str, &str, bool); 8] = [ - ( - "nextest-derive::proc-macro/nextest-derive", - "nextest-derive", - false, - ), + ("nextest-derive", "nextest-derive", false), ("nextest-tests", "nextest-tests", true), ("nextest-tests::basic", "basic", true), ("nextest-tests::bin/nextest-tests", "nextest-tests", true),