Class: VhdlDoctest::TestRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/vhdl_doctest/test_runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(out, dut_path, test_file, dependencies = []) ⇒ TestRunner

Returns a new instance of TestRunner.



3
4
5
6
7
8
9
10
11
# File 'lib/vhdl_doctest/test_runner.rb', line 3

def initialize(out, dut_path, test_file, dependencies = [])
  @out = out
  @dut_path = File.expand_path(dut_path)
  @test_file = test_file
  @dependencies = dependencies

  require 'tmpdir'
  @dir = Dir.mktmpdir
end

Instance Method Details

#create_filesObject



19
20
21
22
# File 'lib/vhdl_doctest/test_runner.rb', line 19

def create_files
  @test_file.create(@dir)
  create_runner_script
end

#create_runner_scriptObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/vhdl_doctest/test_runner.rb', line 29

def create_runner_script
  @sh = File.join(@dir, "run.sh")
  File.open(@sh, 'w') do |f|
    f << "#!/bin/sh -e\n\n"
    f << "cd #{@dir}\n"
    f << "ghdl -a --ieee=synopsys -fexplicit --warn-default-binding --warn-binding --warn-library --warn-body --warn-specs --warn-unused #{dependencies.join(" ")} #{@dut_path} #{@test_file.path}\n"
    f << "ghdl -e -Plibs/unisim --ieee=synopsys -fexplicit #{@test_file.test_name}\n"
    f << "ghdl -r #{@test_file.test_name} --vcd=out.vcd --stop-time=10ms\n"
  end
end

#dependenciesObject



24
25
26
27
# File 'lib/vhdl_doctest/test_runner.rb', line 24

def dependencies
  dut_dir = File.dirname(@dut_path)
  @dependencies.map { |path| File.expand_path(path, dut_dir) }
end

#runObject



13
14
15
16
17
# File 'lib/vhdl_doctest/test_runner.rb', line 13

def run
  create_files
  run_test
  report_result
end