Top Level Namespace

Defined Under Namespace

Classes: Commit, Mesa, MesaTestCase, MesaTestSubmitter

Constant Summary collapse

MesaDirError =
Class.new(StandardError)
TestCaseDirError =
Class.new(StandardError)
InvalidDataType =
Class.new(StandardError)
DEFAULT_REVISION =
10_000

Instance Method Summary collapse

Instance Method Details

#bash_execute(command) ⇒ Object

force the execution to happen with bash



1657
1658
1659
# File 'lib/mesa_test.rb', line 1657

def bash_execute(command)
  system('bash -c "' + command + '"')
end

Check if path is directory or symlink



1652
1653
1654
# File 'lib/mesa_test.rb', line 1652

def dir_or_symlink_exists?(path)
  File.directory?(path) || File.symlink?(path)
end

#generate_seeds_rb(mesa_dir, outfile) ⇒ Object

create seed data for test cases for MesaTestHub of a given mesa version



1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
# File 'lib/mesa_test.rb', line 1629

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}',"
      f.puts "      version_added: #{m.version_number},"
      # 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)

Raises:

  • (exception)


1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
# File 'lib/mesa_test.rb', line 1599

def visit_and_check(new_dir, exception, message)
  cwd = Dir.getwd
  shell.say "Leaving  #{cwd}", :blue
  puts ''
  shell.say "Entering #{new_dir}.", :blue
  Dir.chdir(new_dir)
  success = yield if block_given?
  shell.say "Leaving  #{new_dir}", :blue
  puts ''
  shell.say "Entering #{cwd}.", :blue
  Dir.chdir(cwd)
  return if success
  raise exception, message
end

#visit_dir(new_dir) ⇒ Object

cd into a new directory, execute a block, then cd back into original directory



1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
# File 'lib/mesa_test.rb', line 1616

def visit_dir(new_dir)
  cwd = Dir.getwd
  shell.say "Leaving  #{cwd}\n", :blue
  shell.say "Entering #{new_dir}.", :blue
  Dir.chdir(new_dir)
  yield if block_given?
  shell.say "Leaving  #{new_dir}\n", :blue
  shell.say "Re-entering #{cwd}.", :blue
  puts ""
  Dir.chdir(cwd)
end