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

throw a little error when there are failures #26

Merged
merged 1 commit into from
Oct 10, 2023

Conversation

amtoine
Copy link
Member

@amtoine amtoine commented Oct 10, 2023

related to

Description

after amtoine/nu-git-manager#26, i would like to add nupm test to the CI 👌

however, currently, nupm test does not return a true error when the tests fail and thus won't crash a CI 🤔

this PR throws a real error the number of $failures is non-zero 👍

example

let's introduce an obvious error in the tests of nupm itself

diff --git a/tests/mod.nu b/tests/mod.nu
index b20e9bc..7d0fbac 100644
--- a/tests/mod.nu
+++ b/tests/mod.nu
@@ -22,6 +22,8 @@ export def install-script [] {
             | path join
             | path exists)
     }
+
+    assert false
 }
 
 export def install-module [] {

running nupm test; print "all tests passed" should not print the string

  • before the changes: it did
Testing package /home/amtoine/documents/repos/github.com/amtoine/nupm
tests install-module ... SUCCESS
tests install-script ... FAILURE
tests install-custom ... SUCCESS

Test "tests install-script" failed with exit code 1:
2023-10-10T19:10:54.072|INF|installing package spam_script
Error:   × Assertion failed.
    ╭─[/home/amtoine/documents/repos/github.com/amtoine/nupm/tests/mod.nu:25:1]
 25 │
 26 │     assert false
    ·            ──┬──
    ·              ╰── It is not true.
 27 │ }
    ╰────

Ran 3 tests. 2 succeeded, 1 failed.
all test passed
  • after the changes: it does not anymore
Testing package /home/amtoine/documents/repos/github.com/amtoine/nupm
tests install-module ... SUCCESS
tests install-script ... FAILURE
tests install-custom ... SUCCESS

Test "tests install-script" failed with exit code 1:
2023-10-10T19:10:59.395|INF|installing package spam_script
Error:   × Assertion failed.
    ╭─[/home/amtoine/documents/repos/github.com/amtoine/nupm/tests/mod.nu:25:1]
 25 │
 26 │     assert false
    ·            ──┬──
    ·              ╰── It is not true.
 27 │ }
    ╰────

Ran 3 tests. 2 succeeded, 1 failed.
Error:   × some tests failed

@amtoine amtoine requested a review from kubouch October 10, 2023 17:11
@amtoine amtoine added the enhancement New feature or request label Oct 10, 2023
@kubouch
Copy link
Contributor

kubouch commented Oct 10, 2023

Thanks, seems like a nice QoL touch, we should be returning an error. We might need to redesign the reporting a bit in the future.

@kubouch kubouch merged commit 38f80e7 into nushell:main Oct 10, 2023
@amtoine amtoine deleted the give-error-with-failing-tests branch October 10, 2023 17:20
@amtoine
Copy link
Member Author

amtoine commented Oct 10, 2023

We might need to redesign the reporting a bit in the future.

yup agree there is room for improvement 👍

Thanks, seems like a nice QoL touch, we should be returning an error.

at least for now it will not run past a failing nupm test 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants