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

Comptime blocks in stdlib tests are run on each compilation despite being unused #5806

Open
TomAFrench opened this issue Aug 23, 2024 · 0 comments

Comments

@TomAFrench
Copy link
Member

I noticed that given that these are comptime tests, this comptime code runs whenever you compile any program... which is fine, but I guess if we start adding more and more comptime checks to the std it will make things slow (or at least slower).

Do you think it's worth moving these tests back to a test program? Also in a test program I can use println to debug things.

@asterite noted in #5730 that placing comptime blocks in the stdlib for testing results in us having to interpret these comptime blocks on every compilation. Considering these are test functions this is completely wasted effort as they should be ignored if we're not actively running tests on the stdlib. This will affect any library which uses comptime blocks in tests.

One solution to this would be to have some kind of #[cfg(test)] block similar to rust which would allow us to ignore the tests entirely when not actively running them.

Performing analysis on which comptime blocks are reachable and only interpreting those doesn't seem easily doable as we could use multiple comptime blocks to stitch together another call to a comptime function so it doesn't seem like an option in the short term.

@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Aug 23, 2024
@TomAFrench TomAFrench changed the title Comptime blocks in Comptime blocks in stdlib tests are run on each compilation despite being unused Aug 23, 2024
github-merge-queue bot pushed a commit that referenced this issue Aug 26, 2024
# Description

## Problem

Part of #5668

## Summary

Also moves the tests to a test program to avoid evaluating that
`comptime` code on each compilation (see #5806)

## Additional Context

The rest of the comptime methods involve `Path` or `Pattern` and I'd
like to handle those (or one of those) in a separate PR.

## Documentation

Check one:
- [ ] No documentation needed.
- [x] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant