Skip to content

Commit f4b9966

Browse files
committed
cost_analysis: split ctests into generate/verify fixtures
Replace the run_tests.cmake -P wrapper with a generate, sed (strip volatile line), diff multistep process.
1 parent a8d0de3 commit f4b9966

4 files changed

Lines changed: 31 additions & 68 deletions

File tree

utilities/cost_analysis/CMakeLists.txt

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,27 @@ target_link_libraries(cost_analysis PRIVATE
99
SeQuant::mbpt nlohmann_json::nlohmann_json CLI11::CLI11)
1010
target_set_warning_flags(cost_analysis)
1111

12-
add_test(NAME cost_analysis_ccsd_r2
13-
COMMAND ${CMAKE_COMMAND}
14-
-DEXE=$<TARGET_FILE:cost_analysis>
15-
-DSRC=${CMAKE_CURRENT_SOURCE_DIR}/examples
16-
-DNAME=ccsd_r2 -DDUMP=R2
17-
-P ${CMAKE_CURRENT_SOURCE_DIR}/run_tests.cmake)
12+
foreach(NAME IN ITEMS "ccsd_r2" "df_r1")
13+
add_test(
14+
NAME "sequant/cost_analysis/${NAME}/generate"
15+
COMMAND cost_analysis --driver "${CMAKE_CURRENT_LIST_DIR}/examples/${NAME}.json")
16+
set_tests_properties("sequant/cost_analysis/${NAME}/generate"
17+
PROPERTIES FIXTURES_SETUP "COST_ANALYSIS_${NAME}")
1818

19-
add_test(NAME cost_analysis_df_r1
20-
COMMAND ${CMAKE_COMMAND}
21-
-DEXE=$<TARGET_FILE:cost_analysis>
22-
-DSRC=${CMAKE_CURRENT_SOURCE_DIR}/examples
23-
-DNAME=df_r1
24-
-P ${CMAKE_CURRENT_SOURCE_DIR}/run_tests.cmake)
19+
# Strip the volatile git-revision line before diffing; -B ignores the extra
20+
# trailing blank line the live report carries but the fixture doesn't.
21+
add_test(
22+
NAME "sequant/cost_analysis/${NAME}/verify"
23+
COMMAND bash -c "diff -B <(sed '/^_SeQuant:/d' '${NAME}.md') <(sed '/^_SeQuant:/d' '${NAME}.md.expected')"
24+
WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/examples")
25+
set_tests_properties("sequant/cost_analysis/${NAME}/verify"
26+
PROPERTIES FIXTURES_REQUIRED "COST_ANALYSIS_${NAME}")
27+
endforeach()
28+
29+
# ccsd_r2 exercises --dump_tree; check the tree file was produced.
30+
add_test(
31+
NAME "sequant/cost_analysis/ccsd_r2/dump_tree"
32+
COMMAND bash -c "test -f R2.tree.txt"
33+
WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/examples")
34+
set_tests_properties("sequant/cost_analysis/ccsd_r2/dump_tree"
35+
PROPERTIES FIXTURES_REQUIRED "COST_ANALYSIS_ccsd_r2")

utilities/cost_analysis/README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,11 @@ The quantities that aren't self-evident:
107107

108108
## Tests
109109

110-
Two reference tests (`ctest -R cost_analysis_`) run the tool on `examples/` and
111-
diff the report against a frozen `*.md.expected`:
112-
113-
- `cost_analysis_ccsd_r2` — spin-orbital CCSD R2 (a `Sum` of terms) whose two
114-
ladder terms share one `g*t` intermediate, exercising the reuse census.
115-
- `cost_analysis_df_r1` — a single density-fitted product (the non-`Sum` path).
110+
Reference tests (`ctest -R sequant/cost_analysis`) run the tool on `examples/`
111+
and diff the report against a frozen `*.md.expected` (the volatile git-revision
112+
line is stripped before diffing):
113+
114+
- `.../ccsd_r2/*` — spin-orbital CCSD R2 (a `Sum` of terms) whose two ladder
115+
terms share one `g*t` intermediate, exercising the reuse census; also checks
116+
the `--dump_tree` output was produced.
117+
- `.../df_r1/*` — a single density-fitted product (the non-`Sum` path).

utilities/cost_analysis/examples/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
# in this directory; the frozen reference reports are the *.md.expected files.
33
*.md
44
!*.md.expected
5-
*.filtered
65
*.tree.txt

utilities/cost_analysis/run_tests.cmake

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)