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

TypeError when "Run Tests for Current Namespace" in non "-test" namespace #1516

Closed
arcesino opened this issue Feb 3, 2022 · 3 comments
Closed
Labels
bug Something isn't working test-runner

Comments

@arcesino
Copy link

arcesino commented Feb 3, 2022

I got error:

TypeError: Cannot read property 'test' of undefined

when trying to "Run Tests for Current Namespace" in a non -test namespaces. This command's official docs state that:

Runs the tests for the current namespace. If not a -test namespace, tests for the current namespace plus its corresponding -test namespace will be run.

so it seems that non -test namespaces are indeed supported so I would expect the command worked instead of giving an error, especially if individual tests can be run using command "Run Current Test".

For instance, in the attached image you can see 2 test files core-test.clj & test-core.clj and the output in REPL for each file when first each test is run individually using "Run Current Test" and then all tests in namespace are run using "Run Tests for Current Namespace". As you can see, everything works fine for core-test namespace but we got the error in this issue when running "Run Tests for Current Namespace" in namespace test-core.

I understand that the convention is to write tests inside -test namespaces but based on the official docs and the fact that the tests in the namespace can be successfully run by evaluating (clojure.test/run-tests 'example.test-core) in the REPL, I do believe this is an issue.

Screen Shot 2022-02-03 at 13 37 50

@aturok
Copy link

aturok commented Feb 4, 2022

Also faced this today.
That worked smoothly before, apparently got broken between v2.0.226 (works) and v2.0.227 (doesn't).
Unfortunately my understanding of the inner workings of calva is not good enough to pinpoint the problem.

@bpringe bpringe added bug Something isn't working test-runner labels Feb 5, 2022
@bpringe bpringe added this to To do in Brandon's Board via automation Feb 5, 2022
@bpringe
Copy link
Member

bpringe commented Feb 5, 2022

These changes related to the test runner were included in 2.0.227: #1405. I'm not sure if something in that PR is causing this but it seems to be the only change in that version directly related to the test runner.

@bpringe
Copy link
Member

bpringe commented Feb 5, 2022

I sort of see what's happening. When the command to run tests for a namespace is executed, if the current namespace does not end in -test it seems another namespace is set to have tests run for it that is the current namespace with -test appended to it.

In the below case, I ran the command in the test-core namespace. So then Calva tries to run tests for test-core and test-core-test. The latter namespace does not exist, but tests are attempted to be run for it and reported. During the reporting is where the error occurs, at this line:

result[k] = result[k] + summary[k];

You can see in the below screenshots that one of the results is an nrepl response with a namespace-not-found status, which I think leads to one of the summaries in totalSummary being undefined.

image

image

@bpringe bpringe closed this as completed in 2d4438c Feb 6, 2022
Brandon's Board automation moved this from To do to Done Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working test-runner
Projects
Development

No branches or pull requests

3 participants