Skip to content

Commit 69d1c84

Browse files
committed
Allow to override the artifact name in the bin tests.
1 parent b008f13 commit 69d1c84

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

bin_tests/src/lib.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,25 @@ use once_cell::sync::OnceCell;
2121
/// item, or a `cargo run` command to be able to locate artifacts built by cargo from the position
2222
/// of the current binary.
2323
24-
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
24+
#[derive(Debug, Default, PartialEq, Eq, Hash, Clone, Copy)]
2525
pub enum ArtifactType {
26+
#[default]
2627
ExecutablePackage,
2728
CDylib,
2829
Bin,
2930
}
3031

31-
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
32+
#[derive(Debug, Default, PartialEq, Eq, Hash, Clone, Copy)]
3233
pub enum BuildProfile {
34+
#[default]
3335
Debug,
3436
Release,
3537
}
3638

37-
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
39+
#[derive(Debug, Default, PartialEq, Eq, Hash, Clone)]
3840
pub struct ArtifactsBuild {
3941
pub name: String,
42+
pub lib_name_override: Option<String>,
4043
pub artifact_type: ArtifactType,
4144
pub build_profile: BuildProfile,
4245
pub triple_target: Option<String>,
@@ -97,13 +100,14 @@ fn inner_build_artifact(c: &ArtifactsBuild) -> anyhow::Result<PathBuf> {
97100
ArtifactType::ExecutablePackage | ArtifactType::Bin => artifact_path.push(&c.name),
98101
ArtifactType::CDylib => {
99102
let name = "lib".to_owned()
100-
+ &c.name.replace('-', "_")
103+
+ c.lib_name_override.as_deref().unwrap_or(&c.name.replace('-', "_"))
101104
+ "."
102105
+ shared_lib_extension(
103106
c.triple_target
104107
.as_deref()
105108
.unwrap_or(current_platform::CURRENT_PLATFORM),
106109
)?;
110+
println!("NAME: {}", name);
107111
artifact_path.push(name);
108112
}
109113
};

bin_tests/tests/crashtracker_bin_test.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ fn test_crash_tracking_callstack() {
155155
build_profile: BuildProfile::Debug,
156156
artifact_type: ArtifactType::Bin,
157157
triple_target: None,
158+
..Default::default()
158159
};
159160

160161
let fixtures = setup_test_fixtures(&[&crashtracker_receiver, &crashing_app]);
@@ -686,12 +687,14 @@ fn setup_crashtracking_crates(
686687
build_profile: crash_tracking_receiver_profile,
687688
artifact_type: ArtifactType::Bin,
688689
triple_target: None,
690+
..Default::default()
689691
};
690692
let crashtracker_receiver = ArtifactsBuild {
691693
name: "crashtracker_receiver".to_owned(),
692694
build_profile: crash_tracking_receiver_profile,
693695
artifact_type: ArtifactType::Bin,
694696
triple_target: None,
697+
..Default::default()
695698
};
696699
(crashtracker_bin, crashtracker_receiver)
697700
}

bin_tests/tests/test_the_tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ fn test_the_tests_inner(profile: BuildProfile) {
2525
build_profile: profile,
2626
artifact_type: ArtifactType::Bin,
2727
triple_target: None,
28+
..Default::default()
2829
};
2930
let crates = &[
3031
&ArtifactsBuild {
3132
name: "libdd-profiling-ffi".to_owned(),
33+
lib_name_override: Some("datadog_profiling_ffi".to_owned()),
3234
build_profile: profile,
3335
artifact_type: ArtifactType::CDylib,
3436
triple_target: None,

0 commit comments

Comments
 (0)