# file      : tests/overrides/testscript
# license   : MIT; see accompanying LICENSE file

: valid
:
{
  : build-email
  :
  $* 'build-email: bar@example.com' <<EOI >>EOO
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    build-email: foo@example.com
    build-error-email: error@example.com
    build-warning-email: warning@example.com
    EOI
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    build-email: bar@example.com
    EOO

  : builds
  :
  $* 'builds: gcc' <<EOI >>EOO
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    builds: default
    build-include: linux*
    build-exclude: *; Only supports Linux.
    network-build-config: config.libfoo.network=true
    network-builds: default
    network-build-include: linux*
    network-build-exclude: *
    EOI
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    builds: gcc
    network-build-config: config.libfoo.network=true
    EOO

  : build-include-exclude
  :
  $* 'build-include: linux*' 'build-exclude: *; Only supports Linux.' <<EOI >>EOO
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    builds: default
    build-exclude: freebsd*
    network-build-config: config.libfoo.network=true
    network-builds: default
    network-build-include: linux*
    network-build-exclude: *
    EOI
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    builds: default
    build-include: linux*
    build-exclude: *; Only supports Linux.
    network-build-config: config.libfoo.network=true
    EOO

  : builds-build-include-exclude
  :
  $* 'build-include: linux*' 'build-exclude: *; Only supports Linux.' 'builds: all' <<EOI >>EOO
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    builds: default
    build-exclude: windows; Only supports POSIX.
    EOI
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    builds: all
    build-include: linux*
    build-exclude: *; Only supports Linux.
    EOO

  : build-configs
  :
  $* 'network-builds: all' 'network-build-include: windows*' 'network-build-exclude: *' \
     'cache-build-include: freebsd*' 'cache-build-exclude: *' 'cache-builds: legacy' \
       'cache-build-config: config.libfoo.cache=true config.libfoo.buffer=1028' \
     'deprecated-api-build-config: config.libfoo.deprecated_api=true' 'deprecated-api-builds: windows' \
     'experimental-api-build-config: config.libfoo.experimental_api=true' \
     'sys-build-include: linux*' 'sys-build-exclude: *' \
     'fancy-builds: gcc' <<EOI >>EOO
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    builds: all
    build-include: linux*
    build-include: macos*
    build-include: freebsd*
    build-exclude: *
    network-build-config: config.libfoo.network=true
    network-builds: default
    network-build-include: linux*
    network-build-exclude: *
    cache-build-config: config.libfoo.cache=true
    cache-builds: default
    cache-build-include: macos*
    cache-build-exclude: *
    sys-build-config: ?sys:libcrypto
    sys-builds: default
    sys-build-include: freebsd*
    sys-build-exclude: *
    older-build-config: ?libbar/1.0.0
    older-builds: default
    older-build-include: windows*
    older-build-exclude: *
    fancy-build-config: config.libfoo.fancy=true
    fancy-builds: default
    fancy-build-include: windows*
    fancy-build-exclude: *
    EOI
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    builds: all
    build-include: linux*
    build-include: macos*
    build-include: freebsd*
    build-exclude: *
    default-builds: none
    network-build-config: config.libfoo.network=true
    network-builds: all
    network-build-include: windows*
    network-build-exclude: *
    cache-build-config: config.libfoo.cache=true config.libfoo.buffer=1028
    cache-builds: legacy
    cache-build-include: freebsd*
    cache-build-exclude: *
    sys-build-config: ?sys:libcrypto
    sys-builds: default
    sys-build-include: linux*
    sys-build-exclude: *
    older-build-config: ?libbar/1.0.0
    older-builds: none
    fancy-build-config: config.libfoo.fancy=true
    fancy-builds: gcc
    deprecated-api-build-config: config.libfoo.deprecated_api=true
    deprecated-api-builds: windows
    experimental-api-build-config: config.libfoo.experimental_api=true
    experimental-api-builds: none
    EOO

  : build-config-default
  :
  $* 'default-builds: all' 'default-build-include: windows*' 'default-build-exclude: *' <<EOI >>EOO
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    network-build-config: config.libfoo.network=true
    network-builds: all
    EOI
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    default-builds: all
    default-build-include: windows*
    default-build-exclude: *
    network-build-config: config.libfoo.network=true
    network-builds: none
    EOO

  : add-build-config
  :
  $* 'experimental-api-build-config: config.libfoo.experimental_api=true' <<EOI >>EOO
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    network-build-config: config.libfoo.network=true
    network-builds: all
    EOI
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    network-build-config: config.libfoo.network=true
    network-builds: all
    experimental-api-build-config: config.libfoo.experimental_api=true
    EOO

  : none
  :
  $* <<EOI >>EOO
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    build-email: foo@example.com
    EOI
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    build-email: foo@example.com
    EOO
}

: invalid
:
{
  : forbidden
  :
  $* 'name: libbar' <<EOI 2>"cannot override 'name' value" != 0
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    EOI

  : bad-value
  :
  $* 'builds: all' 'builds: default : -windows' <<EOI 2>>EOE != 0
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    EOI
    invalid package builds in 'default : -windows': unexpected underlying class set
    EOE

  : stream-name-specified
  :
  $* -n 'builds: all' 'builds: default : -windows' <<EOI 2>>EOE != 0
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    EOI
    args:2:8: error: invalid package builds: unexpected underlying class set
    EOE


  : no-build-config
  :
  $* 'network-builds: default' <<EOI 2>>EOE != 0
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    EOI
    cannot override 'network-builds' value: no build package configuration 'network'
    EOE

  : config-builds-after-builds
  :
  $* 'builds: all' 'network-builds: default' <<EOI 2>>EOE != 0
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    network-build-config: config.libfoo.network=true
    EOI
    'network-builds' override specified together with 'builds' override
    EOE

  : config-builds-after-build-exclude
  :
  $* 'build-exclude: *' 'network-builds: default' <<EOI 2>>EOE != 0
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    network-build-config: config.libfoo.network=true
    EOI
    'network-builds' override specified together with 'build-exclude' override
    EOE

  : builds-after-config-builds
  :
  $* 'network-builds: default' 'builds: all' <<EOI 2>>EOE != 0
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    network-build-config: config.libfoo.network=true
    EOI
    'builds' override specified together with 'network-builds' override
    EOE

  : build-exclude-after-config-builds
  :
  $* 'network-builds: default' 'build-exclude: *' <<EOI 2>>EOE != 0
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    network-build-config: config.libfoo.network=true
    EOI
    'build-exclude' override specified together with 'network-builds' override
    EOE

  : build-config-after-config-builds
  :
  $* 'deprecated-api-builds: windows' 'deprecated-api-build-config: config.libfoo.deprecated-api=true' <<EOI 2>>EOE != 0
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    EOI
    cannot override 'deprecated-api-builds' value: no build package configuration 'deprecated-api'
    EOE
}
