Guest User

Untitled

a guest
Feb 18th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. #!parrot
  2.  
  3. .loadlib 'io_ops'
  4.  
  5. .sub main :main
  6. .param pmc argv
  7. $S0 = shift argv
  8. .local int argc
  9. argc = elements argv
  10. if argc > 0 goto L1
  11. help()
  12. end
  13. L1:
  14. .local pmc opts
  15. opts = _parse_opts(argv)
  16. $I0 = exists opts['help']
  17. unless $I0 goto L2
  18. help()
  19. end
  20. L2:
  21. $P0 = _get_tests(opts, argv)
  22. run_tests($P0)
  23. .end
  24.  
  25. .sub 'help' :anon
  26. say <<"HELP"
  27. parrot t/harness.pir [options] [testfiles]
  28. --core-tests
  29. --runcore-tests
  30. --code-tests
  31. --archive ... create a TAP archive of the test run
  32. --send-to-smolder ... send the TAP archive to the Parrot Smolder server
  33. HELP
  34. .end
  35.  
  36. .sub '_get_tests' :anon
  37. .param pmc opts
  38. .param pmc files
  39. .local int nb
  40.  
  41. load_bytecode 'TAP/Harness.pbc'
  42.  
  43. $I0 = opts['code-tests']
  44. unless $I0 goto L1
  45. .const string developing_tests = 't/codingstd/*.t'
  46. files = glob(developing_tests)
  47. goto L2
  48. L1:
  49. nb = elements files
  50. unless nb == 0 goto L2
  51. files = _get_common_tests(opts)
  52. L2:
  53. nb = elements files
  54. # currently, FixedStringArray hasn't the method sort.
  55. # see TT #1356
  56. $P0 = new 'FixedPMCArray'
  57. set $P0, nb
  58. $I0 = 0
  59. $P1 = iter files
  60. L3:
  61. unless $P1 goto L4
  62. $S0 = shift $P1
  63. $P2 = split "\\", $S0
  64. $S0 = join "/", $P2
  65. $P2 = box $S0
  66. $P0[$I0] = $P2
  67. inc $I0
  68. goto L3
  69. L4:
  70. $P0.'sort'()
  71. .return ($P0)
  72. .end
  73.  
  74. .sub '_parse_opts' :anon
  75. .param pmc argv
  76. load_bytecode 'Getopt/Obj.pbc'
  77. $P0 = new ['Getopt';'Obj']
  78. $P0.'notOptStop'(1)
  79. push $P0, 'gc-debug'
  80. push $P0, 'core-tests'
  81. push $P0, 'runcore-tests'
  82. push $P0, 'code-tests'
  83. push $P0, 'run-exec'
  84. push $P0, 'archive'
  85. push $P0, 'send-to-smolder'
  86. push $P0, 'help|h'
  87. $P1 = $P0.'get_options'(argv)
  88. .return ($P1)
  89. .end
  90.  
  91. .sub '_get_common_tests' :anon
  92. .param pmc opts
  93. .const string runcore_tests = <<'TEST'
  94. t/compilers/imcc/*/*.t
  95. t/op/*.t
  96. t/pmc/*.t
  97. t/oo/*.t
  98. t/pir/*.t
  99. t/native_pbc/*.t
  100. TEST
  101. .const string core_tests = <<'TEST'
  102. t/src/*.t
  103. t/src/embed/*.t
  104. t/run/*.t
  105. t/perl/*.t
  106. TEST
  107. .const string library_tests = <<'TEST'
  108. t/compilers/pct/*.t
  109. t/compilers/pge/*.t
  110. t/compilers/pge/p5regex/*.t
  111. t/compilers/pge/perl6regex/*.t
  112. t/compilers/tge/*.t
  113. t/compilers/opsc/*.t
  114. t/compilers/data_json/*.t
  115. t/dynoplibs/*.t
  116. t/dynpmc/*.t
  117. t/library/*.t
  118. t/tools/*.t
  119. t/profiling/*.t
  120. TEST
  121. .const string configure_tests = <<'TEST'
  122. t/configure/*.t
  123. t/steps/*.t
  124. t/postconfigure/*.t
  125. TEST
  126. $S0 = runcore_tests
  127. $I0 = exists opts['runcore-tests']
  128. if $I0 goto L1
  129. $S0 .= core_tests
  130. $I0 = exists opts['core-tests']
  131. if $I0 goto L1
  132. $S0 .= library_tests
  133. $S0 .= configure_tests
  134. L1:
  135. $P0 = split "\n", $S0
  136. $S0 = join ' ', $P0
  137. $P0 = glob($S0)
  138. .return ($P0)
  139. .end
  140.  
  141. .sub run_tests
  142. .param pmc tests
  143. $I0 = 0
  144. $I1 = elements tests
  145. loop:
  146. if $I0 == $I1 goto endloop
  147.  
  148. $S0 = tests[$I0]
  149. $S2 = $S0 . ".mem"
  150.  
  151. $S1 = "valgrind -q --leak-check=full --log-file=" . $S2
  152. $S1 = $S1 . " ./parrot "
  153. $S1 = $S1 . $S0
  154.  
  155. say $S1
  156.  
  157. $P1 = new 'FileHandle'
  158. $P1.'open'($S1, 'rp')
  159. $S1 = $P1.'readall'()
  160. say $S1
  161.  
  162. $P1 = new 'FileHandle'
  163. $P1.'open'($S2, 'r')
  164. $S1 = $P1.'readall'()
  165. say $S1
  166.  
  167. inc $I0
  168. goto loop
  169. endloop:
  170. .end
Add Comment
Please, Sign In to add comment