Module: Bulldogger::Frames

Defined in:
lib/bulldogger/frames.rb

Overview

Runs one command with structural frame collection enabled. It does not select tests or change command arguments.

Constant Summary collapse

SCHEMA_VERSION =
1

Class Method Summary collapse

Class Method Details

.run(command, output_dir: ENV.fetch("BULLDOGGER_OUTPUT_DIR", "tmp/bulldogger"), stdout: $stdout) ⇒ Object

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/bulldogger/frames.rb', line 16

def run(command, output_dir: ENV.fetch("BULLDOGGER_OUTPUT_DIR", "tmp/bulldogger"), stdout: $stdout)
  raise ArgumentError, "frames requires a command after --" if command.empty?

  output_dir = File.expand_path(output_dir)
  FileUtils.mkdir_p(output_dir)
  base_path = File.join(output_dir, "frames")
  env = CollectorEnvironment.build("frames_collector.rb", "BULLDOGGER_FRAMES_OUT" => base_path)
  pid = Process.spawn(env, *command)
  _waited_pid, status = Process.wait2(pid)
  path = "#{base_path}-#{pid}.jsonl"
  append_envelope(path, command, status)
  stdout.puts "bulldogger frames: #{path}"
  stdout.puts "bulldogger result: #{outcome(status)} (exit #{status.exitstatus || status.termsig})"
  status
end