environment:
  CTEST_OUTPUT_ON_FAILURE: 1
  matrix:
  - Compiler: mingw
    Build: static
    ruby_version: "21-x64"
  - Compiler: mingw
    Build: shared
    ruby_version: "21-x64"
  - Compiler: msvc
    Config: Release
    ruby_version: "21-x64"
  - Compiler: msvc
    Config: Debug
    ruby_version: "21-x64"

cache:
  - x86_64-4.9.2-release-win32-seh-rt_v3-rev0.7z
  - C:\Ruby21-x64\lib\ruby\gems\2.1.0
  - C:\Ruby21-x64\bin

install:
  - git clone https://github.com/sass/sassc.git
  - git clone https://github.com/sass/sass-spec.git
  - set PATH=C:\Ruby%ruby_version%\bin;%PATH%
  - set SASS_LIBSASS_PATH=..
  - gem install minitest
  - ps: |
      if ($env:Compiler -eq "mingw") {
        if (-Not (Test-Path "x86_64-4.9.2-release-win32-seh-rt_v3-rev0.7z")) {
          # Install MinGW.
          $url  = "http://sourceforge.net/projects/mingw-w64/files/"
          $url += "Toolchains%20targetting%20Win64/Personal%20Builds/"
          $url += "mingw-builds/4.9.2/threads-win32/seh/"
          $url += "x86_64-4.9.2-release-win32-seh-rt_v3-rev0.7z/download"
          Invoke-WebRequest -UserAgent wget -Uri $url -OutFile x86_64-4.9.2-release-win32-seh-rt_v3-rev0.7z
        }
        &7z x -oC:\ x86_64-4.9.2-release-win32-seh-rt_v3-rev0.7z > $null
      }
  - set PATH=C:\mingw64\bin;%PATH%
  - set CC=gcc

build_script:
  - ps: |
      if ($env:Compiler -eq "mingw") {
        mingw32-make -j4 sassc
      } else {
        msbuild /m:4 /p:Configuration=$env:Config win\libsass.sln
      }
  - ps: |
      if ($env:Compiler -eq "mingw") {
        sassc\bin\sassc.exe -v
        ruby -v
      } else {
        if ($env:Config -eq "Debug") {
          win\bin\Debug\sassc.exe -v
          ruby -v
        } else {
          win\bin\sassc.exe -v
          ruby -v
        }
      }

test_script:
  - ps: |
      if ($env:Compiler -eq "mingw") {
        ruby sass-spec\sass-spec.rb -c sassc\bin\sassc.exe -s --ignore-todo sass-spec/spec
      } else {
        if ($env:Config -eq "Debug") {
          echo test runner in debug mode build via msvc will throw debug assertions
          echo ruby sass-spec\sass-spec.rb -c win\bin\Debug\sassc.exe -s --ignore-todo sass-spec/spec
        } else {
          ruby sass-spec\sass-spec.rb -c win\bin\sassc.exe -s --ignore-todo sass-spec/spec
        }
      }

