Skip to content

Commit 5a4ac1d

Browse files
committed
Actually improving crazyfun-bazel integration for non-windows systems
(accidentally committed a wrong version of the file)
1 parent 0d2a9b4 commit 5a4ac1d

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

rakelib/bazel.rake

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'pp'
2+
require 'open3'
23
require 'rake/task'
34
require 'rake_tasks/selenium_rake/checks'
45
require 'rakelib/bazel/task'
@@ -11,15 +12,33 @@ module Bazel
1112

1213
cmd = %w[bazel] + [kind, target] + (args || [])
1314
puts cmd.join(" ")
14-
15+
1516
if SeleniumRake::Checks::windows?
1617
cmd = cmd + ["2>&1"]
1718
cmd_line = cmd.join(" ")
1819
cmd_out = `#{cmd_line}`
1920
cmd_exit_code = $?.success?
2021
else
21-
cmd_out = `#{cmd_line}`
22-
cmd_exit_code = $?.success?
22+
Open3.popen2e(*cmd) do |stdin, stdouts, wait|
23+
is_running = true
24+
stdin.close
25+
cmd_out = ''
26+
while is_running
27+
begin
28+
pipes = IO.select([stdouts])
29+
if pipes.empty?
30+
is_running = false
31+
else
32+
line = stdouts.readpartial(512)
33+
cmd_out << line
34+
STDOUT.print line if verbose
35+
end
36+
rescue EOFError
37+
is_running = false
38+
end
39+
end
40+
cmd_exit_code = wait.value.exitstatus
41+
end
2342
end
2443

2544
puts cmd_out if verbose
@@ -28,9 +47,9 @@ module Bazel
2847

2948
block&.call(cmd_out)
3049
out_artifact = Regexp.last_match(1) if cmd_out =~ %r{\s+(bazel-bin/\S+)}
31-
50+
3251
puts "#{target} -> #{out_artifact}" if out_artifact
3352
out_artifact
3453
end
3554
end
36-
end
55+
end

0 commit comments

Comments
 (0)