@@ -32,7 +32,6 @@ $FirebirdConfiguration = @{
32
32
$testsBaseDir = " $baseDir \src\FirebirdSql.Data.FirebirdClient.Tests"
33
33
$testsProviderDir = " $testsBaseDir \bin\$Configuration \$ ( Get-UsedTargetFramework ) "
34
34
35
- $startDir = $null
36
35
$firebirdProcess = $null
37
36
38
37
if ($env: tests_firebird_dir ) {
@@ -45,44 +44,53 @@ else {
45
44
function Prepare () {
46
45
echo " === $ ( $MyInvocation.MyCommand.Name ) ==="
47
46
48
- $script :startDir = $pwd
49
47
$selectedConfiguration = $FirebirdConfiguration [$FirebirdSelection ]
50
48
$fbDownload = $selectedConfiguration.Download
51
49
$fbDownloadName = $fbDownload -Replace ' .+/(.+)$' , ' $1'
52
50
if (Test-Path $firebirdDir ) {
53
51
rm - Force - Recurse $firebirdDir
54
52
}
55
53
mkdir $firebirdDir | Out-Null
56
- cd $firebirdDir
57
- echo " Downloading $fbDownload "
58
- Invoke-RestMethod - Uri $fbDownload - OutFile $fbDownloadName
59
- echo " Extracting $fbDownloadName "
60
- 7z x - bsp0 - bso0 $fbDownloadName
61
- rm $fbDownloadName
62
- cp - Recurse - Force .\* $testsProviderDir
63
54
64
- ni firebird.log - ItemType File | Out-Null
55
+ pushd $firebirdDir
56
+ try {
57
+ echo " Downloading $fbDownload "
58
+ Invoke-RestMethod - Uri $fbDownload - OutFile $fbDownloadName
59
+ echo " Extracting $fbDownloadName "
60
+ 7z x - bsp0 - bso0 $fbDownloadName
61
+ rm $fbDownloadName
62
+ cp - Recurse - Force .\* $testsProviderDir
65
63
66
- echo " Starting Firebird"
67
- $process = Start-Process - FilePath $selectedConfiguration.Executable - ArgumentList $selectedConfiguration.Args - PassThru
68
- echo " Version: $ ( $process.MainModule.FileVersionInfo.FileVersion ) "
69
- $script :firebirdProcess = $process
64
+ ni firebird.log - ItemType File | Out-Null
70
65
71
- echo " === END ==="
66
+ echo " Starting Firebird"
67
+ $process = Start-Process - FilePath $selectedConfiguration.Executable - ArgumentList $selectedConfiguration.Args - PassThru
68
+ echo " Version: $ ( $process.MainModule.FileVersionInfo.FileVersion ) "
69
+ $script :firebirdProcess = $process
70
+
71
+ echo " === END ==="
72
+ }
73
+ finally {
74
+ popd
75
+ }
72
76
}
73
77
74
78
function Cleanup () {
75
- echo " === $ ( $MyInvocation.MyCommand.Name ) ==="
79
+ # Do not write to output (Write-Output, echo) here. Write-Host is ok.
80
+ # -- https://stackoverflow.com/a/45105609
81
+
82
+ Write-Host " === $ ( $MyInvocation.MyCommand.Name ) ==="
76
83
77
- cd $script :startDir
78
84
$process = $script :firebirdProcess
79
- $process.Kill ()
80
- $process.WaitForExit ()
81
- # give OS time to release all files
82
- sleep - Milliseconds 100
85
+ if ($process ) {
86
+ $process.Kill ()
87
+ $process.WaitForExit ()
88
+ # give OS time to release all files
89
+ sleep - Milliseconds 100
90
+ }
83
91
rm - Force - Recurse $firebirdDir
84
92
85
- echo " === END ==="
93
+ Write-Host " === END ==="
86
94
}
87
95
88
96
function Tests-All () {
@@ -112,26 +120,46 @@ function Tests-FirebirdClient-Embedded() {
112
120
Tests- FirebirdClient ' Embedded' $False ' Disabled'
113
121
}
114
122
function Tests-FirebirdClient ($serverType , $compression , $wireCrypt ) {
115
- cd $testsProviderDir
116
- .\FirebirdSql.Data.FirebirdClient.Tests.exe -- labels= All " --where=(ServerType==$serverType && Compression==$compression && WireCrypt==$wireCrypt ) || Category==NoServer"
117
- Check- ExitCode
123
+ pushd $testsProviderDir
124
+ try {
125
+ .\FirebirdSql.Data.FirebirdClient.Tests.exe -- labels= All " --where=(ServerType==$serverType && Compression==$compression && WireCrypt==$wireCrypt ) || Category==NoServer"
126
+ Check- ExitCode
127
+ }
128
+ finally {
129
+ popd
130
+ }
118
131
}
119
132
120
133
function Tests-EF6 () {
121
- cd " $baseDir \src\EntityFramework.Firebird.Tests\bin\$Configuration \$ ( Get-UsedTargetFramework ) "
122
- .\EntityFramework.Firebird.Tests.exe -- labels= All
123
- Check- ExitCode
134
+ pushd " $baseDir \src\EntityFramework.Firebird.Tests\bin\$Configuration \$ ( Get-UsedTargetFramework ) "
135
+ try {
136
+ .\EntityFramework.Firebird.Tests.exe -- labels= All
137
+ Check- ExitCode
138
+ }
139
+ finally {
140
+ popd
141
+ }
124
142
}
125
143
126
144
function Tests-EFCore () {
127
- cd " $baseDir \src\FirebirdSql.EntityFrameworkCore.Firebird.Tests\bin\$Configuration \$ ( Get-UsedTargetFramework ) "
128
- .\FirebirdSql.EntityFrameworkCore.Firebird.Tests.exe -- labels= All
129
- Check- ExitCode
145
+ pushd " $baseDir \src\FirebirdSql.EntityFrameworkCore.Firebird.Tests\bin\$Configuration \$ ( Get-UsedTargetFramework ) "
146
+ try {
147
+ .\FirebirdSql.EntityFrameworkCore.Firebird.Tests.exe -- labels= All
148
+ Check- ExitCode
149
+ }
150
+ finally {
151
+ popd
152
+ }
130
153
}
131
154
function Tests-EFCore-Functional () {
132
- cd " $baseDir \src\FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests"
133
- dotnet test -- no- build - c $Configuration
134
- Check- ExitCode
155
+ pushd " $baseDir \src\FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests"
156
+ try {
157
+ dotnet test -- no- build - c $Configuration
158
+ Check- ExitCode
159
+ }
160
+ finally {
161
+ popd
162
+ }
135
163
}
136
164
137
165
try {
0 commit comments