Skip to content

Commit

Permalink
test: consolidate #[cfg(feature = "graphviz-dot")] for tests into o…
Browse files Browse the repository at this point in the history
…ne place
  • Loading branch information
antalsz committed Jan 9, 2025
1 parent 6d682d7 commit b632d89
Show file tree
Hide file tree
Showing 13 changed files with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions quil-rs/src/program/scheduling/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,13 +547,12 @@ impl<'a> From<ScheduledBasicBlock<'a>> for ScheduledBasicBlockOwned {
}
}

#[cfg(test)]
mod tests {
#[cfg(all(test, feature = "graphviz-dot"))]
mod graphviz_dot_tests {
use super::*;
#[cfg(feature = "graphviz-dot")]

use crate::program::scheduling::graphviz_dot::tests::build_dot_format_snapshot_test_case;

#[cfg(feature = "graphviz-dot")]
mod custom_handler {
use super::*;

Expand Down Expand Up @@ -700,7 +699,6 @@ PRAGMA RAW-INSTRUCTION foo

// Because any instruction that reads a particular region must be preceded by any earlier instructions that write to/ capture that memory region,
// we expect an edge from the first load to the second (0 -> 1).
#[cfg(feature = "graphviz-dot")]
build_dot_format_snapshot_test_case! {
classical_write_read_load_load,
r#"
Expand All @@ -715,7 +713,6 @@ LOAD params1[0] params2 integers[0] # reads params2

// Because any instruction that reads a particular region must be preceded by any earlier instructions that write to/ capture that memory region,
// we expect an edge from the mul to the load (0 -> 1).
#[cfg(feature = "graphviz-dot")]
build_dot_format_snapshot_test_case! {
classical_write_read_mul_load,
r#"
Expand All @@ -730,7 +727,6 @@ LOAD params1[0] params2 integers[0] # just reads params2

// Because any instruction that reads a particular region must be preceded by any earlier instructions that write to/ capture that memory region,
// we expect an edge from the mul to the add (0 -> 1).
#[cfg(feature = "graphviz-dot")]
build_dot_format_snapshot_test_case! {
classical_write_read_add_mul,
r#"
Expand All @@ -745,7 +741,6 @@ MUL params1[0] 2 # this reads and writes params1

// Because any instruction that reads a particular region must precede any later instructions that write to/ capture that memory region,
// we expect an edge from the first load to the second (0, 1).
#[cfg(feature = "graphviz-dot")]
build_dot_format_snapshot_test_case! {
classical_read_write_load_load,
r#"
Expand All @@ -760,7 +755,6 @@ LOAD params2[0] params3 integers[0] # writes params2

// Because any instruction that reads a particular region must precede any later instructions that write to/ capture that memory region,
// we expect an edge from the load to the mul (0, 1).
#[cfg(feature = "graphviz-dot")]
build_dot_format_snapshot_test_case! {
classical_read_write_load_mul,
r#"
Expand All @@ -776,7 +770,6 @@ MUL params2[0] 2 # reads and writes params2
// Because memory reading and writing dependencies also apply to RfControl instructions, we
// expect edges from the first load to the first shift-phase (0 -> 1), the first shift-phase
// to the second load (1 -> 2), and the second load to the second shift-phase (2 -> 3).
#[cfg(feature = "graphviz-dot")]
build_dot_format_snapshot_test_case! {
quantum_write_parameterized_operations,
r#"
Expand All @@ -797,13 +790,11 @@ SHIFT-PHASE 1 "rf" params2[0] # reads params2
}

// Because a pragma by default will have no memory accesses, it should only have edges from the block start and to the block end.
#[cfg(feature = "graphviz-dot")]
build_dot_format_snapshot_test_case! {
classical_no_memory_pragma,
r#"PRAGMA example"#
}

#[cfg(feature = "graphviz-dot")]
build_dot_format_snapshot_test_case! {
write_capture_read,
r#"
Expand All @@ -815,7 +806,6 @@ LOAD bits3[0] bits integers[0] # read
"#
}

#[cfg(feature = "graphviz-dot")]
build_dot_format_snapshot_test_case! {
write_write_read,
r#"
Expand Down

0 comments on commit b632d89

Please sign in to comment.