|
| 1 | +unit sub MAIN( |
| 2 | + :a($author), |
| 3 | + :i($install), |
| 4 | + :$rmd, |
| 5 | + :$disable-spesh, |
| 6 | + :$disable-spesh-inline, |
| 7 | + :$disable-JIT, |
| 8 | + :$enable-spesh-nodelay, |
| 9 | + :$enable-spesh-blocking, |
| 10 | + :$enable-spesh-log, |
| 11 | +); |
| 12 | + |
| 13 | +say run(<raku --version>, :out).out.slurp.chomp; |
| 14 | +say "Running on $*DISTRO.gist().\n"; |
| 15 | + |
| 16 | +if $rmd { |
| 17 | + %*ENV<RAKUDO_MODULE_DEBUG> := 1; |
| 18 | + say "RAKUDO_MODULE_DEBUG=1"; |
| 19 | +} |
| 20 | + |
| 21 | +if $disable-spesh { |
| 22 | + %*ENV<MVM_SPESH_DISABLE> := 1; |
| 23 | + say "MVM_SPESH_DISABLE=1"; |
| 24 | +} |
| 25 | + |
| 26 | +if $disable-spesh-inline { |
| 27 | + %*ENV<MVM_SPESH_INLINE_DISABLE> := 1; |
| 28 | + say "MVM_SPESH_INLINE_DISABLE=1"; |
| 29 | +} |
| 30 | + |
| 31 | +if $disable-JIT { |
| 32 | + %*ENV<MVM_JIT_DISABLE> := 1; |
| 33 | + say "MVM_JIT_DISABLE=1"; |
| 34 | +} |
| 35 | + |
| 36 | +if $enable-spesh-nodelay { |
| 37 | + %*ENV<MVM_SPESH_NODELAY> := 1; |
| 38 | + say "MVM_SPESH_NODELAY=1"; |
| 39 | +} |
| 40 | + |
| 41 | +if $enable-spesh-blocking { |
| 42 | + %*ENV<MVM_SPESH_BLOCKING> := 1; |
| 43 | + say "MVM_SPESH_BLOCKING=1"; |
| 44 | +} |
| 45 | + |
| 46 | +my $spesh-log; |
| 47 | +if $enable-spesh-log { |
| 48 | + $spesh-log = ( |
| 49 | + $enable-spesh-log ~~ Bool ?? "spesh-log" !! $enable-spesh-log |
| 50 | + ).IO; |
| 51 | + %*ENV<MVM_SPESH_LOG> := $spesh-log.absolute; |
| 52 | + say "MVM_SPESH_LOG=$spesh-log.relative()"; |
| 53 | +} |
| 54 | + |
| 55 | +say "" |
| 56 | + if $rmd |
| 57 | + || $disable-spesh |
| 58 | + || $disable-spesh-inline |
| 59 | + || $disable-JIT |
| 60 | + || $enable-spesh-nodelay |
| 61 | + || $enable-spesh-blocking |
| 62 | + || $enable-spesh-log; |
| 63 | + |
| 64 | +say "Testing { |
| 65 | + (try "dist.ini".IO.lines.head.substr(7)) // "..." |
| 66 | +}{ |
| 67 | + " including author tests" if $author |
| 68 | +}"; |
| 69 | + |
| 70 | +my @failed; |
| 71 | +my $done = 0; |
| 72 | + |
| 73 | +sub process($proc, $filename) { |
| 74 | + if $proc { |
| 75 | + $proc.out.slurp; |
| 76 | + $spesh-log.unlink if $spesh-log; |
| 77 | + } |
| 78 | + else { |
| 79 | + @failed.push($filename); |
| 80 | + if $proc.out.slurp -> $stdout { |
| 81 | + my @lines = $stdout.lines; |
| 82 | + with @lines.first( |
| 83 | + *.starts-with(" from gen/moar/stage2"),:k) |
| 84 | + -> $index { |
| 85 | + say @lines[^$index].join("\n"); |
| 86 | + } |
| 87 | + else { |
| 88 | + say $stdout; |
| 89 | + } |
| 90 | + } |
| 91 | + else { |
| 92 | + say "No output received, exit-code $proc.exitcode() ($proc.signal()):\n$proc.os-error()"; |
| 93 | + } |
| 94 | + |
| 95 | + if $spesh-log { |
| 96 | + say "\nSpesh log requested, showing last 20000 lines:"; |
| 97 | + say $spesh-log.lines(:!chomp).tail(20000).join; |
| 98 | + $spesh-log.unlink; |
| 99 | + } |
| 100 | + } |
| 101 | +} |
| 102 | + |
| 103 | +sub install() { |
| 104 | + my $zef := $*DISTRO.is-win ?? 'zef.bat' !! 'zef'; |
| 105 | + my $proc := run $zef, "install", ".", "--verbose", "--/test", :out,:err,:merge; |
| 106 | + process($proc, "*installation*"); |
| 107 | +} |
| 108 | + |
| 109 | +sub test-dir($dir) { |
| 110 | + for $dir.IO.dir(:test(*.ends-with: '.t' | '.rakutest')).map(*.Str).sort { |
| 111 | + say "=== $_"; |
| 112 | + my $proc := run "raku", "--ll-exception", "-I.", $_, :out,:err,:merge; |
| 113 | + process($proc, $_); |
| 114 | + $done++; |
| 115 | + } |
| 116 | +} |
| 117 | + |
| 118 | +test-dir("t"); |
| 119 | +test-dir($_) for dir("t", :test({ !.starts-with(".") && "t/$_".IO.d})).map(*.Str).sort; |
| 120 | +test-dir("xt") if $author && "xt".IO.e; |
| 121 | +if $install { |
| 122 | + install; |
| 123 | + ++$done; |
| 124 | +} |
| 125 | + |
| 126 | +if @failed { |
| 127 | + say "\nFAILED: {+@failed} of $done:"; |
| 128 | + say " $_" for @failed; |
| 129 | + exit +@failed; |
| 130 | +} |
| 131 | + |
| 132 | +say "\nALL {"$done " if $done > 1}OK"; |
| 133 | + |
| 134 | +# vim: expandtab shiftwidth=4 |
0 commit comments