# file      : tests/manifest/result.test
# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
# license   : MIT; see accompanying LICENSE file

test.options += -r

: valid
:
: Roundtrip the result manifest.
:
{
  : test-error
  :
  $* <<EOF >>EOF
  : 1
  name: libfoo
  version: 1.0
  status: error
  configure-status: success
  update-status: warning
  test-status: error
  configure-log: \
  conf line 1
  conf line 2
  \
  update-log: \
  update line 1
  update line 2
  \
  test-log: \
  test line 1
  test line 2
  \
  EOF

  : update-error
  :
  $* <<EOF >>EOF
  : 1
  name: libfoo
  version: 1.0
  status: error
  configure-status: warning
  update-status: error
  configure-log: \
  conf line 1
  conf line 2
  \
  update-log: \
  update line 1
  update line 2
  \
  EOF

  : early-abort
  :
  $* <<EOF >>EOF
  : 1
  name: libfoo
  version: 1.0
  status: abort
  EOF
}

: redefinition
:
{
  : name
  :
  $* <<EOI 2>'stdin:3:1: error: result package name redefinition' == 1
  : 1
  name: libfoo
  name: libfoo
  EOI

  : version
  :
  $* <<EOI 2>'stdin:3:1: error: result package version redefinition' == 1
  : 1
  version: 1.0
  version: 1.0
  EOI

  : status
  :
  $* <<EOI 2>'stdin:3:1: error: result status redefinition' == 1
  : 1
  status: success
  status: error
  EOI

  : configure-status
  :
  $* <<EOI 2>'stdin:4:1: error: result configure-status redefinition' == 1
  : 1
  status: success
  configure-status: success
  configure-status: abnormal
  EOI

  : configure-log
  :
  $* <<EOI 2>'stdin:5:1: error: unexpected configure-log' == 1
  : 1
  status: success
  configure-status: success
  configure-log: configured
  configure-log: configured
  EOI
}

: invalid
:
{
  : name-empty
  :
  $* <<EOI 2>'stdin:2:6: error: invalid result package name: length is less than two characters' == 1
  : 1
  name:
  EOI

  : version
  :
  {
    : empty
    :
    $* <<EOI 2>'stdin:2:9: error: invalid result package version: unexpected end' == 1
    : 1
    version:
    EOI

    : release
    :
    $* <<EOI 2>'stdin:2:10: error: invalid result package version release' == 1
    : 1
    version: 1.2.3-
    EOI
  }

  : status
  :
  $* <<EOI 2>'stdin:2:9: error: invalid result status' == 1
  : 1
  status: alert
  EOI

  : configure-status
  :
  $* <<EOI 2>'stdin:3:19: error: invalid configure-status' == 1
  : 1
  status: abort
  configure-status: alert
  EOI

  : order
  :
  {
    : op-status-before-status
    :
    $* <<EOI 2>'stdin:2:1: error: result status must appear first' == 1
    : 1
    configure-status: success
    EOI

    : op-status-after-log
    :
    $* <<EOI 2>'stdin:5:1: error: update-status after operations logs' == 1
    : 1
    status: success
    configure-status: success
    configure-log: log
    update-status: error
    EOI

    : wrong-op-log
    :
    $* <<EOI 2>'stdin:5:1: error: configure-log is expected' == 1
    : 1
    status: success
    configure-status: success
    update-status: error
    update-log: log
    EOI
  }
}

: unknown-name
:
$* <<EOI 2>"stdin:2:1: error: unknown name 'full-logs' in result manifest" == 1
: 1
full-logs: log
EOI

: missed
:
{
  : name
  :
  $* <<EOI 2>'stdin:4:1: error: no result package name specified' == 1
  : 1
  version: 1.0
  status: success
  EOI

  : version
  :
  $* <<EOI 2>'stdin:4:1: error: no result package version specified' == 1
  : 1
  name: libfoo
  status: success
  EOI

  : status
  :
  $* <<EOI 2>'stdin:4:1: error: no result status specified' == 1
  : 1
  name: libfoo
  version: 1.0
  EOI

  : configure-log
  :
  $* <<EOI 2>'stdin:6:1: error: no result configure-log specified' == 1
  : 1
  name: libfoo
  version: 1.0
  status: error
  configure-status: error
  EOI
}