Skip to content

Commit a920dfd

Browse files
Sync with star.
1 parent 1226431 commit a920dfd

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

flake.nix

+7-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
workspace = version: (craneLib version).buildPackage (commonArgs // {
3333
cargoArtifacts = workspaceDeps version;
3434
});
35+
workspaceEmptyFeature = version: (craneLib version).buildPackage (commonArgs // {
36+
cargoArtifacts = workspaceDeps version;
37+
cargoClippyExtraArgs = "--no-default-features";
38+
});
3539
clippy = version: (craneLib version).cargoClippy (commonArgs // {
3640
cargoArtifacts = workspaceDeps version;
3741
cargoClippyExtraArgs = "--all-targets -- -D warnings";
@@ -47,6 +51,7 @@
4751
inherit craneLib workspaceDeps;
4852
antithesis-sdk-rust = {
4953
workspace = workspace "nightly";
54+
workspaceEmptyFeature = workspaceEmptyFeature "nightly";
5055
workspaceMSRV = workspace (lib.importTOML ./lib/Cargo.toml).package.rust-version;
5156
clippy = clippy "nightly";
5257
test = test "nightly";
@@ -71,9 +76,9 @@
7176
packages = with pkgs; [ rust-analyzer cargo-msrv ];
7277
};
7378

74-
# TODO: Check combinations of feature flags & semver check.
79+
# TODO: Perform semver check.
7580
checks = { antithesis-sdk-rust, ... }: {
76-
inherit (antithesis-sdk-rust) workspaceMSRV clippy test;
81+
inherit (antithesis-sdk-rust) workspaceMSRV workspaceEmptyFeature clippy test;
7782
};
7883

7984
# TODO: Decide whether we want auto formatting.

lib/src/assert/macros.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ macro_rules! assert_helper {
8484
#[doc(hidden)]
8585
#[macro_export]
8686
macro_rules! assert_helper {
87-
(condition = $condition:expr, $message:literal, $details:expr, $assert_type:path, $display_type:literal, must_hit = $must_hit:literal) => {{
87+
(condition = $condition:expr, $message:literal, $(details = $details:expr)?, $assert_type:path, $display_type:literal, must_hit = $must_hit:literal) => {{
8888
// Force evaluation of expressions, ensuring that
8989
// any side effects of these expressions will always be
9090
// evaluated at runtime - even if the assertion itself
9191
// is supressed by the `no-antithesis-sdk` feature
9292
let condition = $condition;
93-
let details = $details;
93+
$(let details = $details;)?
9494
}};
9595
}
9696

@@ -367,7 +367,7 @@ macro_rules! numeric_guidance_helper {
367367
#[doc(hidden)]
368368
#[macro_export]
369369
macro_rules! numeric_guidance_helper {
370-
($assert:ident, $op:tt, $maximize:literal, $left:expr, $right:expr, $message:literal$(, $details:expr)?) => {
370+
($assert:path, $op:tt, $maximize:literal, $left:expr, $right:expr, $message:literal$(, $details:expr)?) => {
371371
assert!($left $op $right, $message$(, $details)?);
372372
};
373373
}
@@ -398,8 +398,11 @@ macro_rules! boolean_guidance_helper {
398398
#[macro_export]
399399
macro_rules! boolean_guidance_helper {
400400
($assert:path, $all:literal, {$($name:ident: $cond:expr),*}, $message:literal$(, $details:expr)?) => {{
401-
let cond = if $all { true $(&& $name)* } else { false $(|| $name)* },
402-
$assert!(cond, $message$(, &$details)?);
401+
let cond = {
402+
$(let $name = $cond;)*
403+
if $all { true $(&& $name)* } else { false $(|| $name)* }
404+
};
405+
$assert!(cond, $message$(, $details)?);
403406
}};
404407
}
405408

lib/src/assert/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ use std::collections::HashMap;
1414
#[cfg(feature = "full")]
1515
use std::sync::Mutex;
1616

17-
use self::guidance::GuidanceCatalogInfo;
18-
1917
mod macros;
2018
#[doc(hidden)]
19+
#[cfg(feature = "full")]
2120
pub mod guidance;
2221

2322
/// Catalog of all antithesis assertions provided
@@ -30,7 +29,7 @@ pub static ANTITHESIS_CATALOG: [AssertionCatalogInfo];
3029
#[doc(hidden)]
3130
#[distributed_slice]
3231
#[cfg(feature = "full")]
33-
pub static ANTITHESIS_GUIDANCE_CATALOG: [GuidanceCatalogInfo];
32+
pub static ANTITHESIS_GUIDANCE_CATALOG: [self::guidance::GuidanceCatalogInfo];
3433

3534
// Only need an ASSET_TRACKER if there are actually assertions 'hit'
3635
// (i.e. encountered and invoked at runtime).

0 commit comments

Comments
 (0)