Detect duplicate order numbers in queries.ml at test time#2033
Conversation
…te into semgrep CI Agent-Logs-Url: https://github.com/goblint/analyzer/sessions/28da8933-851d-467f-9742-b3a768ef73be Co-authored-by: michael-schwarz <13812333+michael-schwarz@users.noreply.github.com>
queries.ml at CI time
michael-schwarz
left a comment
There was a problem hiding this comment.
Run as part of normal make test dune test workflow instead of as part of semgrep.
Agent-Logs-Url: https://github.com/goblint/analyzer/sessions/4df863a4-681c-4d41-a545-b61b2aea5d4d Co-authored-by: michael-schwarz <13812333+michael-schwarz@users.noreply.github.com>
Done in 011aab6. Moved the check to the root |
queries.ml at CI timequeries.ml at test time
There was a problem hiding this comment.
Pull request overview
Adds a test-time safeguard to prevent runtime segfaults caused by duplicate numeric tags in Queries.Any.order (a type-unsafe query dispatch mechanism), by checking src/domains/queries.ml during dune runtest / make test.
Changes:
- Introduces
scripts/check-queries-order.pyto parseQueries.Any.orderand fail if duplicate-> <int>values are found. - Hooks the check into the root
duneruntestalias so it runs on normal test executions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| scripts/check-queries-order.py | New Python script that extracts order numbers from queries.ml and fails on duplicates. |
| dune | Adds a runtest-alias rule to execute the script as part of dune runtest. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| seen: set[int] = set() | ||
| duplicates: set[int] = set() | ||
| for num_str in numbers: |
| # Find the order function body. | ||
| # The function starts with "let order = function" and ends at the next | ||
| # top-level "let" binding at the same indentation level inside the module, | ||
| # or at the end of the file if no subsequent binding exists. | ||
| order_match = re.search( | ||
| r"let order = function\n(.*?)(?=\n\s{2,}let\b|\Z)", | ||
| content, | ||
| re.DOTALL, |
Reusing a number in
Queries.Any.ordercauses a silent compile but segfaults at runtime due to type-unsafe query dispatch. This adds a check that catches the mistake before merge.Changes
scripts/check-queries-order.py— parsessrc/domains/queries.ml, extracts all integer return values from theordermatch arms, and exits non-zero on any duplicate:dune(root) — adds a(rule (alias runtest) ...)that runs the script as part ofdune runtest/make test, so it is checked on every normal test run.