Repository navigation
Tests that survive expected SPINE changes, and the CAFMaker contracts - #4
Merged
Merged
Conversation
A SPINE tag that only relabels the version, adds fields or enum members, or removes a field no CAFMaker reads now passes every test once its fixtures are written. A change to what the CAFMakers rely on fails a new ctest entry of its own, spine_reader_contracts. - tests/test_contracts.cpp (new): one row per model field a CAFMaker reads (228: class, field, unit, default as JSON, readers), from the scan of the ND, SBN and FD ports and SPINE 1.4.0's schema. For each class it walks golden_members.inc and compares the unit and the member of a default object; a row whose field or class the model no longer has fails. It also checks every member of ParticleShape, ParticlePID and NuCurrentType by name. ctest runs the "contract*" cases as spine_reader_contracts, and spine_reader_tests excludes them. - tests/test_golden.cpp: column_problems() compares the model with the columns of each current fixture except current_v2_fixed_only: full files have every field, lite files every field but the lite_skip ones (both ways), no column is outside the model, element kinds agree. Width differences are printed only. Its own test case doctors a copy of current_v1's reco_particles, with the column picked at run time. - tests/member_compare.hpp (new): equal_member() from the golden test, plus nan_equal(), member_json() and all_nan(). - tests/test_model.cpp: no field counts, LAST_FIELD table, class list, literal schema version, defaults, units, flags, references, enum member counts or enum values. The structure check runs for every class, and the field-name check for every field (through golden_members.inc). The assign test compares with default objects. The scheme-table check only requires each scheme to select a generated table or none. The doc check is dropped: SPINE may add a field without a docstring. - tests/test_reader.cpp, check_spine_dump.cmake, test_core_real.cpp: the completeness checks on frozen and real files, the summary line, the enum numbers in the mismatch text and the field count come from the model. - tools/release/scan_consumer_fields.py (new): lists the model fields one CAFMaker build reads, by compiling its sources with -fsyntax-only against headers whose members and Field enumerators are marked [[deprecated]] (make -n -B or compile_commands.json; --setup and --wrap for the SL7 container). --contracts lists the fields read that have no row. - Docs: tools/release/EGM.md (new); the model EGM files lose the version and field counts; README, root and tools EGM, tools/gen/README.md describe the new entry and when a contract row changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fourth step of following SPINE releases. The test suite no longer fails on SPINE changes that need no work in the reader. A change to what the CAFMakers rely on fails a ctest entry of its own, so that a later step can tell the two apart.
What changes
spine_reader_contracts(new ctest entry,tests/test_contracts.cpp): what the CAFMakers rely on.golden_members.incand compares each listed member's unit, and the member of a default object, with its row.ParticleShape,ParticlePIDandNuCurrentTypeis checked by name. ND comparesshapeandcurrent_typewith named members; SBN stores the numbers ofshape,pid,chi2_pidandcurrent_type. Members SPINE adds are not a change.spine_reader_testsnow excludescontract*.ci/sl7-ups.shstill runs the whole binary.The golden test checks the model against the current fixtures' columns.
column_problems()runs on everycurrent_*case exceptcurrent_v2_fixed_only, whose columns are a subset by design:lite_skipones, and none for those (both ways);RecoParticle.momentum,TruthParticle.ke,.massand.reco_momentum, as documented intools/fixtures/README.md.FlashHypothesisis printed as "not checked against a file".current_v1'sreco_particles. The column is picked at run time, not by name.Change detectors removed from
test_model.cpp:LAST_FIELDtable and the class list;schema_version == "1.4.0";What remains holds for any tag:
golden_members.inc;NULL_rename.Also dropped:
interaction_schemeor calls the table functions (SBN storesinteraction_modeandinteraction_typeas numbers).Other tests no longer depend on a literal model:
test_reader.cpp:Metachecksmismatched,extraand its four fields instead ofcomplete();run_infocase openscurrent_v1_lite;kNumFields;RecoParticle{}.check_spine_dump.cmakechecks only themeta [Meta]:prefix.test_core_real.cpprequires no missing field only for real files written by the model's SPINE version. The design did not list this check, but it failed the same way.tests/member_compare.hpp(new) holds the helpers the tests share:equal_member(), moved from the golden test;nan_equal(), which compares with NaN equal to NaN;member_json(), used in messages;all_nan().tools/release/scan_consumer_fields.py(new, Python 3.9+, standard library only) lists the model fields one CAFMaker build reads.-fsyntax-onlyagainst a copy ofinclude/whose members andFieldenumerators are marked[[deprecated("SPINEFIELD Class.field")]]. Each deprecation in the CAFMaker's own tree is one read.--buildtakes a Makefile build, read withmake -n -B;--compile-commandstakes acompile_commands.json.--setupand--wraprun the compiles in the CAFMaker's environment, for example the SL7 container.-Wno-errorand the other flags go last, after the CAFMaker's own-Werror; the output and dependency flags are removed, so nothing is written to the build.--contracts tests/test_contracts.cpplists the fields read that have no row (exit 1).tools/release/EGM.md.Docs.
EGM.mdfiles no longer give the version or field counts.EGM.mdandtools/EGM.mdlist the new entry andtools/release/, with the rule that a row is added when a CAFMaker starts reading a field.tools/gen/README.mdstep 4 says what to do whenspine_reader_contractsfails.Checked
Expected changes. Each case below is a copy of this branch with one change, a regenerated model and member list, and a full build and ctest. The last two use local SPINE tags in a scratch clone, and their current fixtures were rewritten with
make_fixtures.py --tag.spine_reader_testsspine_reader_contractsmainRecoParticle.csda_kedefaultnan→0.0MeV→GeVParticlePID.MUON2 → 7csda_keremoved, fixtures not rewrittenRecoParticle.test_scorecrt_scores(read by no CAFMaker)The other entries (
generated_model,golden_members,spine_dump_output) pass in every case.The scanner, on the three ports in the SL7 container: ND 47 fields, SBN 219, FD 31.
fbda59e, the commit of that scan.--contractslists it and exits 1. Acompile_commands.jsoninput gives the same 47 fields.Builds:
ctestunder LCG_110: 6 entries, 5 run and pass;spine_reader_real_filesis skipped without files.SPINE_READER_REAL_FILESset to a real PDSP file, all 6 pass.-Wall -Wextra -Wpedantic: no warnings.ci/sl7-ups.sh(gcc 12, C++17): 132 test cases pass.ci/sanitize.sh(ASan and UBSan): all entries pass.Lint:
flake8 --max-line-length=100onscan_consumer_fields.pygives no warnings.