-
Notifications
You must be signed in to change notification settings - Fork 106
Add support for command line tool #289
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
Conversation
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
| require "bundler/gem_tasks" | ||
|
|
||
| ruby("-r test-unit -e run_test test") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
test-unit.gemspec
Outdated
| spec.files += ["COPYING", "BSDL", "PSFL"] | ||
| spec.files += Dir.glob("{lib,sample}/**/*.rb") | ||
| spec.files += Dir.glob("doc/text/**/*.*") | ||
| spec.files += Dir.glob("bin/*") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>'There was a problem hiding this comment.
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")?
There was a problem hiding this comment.
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/sTest 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" | |||
There was a problem hiding this comment.
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:
| require "test-unit" | |
| require "test/unit" |
There was a problem hiding this comment.
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>
|
I updated PR description. Could you review it again? |
|
Thanks. |
|
Thanks for your review and a lot of suggestion! |
GitHub: GH-288
This patch is the first step.
test-unitexecutable just invokesrequire "test/unit"; exit(Test::Unit::AutoRunner.run(true, "test"))and does not support specifying test targets yet.