PageRenderTime 24ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/Languages/Ruby/Tests/run.rb

https://github.com/madpilot/ironruby
Ruby | 156 lines | 114 code | 20 blank | 22 comment | 17 complexity | 373ee4f6b561989f7bd6318627ac0afd MD5 | raw file
Possible License(s): GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, MIT
  1. # ****************************************************************************
  2. #
  3. # Copyright (c) Microsoft Corporation.
  4. #
  5. # This source code is subject to terms and conditions of the Microsoft Public License. A
  6. # copy of the license can be found in the License.html file at the root of this distribution. If
  7. # you cannot locate the Microsoft Public License, please send an email to
  8. # ironruby@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
  9. # by the terms of the Microsoft Public License.
  10. #
  11. # You must not remove this notice, or any other, from this software.
  12. #
  13. #
  14. # ****************************************************************************
  15. trap("INT") {
  16. puts
  17. puts "!!! Interrupt by the user !!!"
  18. exit(-1)
  19. }
  20. THIS_DIRECTORY = File.expand_path(File.dirname(__FILE__))
  21. CURR_DIRECTORY = Dir.pwd
  22. require File.dirname(__FILE__) + '/common'
  23. require 'benchmark'
  24. $failures = 0
  25. # Represents the list of all TestFiles to be run.
  26. class TestListFile
  27. def TestListFile.load
  28. test_lst_file = File.join(THIS_DIRECTORY, "test.lst")
  29. lines = ''
  30. # filter empty line and comment line
  31. File.open(test_lst_file, 'r') do |f|
  32. lines = f.readlines.grep(/^[^#\s]+/)
  33. end
  34. lines.collect do |l|
  35. parts = l.split
  36. raise "unexpected test entry: #{l}" if parts.length > 2
  37. TestFile.new(*parts)
  38. end
  39. end
  40. end
  41. class TestFile
  42. def initialize(file_name, driver_list='all')
  43. @file_name = file_name
  44. @driver_list = driver_list
  45. end
  46. def should_run_with?(driver)
  47. return true if @driver_list == "all"
  48. return false if @driver_list == "none"
  49. if @driver_list.include? '-'
  50. # you do not have to specify "wanted"
  51. @driver_list.include?(driver.name + "-") == false
  52. else
  53. @driver_list.include? driver.name
  54. end
  55. end
  56. def run_by(driver)
  57. if !should_run_with? driver
  58. print "s"
  59. elsif driver.run(@file_name, driver.logger.log_name) == 0
  60. print "."
  61. else
  62. $failures += 1
  63. print "x(#{File.basename(@file_name)})"
  64. end
  65. end
  66. def run_skipped_by(driver)
  67. if !should_run_with? driver
  68. if driver.run(@file_name, driver.logger.log_name) == 0
  69. printf "p(%s)", File.basename(@file_name)
  70. else
  71. print "f"
  72. end
  73. end
  74. end
  75. end
  76. # current options which are running inside SNAP:
  77. # -checkin
  78. # -fast
  79. # drivers
  80. applicable_drivers = []
  81. ARGV.each do |option|
  82. case option
  83. when /all/
  84. applicable_drivers << Test::Iron_m2 << Test::Iron_m1 << Test::Iron_cc
  85. when /coreclr/
  86. applicable_drivers << Test::Iron_cc
  87. when /fast|interpret/
  88. applicable_drivers << Test::Iron_m1
  89. when /compile/
  90. applicable_drivers << Test::Iron_m2
  91. when /verify/
  92. applicable_drivers << Test::Iron_m3
  93. when /cruby/
  94. applicable_drivers << Test::CRuby
  95. when /checkin/
  96. applicable_drivers << Test::Iron_m2 << Test::Iron_m1
  97. when /neg/
  98. else
  99. p "Invalid option: #{option}"
  100. end
  101. end
  102. applicable_drivers = [ Test::Iron_m2, Test::Iron_m1] if applicable_drivers.empty?
  103. applicable_drivers.uniq!
  104. test_files = TestListFile::load
  105. applicable_drivers.each do |driver|
  106. time = Benchmark.measure(driver.to_s) do
  107. puts "#{driver}"
  108. puts " log @ #{driver.logger} \n"
  109. if ARGV.include? "-neg" # The user wants to run all the unsupported test cases
  110. test_files.each { |tf| tf.run_skipped_by(driver) }
  111. else
  112. test_files.each { |tf| tf.run_by(driver) }
  113. end
  114. puts "\n"
  115. end
  116. puts time.format("Time: %10.6r\n\n")
  117. end
  118. # Some folders use run_<name>.rb instead of a test list
  119. if applicable_drivers.include? Test::Iron_m2 and !ARGV.include? "-fast"
  120. [
  121. 'syntax',
  122. 'compat'
  123. ].each do |s|
  124. puts ">>> Running #{s} test \n"
  125. ret = Test::CRuby.run(File.join(TestPath::TEST_DIR, "#{s}/run_#{s}.rb -snap "), nil)
  126. if ret == 0
  127. puts "pass"
  128. else
  129. $failures += ret
  130. puts "fail"
  131. end
  132. puts "\n"
  133. end
  134. end
  135. puts "\nSummary: #{$failures} failures in run.rb\n"
  136. exit($failures)