Skip to content

Conversation

@tikkss
Copy link
Contributor

@tikkss tikkss commented Feb 20, 2025

GitHub: fix GH-288

This patch is the final step. It allows specifying test targets.

GitHub: fix test-unitGH-288

This patch is the final step. It allows specifying test targets.
@tikkss
Copy link
Contributor Author

tikkss commented Feb 20, 2025

I tested following commands and confirmed they work correctly:

$ bundle exec test-unit --exclude=run-test.rb test
$ bundle exec test-unit --exclude=run-test.rb test/test-assertions.rb
$ bundle exec test-unit --exclude=run-test.rb test/test-assertions.rb:143
$ bundle exec test-unit --exclude=run-test.rb test/test-assertions.rb test/test-data.rb
$ bundle exec test-unit --exclude=run-test.rb test -n /collect/
$ bundle exec test-unit --exclude=run-test.rb test -n /collect/ --parallel

@kou
Copy link
Member

kou commented Feb 21, 2025

What happen with bundle exec test-unit --exclude=run-test.rb?

BTW, we should rename test/run-test.rb to test/run.rb...

@tikkss
Copy link
Contributor Author

tikkss commented Feb 21, 2025

What happen with bundle exec test-unit --exclude=run-test.rb?

It works correctly:

$ bundle exec test-unit --exclude=run-test.rb
Loaded suite .
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.778207 seconds.
-------------------------------------------------------------------------------
478 tests, 1616 assertions, 0 failures, 0 errors, 0 pendings, 6 omissions, 0 notifications
100% passed
-------------------------------------------------------------------------------
614.23 tests/s, 2076.57 assertions/s

In this case, the test target is maybe the current directory.
Because create the following ./test-sample.rb and run test result is the following:

require "test/unit"

class SampleTest < Test::Unit::TestCase
  def test_1
    pp __method__
    assert true
  end
end
$ bundle exec test-unit --exclude=run-test.rb
Loaded suite .
Started
:test_1
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.762427 seconds.
-------------------------------------------------------------------------------
479 tests, 1617 assertions, 0 failures, 0 errors, 0 pendings, 6 omissions, 0 notifications
100% passed
-------------------------------------------------------------------------------
628.26 tests/s, 2120.86 assertions/s

with test target:

$ bundle exec test-unit --exclude=run-test.rb test
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.758385 seconds.
-------------------------------------------------------------------------------
474 tests, 1612 assertions, 0 failures, 0 errors, 0 pendings, 6 omissions, 0 notifications
100% passed
-------------------------------------------------------------------------------
625.01 tests/s, 2125.57 assertions/s

BTW, we should rename test/run-test.rb to test/run.rb...

That makes sense. Without --exclude=run-test.rb, tests can run correctly:
I'll open a separate PR for this file name change.

$ mv test/run-test.rb test/run.rb
$ bundle exec test-unit test
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.778561 seconds.
-------------------------------------------------------------------------------
474 tests, 1612 assertions, 0 failures, 0 errors, 0 pendings, 6 omissions, 0 notifications
100% passed
-------------------------------------------------------------------------------
608.82 tests/s, 2070.49 assertions/s

@kou
Copy link
Member

kou commented Feb 22, 2025

OK. Let's use this.

@kou kou merged commit 7bc1af7 into test-unit:master Feb 22, 2025
32 checks passed
@tikkss tikkss deleted the command-line-tool branch February 23, 2025 22:26
@tikkss
Copy link
Contributor Author

tikkss commented Feb 23, 2025

Thanks for your review!

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.

Add support for command line tool

2 participants