-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtests.ps1
More file actions
141 lines (111 loc) · 4.49 KB
/
Copy pathtests.ps1
File metadata and controls
141 lines (111 loc) · 4.49 KB
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
function Test([string]$config, [string]$mode, [string]$fileName)
{
$BUILD="debug"
$BUILD1="Debug"
$VER="-2026"
$LLVM_BUILD="Debug"
$ARCH="x64"
$DBG="--di --opt_level=0"
$OPTIONS="--nowarn"
$TOOL="tslang"
$test=$fileName
if ($config -eq "release") {
$BUILD="release"
$BUILD1="release"
$LLVM_BUILD="Release"
$DBG=""
$OPTIONS+=" --opt --opt_level=3"
}
$SRC="."
$OUTPUT="."
if ($null -eq $Env:TOOL_PATH) {
$BUILD_PATH="..\TypeScriptCompiler\__build"
#$TOOL_PATH="..\TypeScriptCompiler\__build\$TOOL\windows-msbuild$VER-$BUILD\bin"
$TOOL_PATH="..\TypeScriptCompiler\__build\$TOOL\windows-msbuild$VER-release\bin"
$DEFAULTLIB_BUILD_PATH="..\TypeScriptCompilerDefaultLib\__build"
} else {
$TOOL_PATH=$Env:TOOL_PATH
$BUILD_PATH=$TOOL_PATH
# Compiled default lib is staged under .\__build\defaultlib\{dll,lib}\<mode>
# relative to the DefaultLib repo root (the tests working directory).
$DEFAULTLIB_BUILD_PATH=".\__build"
}
if ($null -eq $Env:GC_LIB_PATH) {
$Env:GC_LIB_PATH="$BUILD_PATH\gc\msbuild\$ARCH\$BUILD\$BUILD1"
}
if ($null -eq $Env:LLVM_LIB_PATH) {
$Env:LLVM_LIB_PATH="$BUILD_PATH\llvm\msbuild\$ARCH\$BUILD\$BUILD1\lib"
}
if ($null -eq $Env:TSLANG_LIB_PATH) {
$Env:TSLANG_LIB_PATH="$BUILD_PATH\$TOOL\windows-msbuild$VER-$BUILD\lib"
}
if ($null -eq $Env:DEFAULT_LIB_PAT) {
$Env:DEFAULT_LIB_PATH="$DEFAULTLIB_BUILD_PATH"
}
$DBG_ARGS = [string[]]$(if ($DBG -ne "") { $DBG -split " " } else { @() })
$OPTIONS_ARGS = [string[]]$(if ($OPTIONS -ne "") { $OPTIONS -split " " } else { @() })
if ($mode -eq "compile") {
$compile_error_output = ($compile_output = & $TOOL_PATH\$TOOL.exe @DBG_ARGS @OPTIONS_ARGS --shared-libs=$TOOL_PATH\TypeScriptRuntime.dll --emit=exe $SRC\tests\$test.ts) 2>&1
$compile_code = $LASTEXITCODE
if ($compile_code -ne 0) {
Write-Host "Compile Error" -ForegroundColor Red
Write-Host "Output: $compile_output"
return $false
}
$run_error_output = ($run_output = & $SRC\tests\$test.exe) 2>&1
$run_code = $LASTEXITCODE
Get-ChildItem $SRC\tests\$test.* -Exclude *.ts | Remove-Item
}
if ($mode -eq "jit") {
$run_error_output = ($run_output = & $TOOL_PATH\$TOOL.exe @DBG_ARGS @OPTIONS_ARGS --shared-libs=$TOOL_PATH\TypeScriptRuntime.dll --emit=jit $SRC\tests\$test.ts) 2>&1
$run_code = $LASTEXITCODE
}
if (($run_error_output | Where-Object {$_.GetType().fullname.Contains("ErrorRecord")} | Measure-Object).Count -gt 0) {
return $false
}
if (($run_output -join "`n") -notmatch "ALL DONE") {
Write-Host "Run Error (no 'ALL DONE' marker)" -ForegroundColor Red
Write-Host "Output: $run_output"
return $false
}
return $true
}
function Tests([string]$config, [string]$mode)
{
Write-Host "Testing..."
$count = (Get-ChildItem ".\tests" -Filter *.ts | Measure-Object).Count
$index = 0
$success = 0
$failedTests = @()
Get-ChildItem ".\tests" -Filter *.ts | Foreach-Object {
$index++
$testName = "$_ ".PadRight(40, '.')
Write-Host -NoNewline "$success/$count Test #$index : $testName "
$time = (Measure-Command { $result = Test $config $mode $_.Basename }).TotalSeconds
$time = [math]::Round($time, 2).ToString("0.00")
if ($result -eq $true) {
$success++
Write-Host -NoNewline "Passed " -ForegroundColor Green
}
else {
$failedTests += $_.Name
Write-Host -NoNewline "Failed " -ForegroundColor Red
}
Write-Host "$time sec"
}
Get-ChildItem -Path $SRC\tests -Include *.pdb,*.ilk,*.exe | Remove-Item
Write-Host "Finished $config, $mode : $success/$count passed"
return $failedTests
}
$allFailedTests = @()
$allFailedTests += Tests "release" "compile" | ForEach-Object { "release/compile: $_" }
$allFailedTests += Tests "release" "jit" | ForEach-Object { "release/jit: $_" }
$allFailedTests += Tests "debug" "compile" | ForEach-Object { "debug/compile: $_" }
$allFailedTests += Tests "debug" "jit" | ForEach-Object { "debug/jit: $_" }
if ($allFailedTests.Count -gt 0) {
Write-Host "Done. $($allFailedTests.Count) test(s) failed:" -ForegroundColor Red
$allFailedTests | ForEach-Object { Write-Host " - $_" -ForegroundColor Red }
exit 1
}
Write-Host "Done. All tests passed." -ForegroundColor Green
exit 0