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.



1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
# File 'lib/mesa_test.rb', line 1045

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.



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

def mesa
  @mesa
end

#modObject (readonly)

Returns the value of attribute mod.



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

def mod
  @mod
end

#positionObject (readonly)

Returns the value of attribute position.



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

def position
  @position
end

#shellObject (readonly)

Returns the value of attribute shell.



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

def shell
  @shell
end

#test_nameObject (readonly)

Returns the value of attribute test_name.



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

def test_name
  @test_name
end

Class Method Details

.modulesObject



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

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!



1078
1079
1080
1081
1082
1083
# File 'lib/mesa_test.rb', line 1078

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



1113
1114
1115
1116
1117
1118
# File 'lib/mesa_test.rb', line 1113

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



1105
1106
1107
1108
1109
1110
# File 'lib/mesa_test.rb', line 1105

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



1121
1122
1123
1124
1125
1126
# File 'lib/mesa_test.rb', line 1121

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)


1100
1101
1102
# File 'lib/mesa_test.rb', line 1100

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

#ran?Boolean

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

Returns:

  • (Boolean)


1094
1095
1096
# File 'lib/mesa_test.rb', line 1094

def ran?
  File.exist?(testhub_file)
end

#results_hashObject



1085
1086
1087
1088
1089
1090
1091
# File 'lib/mesa_test.rb', line 1085

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



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

def test_case_dir
  File.join(test_suite_dir, test_name)
end

#test_suite_dirObject



1064
1065
1066
# File 'lib/mesa_test.rb', line 1064

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

#testhub_fileObject



1072
1073
1074
# File 'lib/mesa_test.rb', line 1072

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