Skip to content

Commit

Permalink
Do not validate extensions in tests :-(
Browse files Browse the repository at this point in the history
  • Loading branch information
acl-cqc committed Jan 29, 2025
1 parent f7f3493 commit c6f446b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions hugr-passes/src/composable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,23 @@ pub enum ValidatePassError<E> {
Underlying(E),
}

/// Runs another, underlying, pass, with validation of the Hugr
/// both before and afterwards.
pub struct ValidatingPass<P>(P, bool);

impl<P: ComposablePass> ValidatingPass<P> {
pub fn new_default(underlying: P) -> Self {
Self(underlying, cfg!(feature = "extension_inference"))
// Self(underlying, cfg!(feature = "extension_inference"))
// Sadly, many tests fail with extension inference, hence:
Self(underlying, false)
}

pub fn new_validating_extensions(underlying: P) -> Self {
Self(underlying, true)
}

pub fn new(underlying: P, extensions: bool) -> Self {
Self(underlying, extensions)
pub fn new(underlying: P, validate_extensions: bool) -> Self {
Self(underlying, validate_extensions)
}

fn validation_impl<E>(
Expand Down Expand Up @@ -121,7 +125,7 @@ pub fn validate_if_test<P: ComposablePass>(
pass: P,
hugr: &mut impl HugrMut,
) -> Result<(), ValidatePassError<P::Err>> {
if cfg!(feature = "extension_inference") {
if cfg!(test) {
ValidatingPass::new_default(pass).run(hugr)
} else {
pass.run(hugr).map_err(ValidatePassError::Underlying)
Expand Down
2 changes: 1 addition & 1 deletion hugr-passes/src/dead_funcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub enum RemoveDeadFuncsError {
InvalidEntryPoint {
/// The invalid node.
node: Node,
}
},
}

fn reachable_funcs<'a>(
Expand Down

0 comments on commit c6f446b

Please sign in to comment.