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

Cleanup temp directory on completion #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Bo98
Copy link

@Bo98 Bo98 commented Dec 17, 2023

The tmp directory is currently fixed to the working directory and is never cleaned up. We can make use of Dir.mktmpdir to have a temporary directory that will clean up itself.

@ilyazub ilyazub self-requested a review January 16, 2024 17:15
Copy link
Collaborator

@ilyazub ilyazub left a comment

Choose a reason for hiding this comment

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

@Bo98 thanks for your work and my apologies for not reviewing your PRs sooner.

Let's make wait_threads available outside of the setup_tmp_dir block or explicitly clean up the folder instead.

TIL Dir.mktmpdir. Thank you for that!


@threads.each(&:join)
@threads.each(&:join)
end

@reporter.failed_examples.empty? && wait_threads.map(&:value).all?(&:success?)
Copy link
Collaborator

Choose a reason for hiding this comment

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

wait_threads are not defined now.

$ bundle exec turbo_tests
Using recorded test runtime
3 processes for 3 specs, ~ 1 specs per process

Randomized with seed 35942

.bundler: failed to load command: turbo_tests (~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/bin/turbo_tests)
~/Workspace/turbo_tests/lib/turbo_tests/runner.rb:110:in `run': undefined local variable or method `wait_threads' for #<TurboTests::Runner:0x00000000015fd588> (NameError)
	from ~/Workspace/turbo_tests/lib/turbo_tests/runner.rb:43:in `run'
	from ~/Workspace/turbo_tests/lib/turbo_tests/cli.rb:101:in `run'
	from ~/Workspace/turbo_tests/bin/turbo_tests:11:in `<top (required)>'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/bin/turbo_tests:23:in `load'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/bin/turbo_tests:23:in `<top (required)>'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/lib/bundler/cli/exec.rb:58:in `load'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/lib/bundler/cli/exec.rb:23:in `run'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/lib/bundler/cli.rb:492:in `exec'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/lib/bundler/cli.rb:34:in `dispatch'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/lib/bundler/cli.rb:28:in `start'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/exe/bundle:37:in `block in <top (required)>'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/exe/bundle:29:in `<top (required)>'
	from ~/.rbenv/versions/2.7.2/bin/bundle:23:in `load'
	from ~/.rbenv/versions/2.7.2/bin/bundle:23:in `<main>'
..bundler: failed to load command: turbo_tests (~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/bin/turbo_tests)
~/Workspace/turbo_tests/lib/turbo_tests/runner.rb:110:in `run': undefined local variable or method `wait_threads' for #<TurboTests::Runner:0x00000000023c1548> (NameError)
	from ~/Workspace/turbo_tests/lib/turbo_tests/runner.rb:43:in `run'
	from ~/Workspace/turbo_tests/lib/turbo_tests/cli.rb:101:in `run'
	from ~/Workspace/turbo_tests/bin/turbo_tests:11:in `<top (required)>'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/bin/turbo_tests:23:in `load'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/bin/turbo_tests:23:in `<top (required)>'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/lib/bundler/cli/exec.rb:58:in `load'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/lib/bundler/cli/exec.rb:23:in `run'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/lib/bundler/cli.rb:492:in `exec'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/lib/bundler/cli.rb:34:in `dispatch'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/lib/bundler/cli.rb:28:in `start'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/exe/bundle:37:in `block in <top (required)>'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
	from ~/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.4.22/exe/bundle:29:in `<top (required)>'
	from ~/.rbenv/versions/2.7.2/bin/bundle:23:in `load'
	from ~/.rbenv/versions/2.7.2/bin/bundle:23:in `<main>'
F..

Failures:

  1) TurboTests::CLI pending exceptions reports
     Failure/Error: expect($?.exitstatus).to eql(0)
     
       expected: 0
            got: 1
     
       (compared using eql?)
     # ./spec/cli_spec.rb:44:in `block (3 levels) in <top (required)>'

Finished in 3.33 seconds (files took 3.12 seconds to load)
6 examples, 1 failure, 1 error occurred outside of examples

Failed examples:

rspec ./spec/cli_spec.rb:43 # TurboTests::CLI pending exceptions reports


Randomized with seed 35942


FileUtils.mkdir_p("tmp/test-pipes/")
def setup_tmp_dir(&block)
Dir.mktmpdir("turbo_tests-pipes", &block)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's follow ParallelTests's convention of using ./tmp folder.

Suggested change
Dir.mktmpdir("turbo_tests-pipes", &block)
Dir.mktmpdir("turbo_tests-pipes", "tmp", &block)
Dir.mktmpdir("turbo_tests-pipes", "tmp") { |tmp| puts tmp }
# tmp/turbo_tests-pipes20240117-61561-5k7jqw
# nil

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.

None yet

2 participants