Add support for multi-file tests#69
Closed
lucic71 wants to merge 5 commits into
Closed
Conversation
Drop _ from RE_ global variables Add compare step that compares cpp_result and rust_result Use Path instead of str for TestContext fields where it makes sense Simplify preconditions for each TestContext pass
Contributor
Author
|
Besides the I didn't add ruff inside the CMakeLists format rule because this file is expected to be modified very few times. |
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.
This PR adds support for writing multi translation-unit tests in the below format. All multi translation-unit tests go into
tests/multi-file, one test per directory.test.expectationsis an optional file that contains one of the following test expectations: no-compile, translation-fail, panic, nondet-result; or it can be empty if the test is successful:I took this opportunity to refactor the logic inside
Cpp2RustTest.pybecause themulti-fileaddition did not fit well into the current model. NowCpp2RustTest.pyis composed of:TestExpectations: dataclass describing the expected output of the test:should_panic, should_not_compile, should_not_translate, is_nondet_result, xfail. For classic tests (ub, benchmarks, unit-tests), TestExpectations is populated from the comment line inside the source file, for multi-file tests, TestExpectations is populated fromtest.expectatoinsTestContext: dataclass that defines all test steps (setup, translate, check_expected, build_cpp, build_rust, run_cpp, run_rust, compare) and keeps test specific data as member variables, includingTestExpectationsCpp2RustTest: entry point of lit, containsexecute(which calls directly intoTestContext)getTestsForPathandgetTestsInDirectory