# file      : tests/buildtab/testscript
# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
# license   : MIT; see accompanying LICENSE file

: valid
:
: Roundtrip buildtab.
:
{
  : all-fileds-combinations
  :
  $* <<EOI >>EOO
  windows*-vc_14* windows-vc_14-32 i686-microsoft-win32-msvc14.0 all
  windows*-vc_14* windows-vc_14-32-debug i686-microsoft-win32-msvc14.0 "" config.cc.coptions=/Z7 config.cc.loptions=/DEBUG ~"warning C4\d{3}: "

  linux_debian_8*-gcc_4.9 linux_debian_8-gcc_4.9    x86_64-linux-gnu "all default linux gcc           gcc-4+:gcc-3+"
  -                       -                         -                                                 gcc-5+:gcc-4+
  -                       -                         -                                                 gcc-6+:gcc-5+
  linux_debian_9*-gcc_7.3 linux_debian_9-gcc_7.3    x86_64-linux-gnu "all default linux gcc           gcc-7+:gcc-6+"
  linux_debian_9*-gcc_7.3 linux_debian_9-gcc_7.3-O3 x86_64-linux-gnu "all default linux gcc optimized gcc-7+" config.cc.coptions=-O3
  linux_debian_9*-gcc_8.1 linux_debian_9-gcc_8.1    x86_64-linux-gnu "all default linux gcc           gcc-8+:gcc-7+"
  EOI
  windows*-vc_14* windows-vc_14-32 i686-microsoft-win32-msvc14.0 all
  windows*-vc_14* windows-vc_14-32-debug i686-microsoft-win32-msvc14.0 "" config.cc.coptions=/Z7 config.cc.loptions=/DEBUG ~"warning C4\d{3}: "
  linux_debian_8*-gcc_4.9 linux_debian_8-gcc_4.9 x86_64-linux-gnu "all default linux gcc gcc-4+:gcc-3+"
  linux_debian_9*-gcc_7.3 linux_debian_9-gcc_7.3 x86_64-linux-gnu "all default linux gcc gcc-7+:gcc-6+"
  linux_debian_9*-gcc_7.3 linux_debian_9-gcc_7.3-O3 x86_64-linux-gnu "all default linux gcc optimized gcc-7+:gcc-6+" config.cc.coptions=-O3
  linux_debian_9*-gcc_8.1 linux_debian_9-gcc_8.1 x86_64-linux-gnu "all default linux gcc gcc-8+:gcc-7+"
  EOO

  : empty-lines
  :
  $* <<EOI >>EOO

  windows*-vc_14* windows-vc_14-32-debug i686-microsoft-win32-msvc14.0 default
   # abc
  EOI
  windows*-vc_14* windows-vc_14-32-debug i686-microsoft-win32-msvc14.0 default
  EOO
}

: parse-errors
:
{
  : name
  :
  {
    : none
    :
    $* <<EOI 2>>EOE == 1
      windows*-vc_14*
      EOI
      cin:1:16: error: no configuration name found
      EOE

    : dup
    :
    $* <<EOI 2>'cin:2:17: error: duplicate configuration name' == 1
      windows*-vc_14* windows-vc_14-32 i686-microsoft-win32-msvc14.0 default
      windows*-vc_14* windows-vc_14-32 i686-microsoft-win32-msvc14.0 default
      EOI
  }

  : target
  :
  {
    : none
    :
    $* <<EOI 2>>EOE == 1
      windows*-vc_14* windows-vc_14-32
      EOI
      cin:1:33: error: no target found
      EOE

    : invalid
    :
    $* <<EOI 2>>EOE == 1
      windows*-vc_14* windows-vc_14-32 microsoft
      EOI
      cin:1:34: error: missing cpu
      EOE
  }

  : class
  :
  {
    : invalid
    :
    $* <<EOI 2>>EOE == 1
      windows*-vc_14* windows-vc_14-32 i686-microsoft-win32-msvc14.0 a=b
      EOI
      cin:1:64: error: class name 'a=b' contains '='
      EOE

    : none
    :
    $* <<EOI 2>>EOE == 1
      windows*-vc_14* windows-vc_14-32 i686-microsoft-win32-msvc14.0 none
      EOI
      cin:1:64: error: class 'none' is reserved
      EOE

    : self-inheritance
    :
    $* <<EOI 2>>EOE == 1
      windows*-vc_14* windows-vc_14-O i686-microsoft-win32-msvc14.0 "msvc-14+:msvc-14+"
      EOI
      cin:1:63: error: inheritance cycle in 'msvc-14+' class inheritance
      EOE

    : inheritance-cycle
    :
    $* <<EOI 2>>EOE == 1
      windows*-vc_14* windows-vc_14-32 i686-microsoft-win32-msvc14.0 msvc-14+:msvc-13+
      windows*-vc_13* windows-vc_13-32 i686-microsoft-win32-msvc13.0 msvc-13+:msvc-14+
      EOI
      cin:2:64: error: inheritance cycle in 'msvc-13+' class inheritance
      EOE

    : base-mismatch
    :
    $* <<EOI 2>>EOE == 1
      windows*-vc_12* windows-vc_12   i686-microsoft-win32-msvc12.0  msvc-12+
      windows*-vc_13* windows-vc_13   i686-microsoft-win32-msvc13.0  msvc-13+:msvc-12+
      windows*-vc_14* windows-vc_14   i686-microsoft-win32-msvc14.0  msvc-14+:msvc-13+
      windows*-vc_14* windows-vc_14-O i686-microsoft-win32-msvc14.0 "msvc-14+:msvc-12+ optimized"
      EOI
      cin:4:63: error: 'msvc-14+' new base 'msvc-12+' does not match existing 'msvc-13+'
      EOE

    : base-mismatch-nobase
    :
    $* <<EOI 2>>EOE == 1
      windows*-vc_12* windows-vc_12   i686-microsoft-win32-msvc12.0  msvc-12+
      windows*-vc_13* windows-vc_13   i686-microsoft-win32-msvc13.0  msvc-13+:msvc-12+
      windows*-vc_14* windows-vc_14   i686-microsoft-win32-msvc14.0  msvc-14+
      windows*-vc_14* windows-vc_14-O i686-microsoft-win32-msvc14.0 "msvc-14+:msvc-13+ optimized"
      EOI
      cin:4:63: error: 'msvc-14+' new base 'msvc-13+' does not match existing ''
      EOE
  }

  : var
  :
  {
    : invalid
    :
    {
      : unquoted
      :
      $* <<EOI 2>>EOE == 1
        windows*-vc_14* windows-vc_14-32 i686-microsoft-win32-msvc14.0 default config.cc.coptions="/Z7
        EOI
        cin:1:95: error: unterminated quoted string
        EOE
    }
  }
}