Top Level Namespace
Defined Under Namespace
Classes: Mesa, MesaTestCase, MesaTestSubmitter
Constant Summary collapse
- MesaDirError =
Class.new(StandardError)
- TestCaseDirError =
Class.new(StandardError)
- InvalidDataType =
Class.new(StandardError)
- GitHubError =
Class.new(StandardError)
- GITHUB_HTTPS =
'https://github.com/MESAHub/mesa.git'.freeze
- GITHUB_SSH =
'[email protected]:MESAHub/mesa.git'.freeze
Instance Method Summary collapse
-
#b64_file(filename) ⇒ Object
encode the contents of a file as base-64.
-
#bash_execute(command, throw_exception = false) ⇒ Object
force the execution to happen with bash.
-
#bashticks(command) ⇒ Object
force execution to happen with bash, but return result rather than exit status (like backticks).
- #dir_or_symlink_exists?(path) ⇒ Boolean
-
#generate_seeds_rb(mesa_dir, outfile) ⇒ Object
the next function probalby doesn’t belong here, but keep it anyway, please create seed data for test cases for MesaTestHub of a given mesa version.
-
#visit_and_check(new_dir, exception, message) ⇒ Object
cd into a new directory, execute a block whose return value is either true or false.
-
#visit_dir(new_dir, quiet: false) ⇒ Object
cd into a new directory, execute a block, then cd back into original directory.
Instance Method Details
#b64_file(filename) ⇒ Object
encode the contents of a file as base-64
1138 1139 1140 |
# File 'lib/mesa_test.rb', line 1138 def b64_file(filename) Base64.encode64(File.open(filename).read) end |
#bash_execute(command, throw_exception = false) ⇒ Object
force the execution to happen with bash
1122 1123 1124 1125 1126 1127 1128 1129 |
# File 'lib/mesa_test.rb', line 1122 def bash_execute(command, throw_exception=false) res = system('bash -c "' + command + '"') if !res && throw_exception raise BashError('Encountered an error when executing the following '\ "command in bash: #{command}.") end res end |
#bashticks(command) ⇒ Object
force execution to happen with bash, but return result rather than exit status (like backticks)
1133 1134 1135 |
# File 'lib/mesa_test.rb', line 1133 def bashticks(command) `bash -c "#{command}"`.chomp end |
#dir_or_symlink_exists?(path) ⇒ Boolean
1117 1118 1119 |
# File 'lib/mesa_test.rb', line 1117 def dir_or_symlink_exists?(path) File.directory?(path) || File.symlink?(path) end |
#generate_seeds_rb(mesa_dir, outfile) ⇒ Object
the next function probalby doesn’t belong here, but keep it anyway, please create seed data for test cases for MesaTestHub of a given mesa version
1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 |
# File 'lib/mesa_test.rb', line 1096 def generate_seeds_rb(mesa_dir, outfile) m = Mesa.new(mesa_dir: mesa_dir) m.load_test_source_data File.open(outfile, 'w') do |f| f.puts 'test_cases = TestCase.create!(' f.puts ' [' m.test_names.each do |test_case_name| f.puts ' {' f.puts " name: '#{test_case_name}'," # no comma on last one if test_case_name == m.test_names[-1] f.puts(' }') else f.puts(' },') end end f.puts ' ]' f.puts ')' end end |
#visit_and_check(new_dir, exception, message) ⇒ Object
cd into a new directory, execute a block whose return value is either true or false. Either way, cd back to original directory. Raise an exception if the block failed (returned false or nil)
1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 |
# File 'lib/mesa_test.rb', line 1068 def visit_and_check(new_dir, exception, ) cwd = Dir.getwd shell.say "Leaving #{cwd}", :blue shell.say "\nEntering #{new_dir}.", :blue Dir.chdir(new_dir) success = yield if block_given? shell.say "Leaving #{new_dir}", :blue shell.say "\nEntering #{cwd}.", :blue Dir.chdir(cwd) return if success raise exception, end |
#visit_dir(new_dir, quiet: false) ⇒ Object
cd into a new directory, execute a block, then cd back into original directory
1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 |
# File 'lib/mesa_test.rb', line 1083 def visit_dir(new_dir, quiet: false) cwd = Dir.getwd shell.say "Leaving #{cwd}\n", :blue unless quiet shell.say "\nEntering #{new_dir}.", :blue unless quiet Dir.chdir(new_dir) yield if block_given? shell.say "Leaving #{new_dir}\n", :blue unless quiet shell.say "\nRe-entering #{cwd}.", :blue unless quiet Dir.chdir(cwd) end |