Class: MesaTestCase

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(test: nil, mesa: nil, mod: nil, position: nil) ⇒ MesaTestCase

Returns a new instance of MesaTestCase.



991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
# File 'lib/mesa_test.rb', line 991

def initialize(test: nil, mesa: nil, mod: nil, position: nil)
  @test_name = test
  @mesa = mesa
  unless MesaTestCase.modules.include? mod
    raise TestCaseDirError, "Invalid module: #{mod}. Must be one of: " +
                            MesaTestCase.modules.join(', ')
  end
  @mod = mod
  @position = position

  # way to output colored text to shell
  @shell = Thor::Shell::Color.new

  # validate stuff
  check_mesa_dir
  check_test_case

end

Instance Attribute Details

#mesaObject (readonly)

Returns the value of attribute mesa.



985
986
987
# File 'lib/mesa_test.rb', line 985

def mesa
  @mesa
end

#modObject (readonly)

Returns the value of attribute mod.



985
986
987
# File 'lib/mesa_test.rb', line 985

def mod
  @mod
end

#positionObject (readonly)

Returns the value of attribute position.



985
986
987
# File 'lib/mesa_test.rb', line 985

def position
  @position
end

#shellObject (readonly)

Returns the value of attribute shell.



985
986
987
# File 'lib/mesa_test.rb', line 985

def shell
  @shell
end

#test_nameObject (readonly)

Returns the value of attribute test_name.



985
986
987
# File 'lib/mesa_test.rb', line 985

def test_name
  @test_name
end

Class Method Details

.modulesObject



987
988
989
# File 'lib/mesa_test.rb', line 987

def self.modules
  %i[star binary astero]
end

Instance Method Details

#do_oneObject

just punt to each_test_run in the test_suite directory. It’s your problem now, sucker!



1024
1025
1026
1027
1028
1029
# File 'lib/mesa_test.rb', line 1024

def do_one
  shell.say("Testing #{test_name}", :yellow)
  visit_dir(test_suite_dir) do
    bash_execute("./each_test_run #{position}")
  end
end

#err_64Object

Base-64 encoded contents of err.txt file



1059
1060
1061
1062
1063
1064
# File 'lib/mesa_test.rb', line 1059

def err_64
  err_file = File.join(test_case_dir, 'err.txt')
  return '' unless File.exist?(err_file)

  b64_file(err_file)
end

#mk_64Object

Base-64 encoded contents of mk.txt file



1051
1052
1053
1054
1055
1056
# File 'lib/mesa_test.rb', line 1051

def mk_64
  mk_file = File.join(test_case_dir, 'mk.txt')
  return '' unless File.exist?(mk_file)

  b64_file(mk_file)
end

#out_64Object

Base-64 encoded contents of out.txt file



1067
1068
1069
1070
1071
1072
# File 'lib/mesa_test.rb', line 1067

def out_64
  out_file = File.join(test_case_dir, 'out.txt')
  return '' unless File.exist?(out_file)

  b64_file(out_file)
end

#passed?Boolean

whether or not a test case has passed; only has meaning if we can load the results hash, though

Returns:

  • (Boolean)


1046
1047
1048
# File 'lib/mesa_test.rb', line 1046

def passed?
  results_hash['outcome'] == :pass
end

#ran?Boolean

rough proxy for whether or not the test has even been run

Returns:

  • (Boolean)


1040
1041
1042
# File 'lib/mesa_test.rb', line 1040

def ran?
  File.exist?(testhub_file)
end

#results_hashObject



1031
1032
1033
1034
1035
1036
1037
# File 'lib/mesa_test.rb', line 1031

def results_hash
  unless ran?
    raise TestCaseDirError.new('No results found for test case '\
                               "#{test_name}.")
  end
  YAML.load(File.read(testhub_file))
end

#test_case_dirObject



1014
1015
1016
# File 'lib/mesa_test.rb', line 1014

def test_case_dir
  File.join(test_suite_dir, test_name)
end

#test_suite_dirObject



1010
1011
1012
# File 'lib/mesa_test.rb', line 1010

def test_suite_dir
  mesa.test_suite_dir(mod: @mod)
end

#testhub_fileObject



1018
1019
1020
# File 'lib/mesa_test.rb', line 1018

def testhub_file
  File.join(test_case_dir, 'testhub.yml')
end