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

Add a flake check for testing the stdlib #2061

Merged
merged 4 commits into from
Oct 8, 2024
Merged

Add a flake check for testing the stdlib #2061

merged 4 commits into from
Oct 8, 2024

Conversation

jneem
Copy link
Member

@jneem jneem commented Oct 8, 2024

An amusing little thing that I think is harmless: when a test in the stdlib uses the std name (like std.contract.not) then it's testing the copy of the stdlib that was compiled into the nickel binary. But when it uses a "local" name (like HasField) then it's testing the copy of the stdlib that it gets from the path ./core/stdlib/std.ncl.

@github-actions github-actions bot temporarily deployed to pull request October 8, 2024 04:22 Inactive
Copy link
Contributor

github-actions bot commented Oct 8, 2024

🐰 Bencher Report

Branch2061/merge
Testbedubuntu-latest

⚠️ WARNING: The following Measure does not have a Threshold. Without a Threshold, no Alerts will ever be generated!

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds CLI flag.

Click to view all benchmark results
BenchmarkLatencynanoseconds (ns)
fibonacci 10📈 view plot
⚠️ NO THRESHOLD
497,790.00
pidigits 100📈 view plot
⚠️ NO THRESHOLD
3,241,700.00
product 30📈 view plot
⚠️ NO THRESHOLD
842,070.00
scalar 10📈 view plot
⚠️ NO THRESHOLD
1,531,500.00
sum 30📈 view plot
⚠️ NO THRESHOLD
839,480.00
🐰 View full continuous benchmarking report in Bencher

@yannham
Copy link
Member

yannham commented Oct 8, 2024

An amusing little thing that I think is harmless: when a test in the stdlib uses the std name (like std.contract.not) then it's testing the copy of the stdlib that was compiled into the nickel binary. But when it uses a "local" name (like HasField) then it's testing the copy of the stdlib that it gets from the path ./core/stdlib/std.ncl.

Yeah, it's the same for the actual stdlib code - often functions refer to other function of the same module directly, but use std to access outer module (in some places this was required because of the typechecking not being the same - I don't know if it's the case anymore with the polymorphism rework but it might be).

Copy link
Member

@yannham yannham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad to see this moving forward!

flake.nix Outdated

stdlibTests = pkgs.runCommandLocal "stdlib-test" { }
''
${pkgs.lib.getExe self.packages."${system}".default} test ${./core/stdlib/std.ncl};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the ; at the end going to make the command pass whatever is the actual result? Maybe a sanity check would be to push a commit with a deliberate error in the stdlib somewhere, just to be sure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know exactly why (maybe runCommandLocal does a set -xeu or something?) but it seems to fail if I make it fail.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But why do you need the ; ? Can't we use a &&? Do we also have to necessarily create $out ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I can use && instead; the behavior seems to be the same.

Yes, without making $out then nix flake check fails with

error: builder for '/nix/store/kyr0xs7ncr05i3frnphvvvr1q8p8ja1c-stdlib-test.drv' failed to produce output path for output 'out' at '/nix/store/kyr0xs7ncr05i3frnphvvvr1q8p8ja1c-stdlib-test.drv.chroot/root/nix/store/yil1zc0j0vy5p3sjsp0c1kqi8r0h6krj-stdlib-test'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good! I think && is indeed better as it doesn't rely on assumptions about how runCommandLocal works internally 👍

@github-actions github-actions bot temporarily deployed to pull request October 8, 2024 08:02 Inactive
This reverts commit 07c34e5.
@github-actions github-actions bot temporarily deployed to pull request October 8, 2024 08:42 Inactive
@github-actions github-actions bot temporarily deployed to pull request October 8, 2024 11:49 Inactive
@yannham yannham added this pull request to the merge queue Oct 8, 2024
Merged via the queue into master with commit 5fd6a14 Oct 8, 2024
7 checks passed
@yannham yannham deleted the test-stdlib branch October 8, 2024 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants