*ns* is never bound to the test namespace - #133
Open
danielsz wants to merge 1 commit into
Open
Conversation
The test runner script is src/main/resources/default_test_script.clj. It runs in the com.theoryinpractise.clojure.testrunner namespace and calls (require ns) followed by (run-tests ns) for each discovered test namespace. The bug: *ns* is never bound to the test namespace before run-tests is called. While deftest functions carry their own namespace at definition time (so symbol resolution within test bodies generally works), *ns* remains set to com.theoryinpractise.clojure.testrunner throughout. This breaks: 1. Tests that read *ns* directly (e.g., (is (= 'my.ns (ns-name *ns*)))) 2. Tests using resolve, intern, find-var with unqualified symbols 3. Tests that eval, load-string, or read-string code 4. test-ns-hook functions that depend on *ns* being correct Single file to change: src/main/resources/default_test_script.clj Wrap all three (run-tests ns) calls with (binding [*ns* (the-ns ns)] ...) This is a small, targeted fix that's consistent with how other Clojure test tools handle namespace context. The fix ensures that *ns* is bound to the correct test namespace when run-tests executes, so tests that use resolve, intern, *ns* directly, or other namespace-sensitive operations get the correct namespace context instead of com.theoryinpractise.clojure.testrunner.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The test runner script is src/main/resources/default_test_script.clj. It runs in the com.theoryinpractise.clojure.testrunner namespace and calls (require ns) followed by (run-tests ns) for each discovered test namespace.
The bug: ns is never bound to the test namespace before run-tests is called. While deftest functions carry their own namespace at definition time (so symbol resolution within test bodies generally works), ns remains set to com.theoryinpractise.clojure.testrunner throughout. This breaks:
Single file to change: src/main/resources/default_test_script.clj Wrap all three (run-tests ns) calls with (binding [ns (the-ns ns)] ...)
This is a small, targeted fix that's consistent with how other Clojure test tools handle namespace context.
The fix ensures that ns is bound to the correct test namespace when run-tests executes, so tests that use resolve, intern, ns directly, or other namespace-sensitive operations get the correct namespace context instead of com.theoryinpractise.clojure.testrunner.