Skip to content

Conversation

@tikkss
Copy link
Contributor

@tikkss tikkss commented Feb 16, 2025

GitHub: GH-288

This patch is the first step. test-unit executable just invokes
require "test/unit"; exit(Test::Unit::AutoRunner.run(true, "test"))
and does not support specifying test targets yet.

GitHub: test-unitGH-288

This patch is the first step. `test-unit` executable just invokes `ruby
-r test-unit -e run_test test` and does not support passing arguments.
bin/test-unit Outdated
Comment on lines 3 to 5
require "bundler/gem_tasks"

ruby("-r test-unit -e run_test test")
Copy link
Member

Choose a reason for hiding this comment

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

We should not create a new process.

We can use require "test-unit"; exit(Test::Unit::AutoRunner.run(true, "test")) instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your suggestion. test execution time became faster!:

  • before: 1.552s
  • after: 1.347s

spec.files += ["COPYING", "BSDL", "PSFL"]
spec.files += Dir.glob("{lib,sample}/**/*.rb")
spec.files += Dir.glob("doc/text/**/*.*")
spec.files += Dir.glob("bin/*")
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to add bin/* to files?
I think that executables are added to files automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removes spec.files += Dir.glob("bin/*") line, then following error ocurred:

$ g df
diff --git a/test-unit.gemspec b/test-unit.gemspec
index 51dc323..be9ac0e 100644
--- a/test-unit.gemspec
+++ b/test-unit.gemspec
@@ -28,7 +28,6 @@ Gem::Specification.new do |spec|
   spec.files += ["COPYING", "BSDL", "PSFL"]
   spec.files += Dir.glob("{lib,sample}/**/*.rb")
   spec.files += Dir.glob("doc/text/**/*.*")
-  spec.files += Dir.glob("bin/*")
   spec.bindir = "bin"
   spec.executables = spec.files.grep(%r{\Abin/}) {|f| File.basename(f)}

$ bundle exec test-unit --exclude=run-test.rb
bundler: failed to load command: test-unit (/Users/zzz/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/bin/test-unit)
/Users/zzz/.rbenv/versions/3.4.1/lib/ruby/site_ruby/3.4.0/bundler/rubygems_integration.rb:241:in 'block in Gem.replace_bin_path': can't find executable test-unit for gem test-unit (Gem::Exception)
        from /Users/zzz/.rbenv/versions/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:281:in 'Gem.activate_bin_path'
        from /Users/zzz/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/bin/test-unit:25:in '<top (required)>'
        from /Users/zzz/.rbenv/versions/3.4.1/lib/ruby/site_ruby/3.4.0/bundler/cli/exec.rb:59:in 'Kernel.load'
        from /Users/zzz/.rbenv/versions/3.4.1/lib/ruby/site_ruby/3.4.0/bundler/cli/exec.rb:59:in 'Bundler::CLI::Exec#kernel_load'
        from /Users/zzz/.rbenv/versions/3.4.1/lib/ruby/site_ruby/3.4.0/bundler/cli/exec.rb:23:in 'Bundler::CLI::Exec#run'
        from /Users/zzz/.rbenv/versions/3.4.1/lib/ruby/site_ruby/3.4.0/bundler/cli.rb:452:in 'Bundler::CLI#exec'
        from /Users/zzz/.rbenv/versions/3.4.1/lib/ruby/site_ruby/3.4.0/bundler/vendor/thor/lib/thor/command.rb:28:in 'Bundler::Thor::Command#run'
        from /Users/zzz/.rbenv/versions/3.4.1/lib/ruby/site_ruby/3.4.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in 'Bundler::Thor::Invocation#invoke_command'
        from /Users/zzz/.rbenv/versions/3.4.1/lib/ruby/site_ruby/3.4.0/bundler/vendor/thor/lib/thor.rb:538:in 'Bundler::Thor.dispatch'
        from /Users/zzz/.rbenv/versions/3.4.1/lib/ruby/site_ruby/3.4.0/bundler/cli.rb:35:in 'Bundler::CLI.dispatch'
        from /Users/zzz/.rbenv/versions/3.4.1/lib/ruby/site_ruby/3.4.0/bundler/vendor/thor/lib/thor/base.rb:584:in 'Bundler::Thor::Base::ClassMethods#start'
        from /Users/zzz/.rbenv/versions/3.4.1/lib/ruby/site_ruby/3.4.0/bundler/cli.rb:29:in 'Bundler::CLI.start'
        from /Users/zzz/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/exe/bundle:28:in 'block in <top (required)>'
        from /Users/zzz/.rbenv/versions/3.4.1/lib/ruby/site_ruby/3.4.0/bundler/friendly_errors.rb:117:in 'Bundler.with_friendly_errors'
        from /Users/zzz/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/exe/bundle:20:in '<top (required)>'
        from /Users/zzz/.rbenv/versions/3.4.1/bin/bundle:25:in 'Kernel#load'
        from /Users/zzz/.rbenv/versions/3.4.1/bin/bundle:25:in '<main>'

Copy link
Member

Choose a reason for hiding this comment

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

Could you also update spec.executables = spec.files.grep(%r{\Abin/}) {|f| File.basename(f)}? spec.executables = Dir.glob("*", base: "bin")?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your suggestion! It works successfully now:

$ bundle exec test-unit --exclude=run-test.rb
Loaded suite test
Started
O
================================================================================================================================================================================================================================================================================================================================
Omission: memory usage collection isn't supported on this platform [test_fail(Test::Unit::TestAssertNothingLeakedMemory)]
/Users/zzz/src/github.com/test-unit/test-unit/test/test-assertions.rb:2986:in 'block in Test::Unit::TestAssertNothingLeakedMemory#test_fail'
================================================================================================================================================================================================================================================================================================================================
O
================================================================================================================================================================================================================================================================================================================================
Omission: memory usage collection isn't supported on this platform [test_pass(Test::Unit::TestAssertNothingLeakedMemory)]
/Users/zzz/src/github.com/test-unit/test-unit/test/test-assertions.rb:2933:in 'block in Test::Unit::TestAssertNothingLeakedMemory#test_pass'
================================================================================================================================================================================================================================================================================================================================
O
================================================================================================================================================================================================================================================================================================================================
Omission: memory usage collection isn't supported on this platform [test_pass_message(Test::Unit::TestAssertNothingLeakedMemory)]
/Users/zzz/src/github.com/test-unit/test-unit/test/test-assertions.rb:2944:in 'block in Test::Unit::TestAssertNothingLeakedMemory#test_pass_message'
================================================================================================================================================================================================================================================================================================================================
O
================================================================================================================================================================================================================================================================================================================================
Omission: memory usage collection isn't supported on this platform [test_pass_target(Test::Unit::TestAssertNothingLeakedMemory)]
/Users/zzz/src/github.com/test-unit/test-unit/test/test-assertions.rb:2957:in 'block in Test::Unit::TestAssertNothingLeakedMemory#test_pass_target'
================================================================================================================================================================================================================================================================================================================================
O
================================================================================================================================================================================================================================================================================================================================
Omission: test for JRuby [test_assert_raise_jruby(Test::Unit::TestAssertions)]
/Users/zzz/src/github.com/test-unit/test-unit/test/testunit-test-util.rb:15:in 'TestUnitTestUtil#jruby_only_test'
================================================================================================================================================================================================================================================================================================================================
O
================================================================================================================================================================================================================================================================================================================================
Omission: test for JRuby [test_error_inside_jruby(TestCodeSnippet::TestJRuby)]
/Users/zzz/src/github.com/test-unit/test-unit/test/testunit-test-util.rb:15:in 'TestUnitTestUtil#jruby_only_test'
================================================================================================================================================================================================================================================================================================================================
Finished in 0.770912 seconds.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
475 tests, 1612 assertions, 0 failures, 0 errors, 0 pendings, 6 omissions, 0 notifications
100% passed
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
616.15 tests/s, 2091.03 assertions/s

tikkss and others added 3 commits February 17, 2025 06:08
Test execution time bacame faster:

* before: 1.552s
* after: 1.347s

Co-authored-by: Sutou Kouhei <kou@clear-code.com>
Because `executables` are added to `files` automatically.

Co-authored-by: Sutou Kouhei <kou@clear-code.com>
bin/test-unit Outdated
@@ -0,0 +1,5 @@
#!/usr/bin/env ruby

require "test-unit"
Copy link
Member

Choose a reason for hiding this comment

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

Ah, we can use test/unit here:

Suggested change
require "test-unit"
require "test/unit"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, thanks!!!

Co-authored-by: Sutou Kouhei <kou@clear-code.com>
@tikkss
Copy link
Contributor Author

tikkss commented Feb 18, 2025

I updated PR description. Could you review it again?

@kou kou merged commit 269bdd1 into test-unit:master Feb 19, 2025
31 of 32 checks passed
@kou
Copy link
Member

kou commented Feb 19, 2025

Thanks.

@tikkss tikkss deleted the command-line-tool branch February 19, 2025 20:39
@tikkss
Copy link
Contributor Author

tikkss commented Feb 19, 2025

Thanks for your review and a lot of suggestion!

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.

2 participants