From b632d899cf64f0b5f9912e02221ffcce0ba2c6cd Mon Sep 17 00:00:00 2001 From: Antal Spector-Zabusky Date: Thu, 9 Jan 2025 01:31:59 -0500 Subject: [PATCH] test: consolidate `#[cfg(feature = "graphviz-dot")]` for tests into one place --- quil-rs/src/program/scheduling/graph.rs | 16 +++------------- ...z_dot_tests__classical_no_memory_pragma.snap} | 0 ...t_tests__classical_read_write_load_load.snap} | 0 ...ot_tests__classical_read_write_load_mul.snap} | 0 ...dot_tests__classical_write_read_add_mul.snap} | 0 ...t_tests__classical_write_read_load_load.snap} | 0 ...ot_tests__classical_write_read_mul_load.snap} | 0 ...ustom_handler__mixed_pragmas_and_pulses.snap} | 0 ...ustom_handler__only_pragmas_with_frames.snap} | 0 ...om_handler__only_pragmas_without_frames.snap} | 0 ..._quantum_write_parameterized_operations.snap} | 0 ..._graphviz_dot_tests__write_capture_read.snap} | 0 ...h__graphviz_dot_tests__write_write_read.snap} | 0 13 files changed, 3 insertions(+), 13 deletions(-) rename quil-rs/src/program/scheduling/snapshots/{quil_rs__program__scheduling__graph__tests__classical_no_memory_pragma.snap => quil_rs__program__scheduling__graph__graphviz_dot_tests__classical_no_memory_pragma.snap} (100%) rename quil-rs/src/program/scheduling/snapshots/{quil_rs__program__scheduling__graph__tests__classical_read_write_load_load.snap => quil_rs__program__scheduling__graph__graphviz_dot_tests__classical_read_write_load_load.snap} (100%) rename quil-rs/src/program/scheduling/snapshots/{quil_rs__program__scheduling__graph__tests__classical_read_write_load_mul.snap => quil_rs__program__scheduling__graph__graphviz_dot_tests__classical_read_write_load_mul.snap} (100%) rename quil-rs/src/program/scheduling/snapshots/{quil_rs__program__scheduling__graph__tests__classical_write_read_add_mul.snap => quil_rs__program__scheduling__graph__graphviz_dot_tests__classical_write_read_add_mul.snap} (100%) rename quil-rs/src/program/scheduling/snapshots/{quil_rs__program__scheduling__graph__tests__classical_write_read_load_load.snap => quil_rs__program__scheduling__graph__graphviz_dot_tests__classical_write_read_load_load.snap} (100%) rename quil-rs/src/program/scheduling/snapshots/{quil_rs__program__scheduling__graph__tests__classical_write_read_mul_load.snap => quil_rs__program__scheduling__graph__graphviz_dot_tests__classical_write_read_mul_load.snap} (100%) rename quil-rs/src/program/scheduling/snapshots/{quil_rs__program__scheduling__graph__tests__custom_handler__mixed_pragmas_and_pulses.snap => quil_rs__program__scheduling__graph__graphviz_dot_tests__custom_handler__mixed_pragmas_and_pulses.snap} (100%) rename quil-rs/src/program/scheduling/snapshots/{quil_rs__program__scheduling__graph__tests__custom_handler__only_pragmas_with_frames.snap => quil_rs__program__scheduling__graph__graphviz_dot_tests__custom_handler__only_pragmas_with_frames.snap} (100%) rename quil-rs/src/program/scheduling/snapshots/{quil_rs__program__scheduling__graph__tests__custom_handler__only_pragmas_without_frames.snap => quil_rs__program__scheduling__graph__graphviz_dot_tests__custom_handler__only_pragmas_without_frames.snap} (100%) rename quil-rs/src/program/scheduling/snapshots/{quil_rs__program__scheduling__graph__tests__quantum_write_parameterized_operations.snap => quil_rs__program__scheduling__graph__graphviz_dot_tests__quantum_write_parameterized_operations.snap} (100%) rename quil-rs/src/program/scheduling/snapshots/{quil_rs__program__scheduling__graph__tests__write_capture_read.snap => quil_rs__program__scheduling__graph__graphviz_dot_tests__write_capture_read.snap} (100%) rename quil-rs/src/program/scheduling/snapshots/{quil_rs__program__scheduling__graph__tests__write_write_read.snap => quil_rs__program__scheduling__graph__graphviz_dot_tests__write_write_read.snap} (100%) diff --git a/quil-rs/src/program/scheduling/graph.rs b/quil-rs/src/program/scheduling/graph.rs index 878524a2..ead1b4fd 100644 --- a/quil-rs/src/program/scheduling/graph.rs +++ b/quil-rs/src/program/scheduling/graph.rs @@ -547,13 +547,12 @@ impl<'a> From> 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::*; @@ -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#" @@ -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#" @@ -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#" @@ -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#" @@ -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#" @@ -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#" @@ -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#" @@ -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#" diff --git a/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__classical_no_memory_pragma.snap b/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__classical_no_memory_pragma.snap similarity index 100% rename from quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__classical_no_memory_pragma.snap rename to quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__classical_no_memory_pragma.snap diff --git a/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__classical_read_write_load_load.snap b/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__classical_read_write_load_load.snap similarity index 100% rename from quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__classical_read_write_load_load.snap rename to quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__classical_read_write_load_load.snap diff --git a/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__classical_read_write_load_mul.snap b/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__classical_read_write_load_mul.snap similarity index 100% rename from quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__classical_read_write_load_mul.snap rename to quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__classical_read_write_load_mul.snap diff --git a/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__classical_write_read_add_mul.snap b/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__classical_write_read_add_mul.snap similarity index 100% rename from quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__classical_write_read_add_mul.snap rename to quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__classical_write_read_add_mul.snap diff --git a/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__classical_write_read_load_load.snap b/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__classical_write_read_load_load.snap similarity index 100% rename from quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__classical_write_read_load_load.snap rename to quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__classical_write_read_load_load.snap diff --git a/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__classical_write_read_mul_load.snap b/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__classical_write_read_mul_load.snap similarity index 100% rename from quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__classical_write_read_mul_load.snap rename to quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__classical_write_read_mul_load.snap diff --git a/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__custom_handler__mixed_pragmas_and_pulses.snap b/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__custom_handler__mixed_pragmas_and_pulses.snap similarity index 100% rename from quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__custom_handler__mixed_pragmas_and_pulses.snap rename to quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__custom_handler__mixed_pragmas_and_pulses.snap diff --git a/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__custom_handler__only_pragmas_with_frames.snap b/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__custom_handler__only_pragmas_with_frames.snap similarity index 100% rename from quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__custom_handler__only_pragmas_with_frames.snap rename to quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__custom_handler__only_pragmas_with_frames.snap diff --git a/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__custom_handler__only_pragmas_without_frames.snap b/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__custom_handler__only_pragmas_without_frames.snap similarity index 100% rename from quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__custom_handler__only_pragmas_without_frames.snap rename to quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__custom_handler__only_pragmas_without_frames.snap diff --git a/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__quantum_write_parameterized_operations.snap b/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__quantum_write_parameterized_operations.snap similarity index 100% rename from quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__quantum_write_parameterized_operations.snap rename to quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__quantum_write_parameterized_operations.snap diff --git a/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__write_capture_read.snap b/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__write_capture_read.snap similarity index 100% rename from quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__write_capture_read.snap rename to quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__write_capture_read.snap diff --git a/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__write_write_read.snap b/quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__write_write_read.snap similarity index 100% rename from quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__tests__write_write_read.snap rename to quil-rs/src/program/scheduling/snapshots/quil_rs__program__scheduling__graph__graphviz_dot_tests__write_write_read.snap