Skip to content

Conversation

@tikkss
Copy link
Contributor

@tikkss tikkss commented Dec 14, 2025

GitHub: GH-235

Will be available process based parallel test running. A user can use it by the --parallel=process option.

A user needs to specify load path options (e.g. -Ilib). Workers preload required files, so they must have the correct $LOAD_PATH. However, it's hard for us to figure out the right extra load paths automatically.

Like the thread based runner, the test case level fixture defined tests run in the same worker.

Note: Windows is not supported yet.

GitHub: test-unitGH-235

Will be available process based parallel test running. A user can use it
by the `--parallel=process` option.

A user needs to specify load path options (e.g. `-Ilib`). Workers
preload required files, so they must have the correct `$LOAD_PATH`.
However, it's hard for us to figure out the right extra load paths
automatically.

Like the thread based runner, the test case level fixture defined tests
run in the same worker.

Co-authored-by: Sutou Kouhei <kou@clear-code.com>
Co-authored-by: Naoto Ono <onoto1998@gmail.com>
data = worker.receive
case data[:status]
when :ready
test_name = run_context.test_names.shift
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like the Thread::Queue#pop, We can use Array#shift instead of Array#pop.

@tikkss
Copy link
Contributor Author

tikkss commented Dec 14, 2025

3.4 on Windows + Process CI has failed:

D:/a/test-unit/test-unit/lib/test/unit/test-suite-process-runner.rb:67:in 'Kernel#spawn': wrong file descriptor (3) (ArgumentError)

          pid = spawn(*command_line, {3 => main_to_worker_input, 4 => worker_to_main_output})

On Windows, can we pass file descriptors 3 and above to child processes?
If not, Can we pass to using only 0, 1 or 2 on Windows?

@kou
Copy link
Member

kou commented Dec 14, 2025

On Windows, can we pass file descriptors 3 and above to child processes?
If not, Can we pass to using only 0, 1 or 2 on Windows?

Oh... I don't want to change stdin/stdout/stderr as much as possible because tests may use them.

We may need to find another approach...

`Test::Unit::TestSuite::FINISHED::OBJECT` event includes
`Test::Unit::TestCase` object, and `Test::Unit::TestCase` object has
`Test::Unit::ProcessTestResult` object.
`Test::Unit::ProcessTestResult` object has `IO` object, so it can't
dump.

Since f0ddbe7, `Test::Unit::TestCase` object dump only minimal data, so
this object has not `Test::Unit::ProcessTestResult` object.
@tikkss
Copy link
Contributor Author

tikkss commented Dec 14, 2025

We may need to find another approach...

Ouch! This means do we use TCP/IP socket instead of IO.pipe as below?

  • Pipe
    • Faster, but Unix only? (also work Windows?)
  • Unix domain socket
    • Fast, but Unix only
  • TCP/IP socket
    • Portable, but slow

We prioritize portability, so we will use Pipe or TCP/IP.

Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

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

This means do we use TCP/IP socket instead of IO.pipe as below?

Let's try it.
Let's work on Windows support as a separated task.

@kou kou merged commit e15026e into test-unit:master Dec 15, 2025
38 checks passed
@tikkss tikkss deleted the add-support-for-process-based-parallel-test-running branch December 15, 2025 01:36
tikkss added a commit to tikkss/test-unit that referenced this pull request Dec 15, 2025
GitHub: test-unitGH-235, test-unitGH-346

On Windows, file descriptors 3 and above cannot be passed to child
processes. So we use `TCPSocket` instead of `IO.pipe`.
tikkss added a commit to tikkss/test-unit that referenced this pull request Dec 15, 2025
GitHub: test-unitGH-235, test-unitGH-346

On Windows, file descriptors 3 and above cannot be passed to child
processes. So we use `TCPSocket` instead of `IO.pipe`.
kou added a commit that referenced this pull request Dec 18, 2025
GitHub: GH-235, GH-346

On Windows, file descriptors 3 and above cannot be passed to child
processes. So we use `TCPSocket` instead of `IO.pipe`.

---------

Co-authored-by: Sutou Kouhei <kou@clear-code.com>
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