<commit_before>﻿
# Helper function to extract vars out of the vsvars batch file
function Get-Batchfile ($file) {
    $cmd = "`"$file`" & set"
    cmd /c $cmd | Foreach-Object {
        $p, $v = $_.split('=')
        Set-Item -path env:$p -value $v
    }
}

function Invoke-BuildCommand($command)
{
    Write-Host $command
    Invoke-Expression $command
    if (-not $?)
    {
        Exit $LASTEXITCODE
    }
}

function Invoke-Tests($executable)
{
    # Run tests using Chutzpah and export results as JUnit format to chutzpah-results.xml
    $TestCommand = "$executable -ojunit"
    Write-Host $TestCommand
    Invoke-Expression $TestCommand

    $anyFailures = $FALSE

    # Upload results to AppVeyor one by one
    Get-ChildItem *.xml | foreach {
        $testsuites = [xml](get-content $_.Name)

        foreach ($testsuite in $testsuites.testsuites.testsuite) {
            write-host " $($testsuite.name)"
            foreach ($testcase in $testsuite.testcase){
                $failed = $testcase.failure
                if ($failed) {
                    Add-AppveyorTest $testcase.name -Outcome Failed -FileName $testsuite.name -ErrorMessage $testcase.failure.message
                    Add-AppveyorMessage "$($testcase.name) failed" -Category Error
                    $anyFailures = $TRUE
                }
                else {
                    Add-AppveyorTest $testcase.name -Outcome Passed -FileName $testsuite.name
                }

            }
        }
    }

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

# The project files that will get built
$VS2008ProjectFiles = @( 'CppUTest.vcproj' , 'tests\AllTests.vcproj'  )
$VS2010ProjectFiles = @( 'CppUTest.vcxproj', 'tests\AllTests.vcxproj' )
$VS2008TestCommand = 'tests\Debug\AllTests.exe'
$VS2010TestCommand = 'tests\Debug\AllTests.exe'

if ($env:APPVEYOR)
{
    $logger_arg = '/logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"'
}
else
{
    $logger_arg = ''
}
<commit_msg>Script nested one level too deep<commit_after>﻿
# Helper function to extract vars out of the vsvars batch file
function Get-Batchfile ($file) {
    $cmd = "`"$file`" & set"
    cmd /c $cmd | Foreach-Object {
        $p, $v = $_.split('=')
        Set-Item -path env:$p -value $v
    }
}

function Invoke-BuildCommand($command)
{
    Write-Host $command
    Invoke-Expression $command
    if (-not $?)
    {
        Exit $LASTEXITCODE
    }
}

function Invoke-Tests($executable)
{
    # Run tests using Chutzpah and export results as JUnit format to chutzpah-results.xml
    $TestCommand = "$executable -ojunit"
    Write-Host $TestCommand
    Invoke-Expression $TestCommand

    $anyFailures = $FALSE

    # Upload results to AppVeyor one by one
    Get-ChildItem *.xml | foreach {
        $testsuite = [xml](get-content $_.Name)

        write-host " $($testsuite.name)"
        foreach ($testcase in $testsuite.testcase){
            if ($testcase.failure) {
                Add-AppveyorTest $testcase.name -Outcome Failed -FileName $testsuite.name -ErrorMessage $testcase.failure.message
                Add-AppveyorMessage "$($testcase.name) failed" -Category Error
                $anyFailures = $TRUE
            }
            elseif ($testcase.skipped) {
                Add-AppveyorTest $testcase.name -Outcome Ignored -Filename $testsuite.name
            }
            else {
                Add-AppveyorTest $testcase.name -Outcome Passed -FileName $testsuite.name
            }
        }
    }

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

# The project files that will get built
$VS2008ProjectFiles = @( 'CppUTest.vcproj' , 'tests\AllTests.vcproj'  )
$VS2010ProjectFiles = @( 'CppUTest.vcxproj', 'tests\AllTests.vcxproj' )
$VS2008TestCommand = 'tests\Debug\AllTests.exe'
$VS2010TestCommand = 'tests\Debug\AllTests.exe'

if ($env:APPVEYOR)
{
    $logger_arg = '/logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"'
}
else
{
    $logger_arg = ''
}

{'fraction_non_alphanumeric': 0.11961259079903147, 'fraction_numerical': 0.008232445520581114, 'mean_word_length': 2.425373134328358, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7633535', 'n_tokens_mistral': 1373, 'n_tokens_neox': 1304, 'n_words': 305}