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

Tests do not finish if an agent has been started. #43

Open
farbeiza opened this issue Oct 25, 2022 · 5 comments
Open

Tests do not finish if an agent has been started. #43

farbeiza opened this issue Oct 25, 2022 · 5 comments

Comments

@farbeiza
Copy link

If an agent is started, tests do not finish, waiting for the agent threads to finish:

These files should reproduce the issue:
deps.edn:

{:paths ["src"]
 :deps {}
 :aliases {:test {:extra-paths ["test"]
                  :extra-deps {io.github.cognitect-labs/test-runner {:git/sha "a522ab2851a2aa5bf9c22a942b45287a3a019310"}}
                  :main-opts ["-m" "cognitect.test-runner"]
                  :exec-fn cognitect.test-runner.api/test}}}

core_test.clj:

(ns core-test
  (:require [clojure.test :refer :all]))

(deftest duration-test
  (let [a (agent 0)]
    (send a inc)
    (await a)
    (is (= 1 @a))))

I've seen a PR which could be very useful for this: Add before and after options
since it will allow to run (shutdown-agents) after running the tests.

@puredanger
Copy link
Contributor

We used to have such logic (see 23771f4) but that was removed in favor of having the execution context handle it.

How are you running test-runner?

@puredanger
Copy link
Contributor

And if you are running with the Clojure CLI, which version (exit behavior has changed there several times)?

@farbeiza
Copy link
Author

I'm running it with clj -X

$ clj -X:test

Running tests in #{"test"}

Testing core-test

Ran 1 tests containing 1 assertions.
0 failures, 0 errors.

Version is:

$ clj -version
Clojure CLI version 1.11.1.1165

respatialized added a commit to respatialized/respatialized that referenced this issue Jan 2, 2023
@seancorfield
Copy link
Contributor

I think it's okay for -M contexts to call shutdown-agents at the end but it is not okay for -X contexts to do this since it undermines programmatic invocation of the test runner.

@raystubbs
Copy link

raystubbs commented Aug 25, 2024

Seems like this happens if a Timer, or any other user thread remains alive too... seems like it'd be good to have something (on an opt-in basis) that just calls System/exit after all the test runner stuff finishes.

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

No branches or pull requests

4 participants