MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / execute

Method execute

rake_tasks/bazel.rb:14–59  ·  view source on GitHub ↗
(kind, args, target, &block)

Source from the content-addressed store, hash-verified

12 end
13
14 def self.execute(kind, args, target, &block)
15 verbose = Rake::FileUtilsExt.verbose_flag
16
17 if target.end_with?(':run')
18 kind = 'run'
19 target = target[0, target.length - 4]
20 end
21
22 cmd = %w[bazel] + [kind, target] + (args || [])
23 cmd_out = ''
24 cmd_exit_code = 0
25
26 puts "Executing: #{cmd.join(' ')}"
27 if windows?
28 quoted = cmd.map { |a| a.match?(/[\s"]/) ? %("#{a.gsub('"', '\\"')}") : a }
29 cmd_line = "#{quoted.join(' ')} 2>&1"
30 cmd_out = `#{cmd_line}`.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
31 puts cmd_out if verbose
32 cmd_exit_code = $CHILD_STATUS
33 else
34 Open3.popen2e(*cmd) do |stdin, stdouts, wait|
35 is_running = true
36 stdin.close
37 while is_running
38 begin
39 stdouts.wait_readable
40 line = stdouts.readpartial(512)
41 cmd_out += line
42 $stdout.print line if verbose
43 rescue EOFError
44 is_running = false
45 end
46 end
47 cmd_exit_code = wait.value.exitstatus
48 end
49 end
50
51 raise "#{cmd.join(' ')} failed with exit code: #{cmd_exit_code}\nOutput: #{cmd_out}" if cmd_exit_code != 0
52
53 block&.call(cmd_out)
54 return unless cmd_out =~ %r{\s+(bazel-bin/\S+)}
55
56 out_artifact = Regexp.last_match(1)
57 puts "#{target} -> #{out_artifact}" if out_artifact
58 out_artifact
59 end
60end

Callers

nothing calls this directly

Calls 7

lengthMethod · 0.65
encodeMethod · 0.65
closeMethod · 0.65
printMethod · 0.65
callMethod · 0.65
mapMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected