# 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
    network-build-config: config.libfoo.network=true
    network-build-email: network-foo@example.com
    network-build-error-email: network-error@example.com
    network-build-warning-email: network-warning@example.com
    EOI
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    build-email: bar@example.com
    network-build-config: config.libfoo.network=true
    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: *' \
     'network-build-warning-email: network-warning@example.com' 'sys-build-email:' \
     'cache-build-error-email: cache-error@example.com' \
     '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
    build-email: foo@example.com
    build-error-email: error@example.com
    build-warning-email: warning@example.com
    builds: all
    build-include: linux*
    build-include: macos*
    build-include: freebsd*
    build-exclude: *
    network-builds: default
    network-build-include: linux*
    network-build-exclude: *
    network-build-config: config.libfoo.network=true
    network-build-error-email: network-error@example.com
    cache-builds: default
    cache-build-include: macos*
    cache-build-exclude: *
    cache-build-config: config.libfoo.cache=true
    cache-build-email: cache@example.com
    sys-builds: default
    sys-build-include: freebsd*
    sys-build-exclude: *
    sys-build-config: ?sys:libcrypto
    sys-build-email: sys@example.com
    older-builds: default
    older-build-include: windows*
    older-build-exclude: *
    older-build-config: ?libbar/1.0.0
    fancy-builds: default
    fancy-build-include: windows*
    fancy-build-exclude: *
    fancy-build-config: config.libfoo.fancy=true
    EOI
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    build-email: foo@example.com
    build-warning-email: warning@example.com
    build-error-email: error@example.com
    builds: all
    build-include: linux*
    build-include: macos*
    build-include: freebsd*
    build-exclude: *
    default-builds: none
    default-build-email:
    network-builds: all
    network-build-include: windows*
    network-build-exclude: *
    network-build-config: config.libfoo.network=true
    network-build-warning-email: network-warning@example.com
    cache-builds: legacy
    cache-build-include: freebsd*
    cache-build-exclude: *
    cache-build-config: config.libfoo.cache=true config.libfoo.buffer=1028
    cache-build-error-email: cache-error@example.com
    sys-builds: default
    sys-build-include: linux*
    sys-build-exclude: *
    sys-build-config: ?sys:libcrypto
    sys-build-email:
    older-builds: none
    older-build-config: ?libbar/1.0.0
    older-build-email:
    fancy-builds: gcc
    fancy-build-config: config.libfoo.fancy=true
    fancy-build-email:
    deprecated-api-builds: windows
    deprecated-api-build-config: config.libfoo.deprecated_api=true
    deprecated-api-build-email:
    experimental-api-builds: none
    experimental-api-build-config: config.libfoo.experimental_api=true
    experimental-api-build-email:
    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-builds: all
    network-build-config: config.libfoo.network=true
    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-builds: none
    network-build-config: config.libfoo.network=true
    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-builds: all
    network-build-config: config.libfoo.network=true
    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

  : build-auxiliary
  :
  {
    : named
    :
    $* 'build-auxiliary-pgsql: *-postgresql**' \
       'foo-build-auxiliary-oracle: *-oracle**' <<EOI >>EOO
      : 1
      name: libfoo
      version: 2.0.0
      summary: Modern C++ parser
      license: LGPLv2
      build-auxiliary-pgsql: *-postgresql_*
      build-auxiliary-mysql: *-mysql_*
      foo-build-auxiliary-mssql: *-mssql_*
      foo-build-auxiliary-oracle: *-oracle_*
      EOI
      : 1
      name: libfoo
      version: 2.0.0
      summary: Modern C++ parser
      license: LGPLv2
      build-auxiliary-pgsql: *-postgresql**
      build-auxiliary-mysql: *-mysql_*
      foo-build-auxiliary-mssql: *-mssql_*
      foo-build-auxiliary-oracle: *-oracle**
      EOO

    : unnamed
    :
    $* 'build-auxiliary: *-postgresql**' \
       'foo-build-auxiliary: *-oracle**' <<EOI >>EOO
      : 1
      name: libfoo
      version: 2.0.0
      summary: Modern C++ parser
      license: LGPLv2
      build-auxiliary: *-postgresql_*
      foo-build-auxiliary: *-oracle_*
      EOI
      : 1
      name: libfoo
      version: 2.0.0
      summary: Modern C++ parser
      license: LGPLv2
      build-auxiliary: *-postgresql**
      foo-build-auxiliary: *-oracle**
      EOO

    : new-config
    :
    $* 'bar-build-config:' \
       'bar-build-auxiliary-mysql: *-mysql_8' \
       'bar-build-auxiliary-pgsql: *-postgresql_16' <<EOI >>EOO
      : 1
      name: libfoo
      version: 2.0.0
      summary: Modern C++ parser
      license: LGPLv2
      build-auxiliary-pgsql: *-postgresql_*
      build-auxiliary-mssql: *-mssql_*
      foo-build-auxiliary-mysql: *-mysql_*
      foo-build-auxiliary-oracle: *-oracle_*
      EOI
      : 1
      name: libfoo
      version: 2.0.0
      summary: Modern C++ parser
      license: LGPLv2
      build-auxiliary-pgsql: *-postgresql_*
      build-auxiliary-mssql: *-mssql_*
      foo-build-auxiliary-mysql: *-mysql_*
      foo-build-auxiliary-oracle: *-oracle_*
      bar-build-auxiliary-mysql: *-mysql_8
      bar-build-auxiliary-pgsql: *-postgresql_16
      EOO
  }

  : build-bot
  :
  {
    : common
    :
    $* 'build-bot: key3' 'build-bot: key4' <<EOI >>EOO
      : 1
      name: libfoo
      version: 2.0.0
      summary: Modern C++ parser
      license: LGPLv2
      build-bot: key1
      foo-build-bot: key2
      EOI
      : 1
      name: libfoo
      version: 2.0.0
      summary: Modern C++ parser
      license: LGPLv2
      build-bot: key3
      build-bot: key4
      EOO

    : config
    :
    $* 'foo-build-bot: key3' 'foo-build-bot: key4' <<EOI >>EOO
      : 1
      name: libfoo
      version: 2.0.0
      summary: Modern C++ parser
      license: LGPLv2
      build-bot: key1
      foo-build-bot: key2
      EOI
      : 1
      name: libfoo
      version: 2.0.0
      summary: Modern C++ parser
      license: LGPLv2
      build-bot: key1
      foo-build-bot: key3
      foo-build-bot: key4
      EOO

    : new-config
    :
    $* 'bar-build-config:' \
       'bar-build-bot: key1' \
       'bar-build-bot: key2' <<EOI >>EOO
      : 1
      name: libfoo
      version: 2.0.0
      summary: Modern C++ parser
      license: LGPLv2
      build-bot: key1
      foo-build-bot: key2
      EOI
      : 1
      name: libfoo
      version: 2.0.0
      summary: Modern C++ parser
      license: LGPLv2
      build-bot: key1
      foo-build-bot: key2
      bar-build-bot: key1
      bar-build-bot: key2
      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

  : config-bot-after-built-bot
  :
  $* 'build-bot: key1' 'foo-build-bot: key2' <<EOI 2>>EOE != 0
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    foo-build-config:
    EOI
    'foo-build-bot' override specified together with 'build-bot' override
    EOE

  : built-bot-after-config-bot
  :
  $* 'foo-build-bot: key1' 'build-bot: key2' <<EOI 2>>EOE != 0
    : 1
    name: libfoo
    version: 2.0.0
    summary: Modern C++ parser
    license: LGPLv2
    foo-build-config:
    EOI
    'build-bot' override specified together with 'foo-build-bot' override
    EOE

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

  : config-email-after-email
  :
  $* 'build-email: foo@example.com' 'network-build-warning-email: warning@example.com' <<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-build-warning-email' override specified together with 'build-email' override
    EOE

  : email-after-config-email
  :
  $* 'network-build-warning-email: warning@example.com' 'build-email: foo@example.com' <<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-email' override specified together with 'network-build-warning-email' override
    EOE

  : build-auxiliary
  :
  {
    : named-common
    :
    $* 'build-auxiliary-mysql: *-mysql_*' <<EOI 2>>EOE != 0
      : 1
      name: libfoo
      version: 2.0.0
      summary: Modern C++ parser
      license: LGPLv2
      build-auxiliary-pgsql: *-postgresql_*
      foo-build-auxiliary-mssql: *-mssql_*
      foo-build-auxiliary-oracle: *-oracle_*
      EOI
      no match for 'build-auxiliary-mysql' value override
      EOE

    : named-config1
    :
    $* 'foo-build-auxiliary-mysql: *-mysql_*' <<EOI 2>>EOE != 0
      : 1
      name: libfoo
      version: 2.0.0
      summary: Modern C++ parser
      license: LGPLv2
      build-auxiliary-pgsql: *-postgresql_*
      foo-build-auxiliary-mssql: *-mssql_*
      foo-build-auxiliary-oracle: *-oracle_*
      EOI
      no match for 'foo-build-auxiliary-mysql' value override
      EOE

    : named-config2
    :
    $* 'bar-build-auxiliary-oracle: *-oracle**' <<EOI 2>>EOE != 0
      : 1
      name: libfoo
      version: 2.0.0
      summary: Modern C++ parser
      license: LGPLv2
      build-auxiliary-pgsql: *-postgresql_*
      foo-build-auxiliary-mssql: *-mssql_*
      foo-build-auxiliary-oracle: *-oracle_*
      EOI
      cannot override 'bar-build-auxiliary-oracle' value: no build package configuration 'bar'
      EOE

    : unnamed-common
    :
    $* 'build-auxiliary-mysql: *-mysql_*' <<EOI 2>>EOE != 0
      : 1
      name: libfoo
      version: 2.0.0
      summary: Modern C++ parser
      license: LGPLv2
      build-auxiliary: *-postgresql_*
      foo-build-auxiliary: *-oracle_*
      EOI
      no match for 'build-auxiliary-mysql' value override
      EOE

    : unnamed-config1
    :
    $* 'foo-build-auxiliary-mysql: *-mysql_*' <<EOI 2>>EOE != 0
      : 1
      name: libfoo
      version: 2.0.0
      summary: Modern C++ parser
      license: LGPLv2
      build-auxiliary: *-postgresql_*
      foo-build-auxiliary: *-oracle_*
      EOI
      no match for 'foo-build-auxiliary-mysql' value override
      EOE

    : unnamed-config2
    :
    $* 'bar-build-auxiliary: *-mysql_*' <<EOI 2>>EOE != 0
      : 1
      name: libfoo
      version: 2.0.0
      summary: Modern C++ parser
      license: LGPLv2
      build-auxiliary: *-postgresql_*
      foo-build-auxiliary: *-oracle_*
      EOI
      cannot override 'bar-build-auxiliary' value: no build package configuration 'bar'
      EOE
  }
}
