Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File tests should allow pointing to a minimal prelude file #5076

Closed
danakj opened this issue Mar 5, 2025 · 0 comments · Fixed by #5080
Closed

File tests should allow pointing to a minimal prelude file #5076

danakj opened this issue Mar 5, 2025 · 0 comments · Fixed by #5080
Assignees

Comments

@danakj
Copy link
Contributor

danakj commented Mar 5, 2025

Description of the bug:

Instead of copy-pasting little bits of the Core package into individual test files, we would like no_prelude tests to be able to opt into specifying a specific minimal prelude file. Then we can still have a minimal set of things getting run through check/ during a test, which is useful for interactive debugging, but we have to maintain a smaller set of minimal preludes instead of it being in so many test files.

This was discussed in toolchain meeting on March 4, 2025: https://docs.google.com/document/d/1Iut5f2TQBrtBNIduF4vJYOKfw7MbS8xH_J01_Q4e6Rk/edit?resourcekey=0-mc_vh5UzrzXfU4kO-3tOjA&tab=t.0#heading=h.7bhlbi66d40s

@danakj danakj self-assigned this Mar 5, 2025
github-merge-queue bot pushed a commit that referenced this issue Mar 10, 2025
…imal prelude library (#5080)

The INCLUDE-FILE option is only used in the toolchain tests for now. If
specified in a file test, the given file path is added to the test's
arguments. For toolchain tests this makes the file's package available
to the test. The `--custom-core` command line flag is added to the
driver, which avoids adding the production `Core` package to the command
line. Together, these allow a test to provide their own minimal `Core`
package.

For example, this would replace `Core` with the package and prelude in
`facet_types.carbon`.
```
// INCLUDE-FILE: toolchain/testing/min_prelude/facet_types.carbon
// EXTRA-ARGS: --custom-core
```

To support this:
* //testing knows how to parse INCLUDE-FILE out of the header of a test
file.
* //testing adds the file to the virtual file system, and includes it in
the test's arguments.
* //toolchain/driver grows the --custom-core command line flag to avoid
loading the production `Core` package.

Tests that were creating their own minimal prelude to define BitAnd on
types are now pointed to
toolchain/testing/min_prelude/facet_types.carbon as the prelude. They no
longer need to `import Core` in each test as a result.

Such tests are no longer `no_prelude`, but instead have their own
prelude. So they are moved to a `min_prelude` subdirectory.

Closes #5076
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant