example_puzzles/compile_examples.rb
# Executes an example and stores output and exit code in the hash.
#
# @param example [Hash] the example originally described in YAML.
# @return [Hash] the example
Executes an example and stores output and exit code in the hash.
Executes an example and stores output and exit code in the hash .
def execute(example)
  argv = example[:input_files] + example[:argv]
  example[:command] = "solve_sudoku #{argv.join(' ')}"
  full_command = "./exe/#{example[:command]}"
  Open3.popen3(full_command) {|stdin, stdout, stderr, wait_thr|
    stdin.write(example[:input]) if example[:input]
    example[:exit_code] = wait_thr.value.to_i
    example[:stdout] = stdout.read
    example[:stderr] = stderr.read
  }
  example
end
def execute ( example ) argv = example [ :input_files ] + example [ :argv ] example [ :command ] = "solve_sudoku #{argv.join(' ')}" full_command = "./exe/#{example[:command]}" Open3 . popen3 ( full_command ) { | stdin , stdout , stderr , wait_thr | stdin . write ( example [ :input ] ) if example [ :input ] example [ :exit_code ] = wait_thr . value . to_i example [ :stdout ] = stdout . read example [ :stderr ] = stderr . read } example end
Executes an example and stores output and exit code in the hash.
Executes an example and stores output and exit code in the hash .
None
Hash
example
the example originally described in YAML.
the example originally described in YAML .