Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
34 changes: 34 additions & 0 deletions PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,40 @@ cmake --build build --target gen_transform_oracle
ast_tester/fixtures/oracle/framesets.oracle
```

## STC-S corpus

`fixtures/stcs/` holds STC-S documents, one row each in `corpus.txt`, with
the files that say what reading and writing each one gives; its `README.md`
gives the layout. The tree is shared, byte for byte, with the Rust port of
AST, whose StcsChan is held to the same files.

- `check_stcs_corpus <fixtures-dir> <name>` checks one document: the error
and message in its `.error` file, or the Native dumps of the object and
the properties KeyMap read (`.native`, `.props.native`), the warnings
(`.warnings`), the STC-S written at Indent 0 and StcsLength 70, Indent 1
and StcsLength 20 and, for an `indent` row, Indent 1 and StcsLength 70
(`.out`, `.out-20`, `.out-indent`) with the warnings of those writes
(`.write-warnings`), and that each written text reads back to an object
written as the `.out` text. The comparison is byte for byte on
Linux x86_64, where the files were captured, and by the rule of
`compare_dumps.c`, which it includes, elsewhere.
- One ctest per row, `stcs_corpus_<name>`, registered from `corpus.txt` at
configure time. Two documents are listed in the program with the reason:
`timeinterval-allsky` writes nothing, and the `.out` text of `position`
is rejected by the reader; each is checked for still doing so.
- The corpus found the crash fixed in `stcschan.c` for a time sub-phrase
starting with `Time` (`time-identifier`).
Documents that still crash the reader (a redshift sub-phrase ending at
`unit` or at its type, and the `SPHER3` and `UNITSPHER` flavours) are
not in the corpus; the Rust port records them.

The defects the port found in the C library while porting StcsChan, each with a reproducer, are in `docs/issues/2026-12-02-stcschan-c-defects.md`.
It is a verbatim copy of the port's report, so it keeps the port's American spelling and its references to the port's tree.
- `teststcschan_c` compares the PROPS KeyMap of its third document with
`programs/teststcschan/stcschan-test1-doc3-props.ast` as dump text, as
astEqual compares only the class of two KeyMaps; the fixture was
regenerated from what astRead returns.

## Verification

```
Expand Down
43 changes: 43 additions & 0 deletions ast_tester/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,49 @@ ast_add_test(testpointset_c SOURCES testpointset.c)
ast_add_test(testxmlchan_c SOURCES testxmlchan.c)
ast_add_test(testtable_c SOURCES testtable.c)
ast_add_test(teststcschan_c SOURCES teststcschan.c)

# The STC-S corpus: one test per document of fixtures/stcs/corpus.txt, each
# checking that the library reads and writes the document as its expectation
# files say (fixtures/stcs/README.md). The Rust port of AST is held to the
# same files. corpus.txt is read at configure time, so a change to it
# reconfigures. Its comments are removed before the text is split into
# lines, as they contain semicolons, which would split a CMake list.
add_executable(check_stcs_corpus check_stcs_corpus.c)
target_include_directories(check_stcs_corpus PRIVATE ${TEST_INCLUDES})
target_link_libraries(check_stcs_corpus PRIVATE ${TEST_LIBS})
target_compile_definitions(check_stcs_corpus PRIVATE HAVE_CONFIG_H)
set_target_properties(check_stcs_corpus PROPERTIES C_STANDARD 11)
ast_apply_dev_options(check_stcs_corpus)
add_dependencies(check_stcs_corpus ast_stage_fixtures)
ast_fixture_status("stcs" "stcs/corpus.txt" _stcs_ok)
if(_stcs_ok)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
"${AST_FIXTURE_SOURCE_ROOT}/stcs/corpus.txt")
file(READ "${AST_FIXTURE_SOURCE_ROOT}/stcs/corpus.txt" _stcs_text)
string(REGEX REPLACE "#[^\n]*" "" _stcs_text "${_stcs_text}")
string(REPLACE "\n" ";" _stcs_rows "${_stcs_text}")
foreach(_row IN LISTS _stcs_rows)
string(STRIP "${_row}" _row)
if(_row STREQUAL "")
continue()
endif()
string(REGEX MATCH "^[^ \t]+" _stcs_name "${_row}")
# Called for its check alone: a row whose document is missing stops
# the configuration, as the corpus is distributed whole, so the
# status it returns is not needed.
ast_fixture_status("stcs/corpus.txt" "stcs/${_stcs_name}.stcs" _doc_ok)
add_test(NAME stcs_corpus_${_stcs_name}
COMMAND check_stcs_corpus "${AST_FIXTURE_BINARY_ROOT}"
"${_stcs_name}"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
if(AST_ENABLE_SANITIZERS)
set_tests_properties(stcs_corpus_${_stcs_name} PROPERTIES
ENVIRONMENT "ASAN_OPTIONS=detect_leaks=0")
endif()
endforeach()
else()
ast_add_skipped_test(stcs_corpus)
endif()
ast_add_test(testregions_c SOURCES testregions.c)

ast_add_test(testwcsmap_c SOURCES testwcsmap.c)
Expand Down
Loading
Loading