# file      : tests/test/script/runner/status.testscript
# license   : MIT; see accompanying LICENSE file

.include ../common.testscript

b += --no-column

: eq
:
{{
  : true
  :
  $c <<EOI && $b
  $* == 0
  EOI

  : false
  :
  $c <<EOI && $b 2>>/~%EOE%d != 0
  $* -s 1 == 0
  EOI
  %testscript:1: error: process ../../../../driver(.exe)? exit code 1, expected 0%
    info: test id: 1
  EOE
}}

: ne
:
{{
  : true
  :
  $c <<EOI && $b
  $* -s 1 != 0
  EOI

  : false
  :
  $c <<EOI && $b 2>>/~%EOE% != 0
  $* -s 1 != 1
  EOI
  %testscript:1: error: process ../../../../driver(.exe)? exit code 1, expected not 1%
    info: test id: 1
  EOE
}}

: error
:
$c <<EOI && $b 2>>/~%EOE% != 0
$* -s 1 -e "Error"
EOI
%testscript:1: error: process ../../../driver(.exe)? exited with code 1%
  info: stderr: test/1/stderr
Error
  info: test id: 1
EOE

: error-check
:
$c <<EOI && $b 2>>/~%EOE% != 0
$* -s 1 -e "Error" == 0
EOI
%testscript:1: error: process ../../../driver(.exe)? exit code 1, expected 0%
  info: stderr: test/1/stderr
Error
  info: test id: 1
EOE

#\
: segmentation-fault
:
: Can pop up dialog boxes on Windows or produce coredump on POSIX. Note that
: under Wine some extra info is printed to STDOUT.
:
$c <<EOI && $b 2>>/~%EOE% != 0
$* -t m
EOI
%wine: .+%?
%testscript:1: error: ../../../driver(.exe)? terminated abnormally%d
%  info: .+%
%  info: stdout: test\\1\\stdout%?
EOE
#\

: syntax-1
:
{{
  b = [cmdline] $regex.apply($b, '(.+testscript.syntax).+', "\1 = 1'")

  : eq
  :
  {{
    : true
    :
    $c <'$* == 0' && $b

    : false
    :
    $c <'$* -s 1 == 0' && $b 2>>/~%EOE%d != 0
    %testscript:1: error: process ../../../../../driver(.exe)? exit code 1, expected 0%
      info: test id: 1
    EOE
  }}

  : ne
  :
  {{
    : true
    :
    $c <'$* -s 1 != 0' && $b

    : false
    :
    $c <'$* -s 1 != 1' && $b 2>>/~%EOE% != 0
    %testscript:1: error: process ../../../../../driver(.exe)? exit code 1, expected not 1%
      info: test id: 1
    EOE
  }}

  : error
  :
  $c <'$* -s 1 -e "Error"' && $b 2>>/~%EOE% != 0
  %testscript:1: error: process ../../../../driver(.exe)? exited with code 1%
    info: stderr: test/1/stderr
  Error
    info: test id: 1
  EOE

  : error-check
  :
  $c <'$* -s 1 -e "Error" == 0' && $b 2>>/~%EOE% != 0
  %testscript:1: error: process ../../../../driver(.exe)? exit code 1, expected 0%
    info: stderr: test/1/stderr
  Error
    info: test id: 1
  EOE

  #\
  : segmentation-fault
  :
  : Can pop up dialog boxes on Windows or produce coredump on POSIX. Note that
  : under Wine some extra info is printed to STDOUT.
  :
  $c <'$* -t m' && $b 2>>/~%EOE% != 0
  %wine: .+%?
  %testscript:1: error: ../../../driver(.exe)? terminated abnormally%d
  %  info: .+%
  %  info: stdout: test\\1\\stdout%?
  EOE
  #\
}}
