-
Notifications
You must be signed in to change notification settings - Fork 30
Windows support #50
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
Windows support #50
Changes from 3 commits
d0246f2
3b70426
df946e7
b4ad8f4
8af698e
1fa426c
1f714bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,3 +81,5 @@ def notification | |
end | ||
end | ||
end | ||
|
||
require "turbo_tests/windows" if RUBY_PLATFORM.match?(/mingw|mswin/) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# frozen_string_literal: true | ||
|
||
module TurboTests | ||
class Runner | ||
private | ||
|
||
def start_subprocess(env, extra_args, tests, process_id, record_runtime:) | ||
if tests.empty? | ||
@messages << { | ||
type: "exit", | ||
process_id: process_id, | ||
} | ||
else | ||
require "securerandom" | ||
env["RSPEC_FORMATTER_OUTPUT_ID"] = SecureRandom.uuid | ||
env["RUBYOPT"] = ["-I#{File.expand_path("..", __dir__)}", ENV["RUBYOPT"]].compact.join(" ") | ||
|
||
command_name = Gem.win_platform? ? [Gem.ruby, "bin/rspec"] : "bin/rspec" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the best way to detect Bundler binstubs and/or if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point too! Using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Will Windows correctly handle this if we append env["PATH"] << ":#{File.expand_path("bin", __dir__)}"
command_name = ENV["BUNDLE_BIN_PATH"] ? [ENV["BUNDLE_BIN_PATH"], "exec", "rspec"] : "rspec" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would handle it fine, but I'm not sure it's a good idea since it would have global side effects. Users have other scripts in Maybe we can start leaving things as they are regarding building the command name for now. I could configure |
||
|
||
command = [ | ||
*command_name, | ||
*extra_args, | ||
"--seed", rand(0xFFFF).to_s, | ||
"--format", "ParallelTests::RSpec::RuntimeLogger", | ||
"--out", @runtime_log, | ||
"--require", File.expand_path("windows_json_rows_formatter", __dir__), | ||
"--format", "TurboTests::WindowsJsonRowsFormatter", | ||
deivid-rodriguez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*tests | ||
] | ||
|
||
if @verbose | ||
command_str = [ | ||
env.map {|k, v| "#{k}=#{v}" }.join(" "), | ||
command.join(" "), | ||
].select {|x| x.size > 0 }.join(" ") | ||
|
||
warn "Process #{process_id}: #{command_str}" | ||
end | ||
|
||
stdin, stdout, stderr, wait_thr = Open3.popen3(env, *command) | ||
stdin.close | ||
|
||
@threads << | ||
Thread.new do | ||
require "json" | ||
stdout.each_line do |line| | ||
result = line.split(env["RSPEC_FORMATTER_OUTPUT_ID"]) | ||
|
||
output = result.shift | ||
print(output) unless output.empty? | ||
|
||
message = result.shift | ||
next unless message | ||
|
||
message = JSON.parse(message, symbolize_names: true) | ||
message[:process_id] = process_id | ||
@messages << message | ||
end | ||
|
||
@messages << { type: "exit", process_id: process_id } | ||
end | ||
|
||
@threads << start_copy_thread(stderr, STDERR) | ||
|
||
@threads << Thread.new do | ||
unless wait_thr.value.success? | ||
@messages << { type: "error" } | ||
end | ||
end | ||
|
||
wait_thr | ||
end | ||
end | ||
end | ||
end |
Uh oh!
There was an error while loading. Please reload this page.