aboutsummaryrefslogtreecommitdiff
path: root/appveyor.yml
blob: 13be7fa4059b819871c8eb57b1c5056f1dc5d593 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
version: '{build}'

configuration:
  - Static Debug
  - Static Release
#  - Shared Debug
#  - Shared Release

platform:
  - x86
  - x64

environment:
  matrix:
    - compiler: msvc-12-seh
    - compiler: msvc-14-seh
    - compiler: gcc-4.9.2-posix
#    - compiler: gcc-4.8.4-posix

artifacts:
  - path: '_build/CMakeFiles/*.log'
    name: logs
  - path: '_build/Testing/**/*.xml'
    name: test_results

install:
  # derive some extra information
  - for /f "tokens=1-2" %%a in ("%configuration%") do (@set "linkage=%%a")
  - for /f "tokens=1-2" %%a in ("%configuration%") do (@set "variant=%%b")
  - if "%linkage%"=="Shared" (set shared=YES) else (set shared=NO)
  - for /f "tokens=1-3 delims=-" %%a in ("%compiler%") do (@set "compiler_name=%%a")
  - for /f "tokens=1-3 delims=-" %%a in ("%compiler%") do (@set "compiler_version=%%b")
  - for /f "tokens=1-3 delims=-" %%a in ("%compiler%") do (@set "compiler_threading=%%c")
  - if "%platform%"=="x64" (set arch=x86_64)
  - if "%platform%"=="x86" (set arch=i686)
  # download the specific version of MinGW
  - if "%compiler_name%"=="gcc" (for /f %%a in ('python mingw.py --quiet --version "%compiler_version%" --arch "%arch%" --threading "%compiler_threading%" --location "C:\mingw-builds"') do @set "compiler_path=%%a")

before_build:
  # Set up mingw commands
  - if "%compiler_name%"=="gcc" (set "generator=MinGW Makefiles")
  - if "%compiler_name%"=="gcc" (set "build=mingw32-make -j4")
  - if "%compiler_name%"=="gcc" (set "test=mingw32-make CTEST_OUTPUT_ON_FAILURE=1 test")
  # msvc specific commands
  - if "%compiler_name%"=="msvc" if "%compiler_version%"=="12" if "%platform%"=="x86" (set "generator=Visual Studio 12 2013")
  - if "%compiler_name%"=="msvc" if "%compiler_version%"=="12" if "%platform%"=="x64" (set "generator=Visual Studio 12 2013 Win64")
  - if "%compiler_name%"=="msvc" if "%compiler_version%"=="14" if "%platform%"=="x86" (set "generator=Visual Studio 14 2015")
  - if "%compiler_name%"=="msvc" if "%compiler_version%"=="14" if "%platform%"=="x64" (set "generator=Visual Studio 14 2015 Win64")
  - if "%compiler_name%"=="msvc" (set "build=cmake --build . --config %variant%")
  - if "%compiler_name%"=="msvc" (set "test=ctest -c Release -D CTEST_OUTPUT_ON_FAILURE:STRING=1")
  # add the compiler path if needed
  - if not "%compiler_path%"=="" (set "PATH=%PATH%;%compiler_path%")
  # git bash conflicts with MinGW makefiles
  - if "%generator%"=="MinGW Makefiles" (set "PATH=%PATH:C:\Program Files\Git\usr\bin;=%")

build_script:
- ps: |
    md _build -Force
    cd _build
    & cmake -G "$env:generator" "-DCMAKE_BUILD_TYPE=$env:variant" "-DBUILD_SHARED_LIBS=$env:shared" ..
    if ($LastExitCode -ne 0) {
        throw "Exec: $ErrorMessage"
    }
    iex "& $env:build"
    if ($LastExitCode -ne 0) {
        throw "Exec: $ErrorMessage"
    }

test_script:
- ps: |
    iex "& $env:test"
    if ($LastExitCode -ne 0) {
        throw "Exec: $ErrorMessage"
    }

    function Add-CTest-Result($testResult)
    {
        $tests = ([xml](get-content $testResult)).Site.Testing
        $testsCount = 0
        $anyFailures = $FALSE

        foreach ($test in $tests.test) {
            $testsCount++
            $testName = $test.Name
            $testpath = $test.Path
            $timeNode = $test.SelectSingleNode('Results/NamedMeasurement[@name="Execution Time"]/Value')
            if ($test.status -eq "failure") {
                $time = ([double]$timeNode.InnerText * 1000)
                Add-AppveyorTest $testName -Outcome Failed -FileName $testpath -Duration $time -ErrorMessage $($test.results.measurement.value)
                Add-AppveyorMessage `"$testName failed`" -Category Error
                $anyFailures = $TRUE
            }
            elseif ($test.status -eq "skipped") {
                Add-AppveyorTest $testName -Outcome Ignored -Filename $testpath
            }
            else {
                $time = ([double]$timeNode.InnerText * 1000)
                Add-AppveyorTest $testName -Outcome Passed -FileName $testpath -Duration $time -StdOut $($test.results.measurement.value)
            }
        }
        return $testsCount, $anyFailures
    }

    $testsCount = 0
    $anyFailures = $FALSE

    # Run tests and upload results to AppVeyor one by one
    Get-ChildItem ".\Testing\*.xml" -Recurse | foreach {
        $testfile = $_.fullname
        $count, $testsResult = Add-CTest-Result $testfile
        Write-Host "Found $testfile with $count tests"
        $testsCount = $testsCount + $count
        $anyFailures = $anyFailures -or $testsResult
    }

    Write-Host "There are $testsCount tests found"

    if ($anyFailures -eq $TRUE){
        Write-Host "Failing build as there are broken tests"
        $host.SetShouldExit(1)
    }

matrix:
  fast_finish: true

cache:
  - C:\mingw-builds