Skip to content

Commit 7ff826b

Browse files
Add tests for -private mode.
1 parent 9436799 commit 7ff826b

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
$helperPath = Join-Path (Split-Path -Parent (Split-Path -Parent $PSScriptRoot)) 'helpers\prefix-input.ps1'
2+
. $helperPath
3+
4+
$tempDir = New-PrefixTempDir
5+
try {
6+
$programPath = Join-Path $tempDir 'program.pre'
7+
8+
Set-Content -Path $programPath -Encoding Ascii -Value @'
9+
FREEZE(not_declared)
10+
'@
11+
12+
# Pass both -verbose and -private; private should suppress snapshots
13+
$result = Invoke-PrefixWithArguments -Arguments @('-verbose', '-private', $programPath)
14+
15+
if ($result.ExitCode -eq 0) {
16+
$stdout = Format-VisibleText $result.Stdout
17+
$stderr = Format-VisibleText $result.Stderr
18+
throw "Expected interpreter to exit nonzero; got 0. STDOUT: $stdout STDERR: $stderr"
19+
}
20+
21+
if (-not ($result.Stderr -match 'Traceback')) {
22+
$stderr = Format-VisibleText $result.Stderr
23+
throw "Expected 'Traceback' in stderr: $stderr"
24+
}
25+
26+
if ($result.Stderr -match 'State log index') {
27+
$stderr = Format-VisibleText $result.Stderr
28+
throw "Unexpected state log when -private present: $stderr"
29+
}
30+
31+
if ($result.Stderr -match 'Env snapshot') {
32+
$stderr = Format-VisibleText $result.Stderr
33+
throw "Unexpected env snapshot when -private present: $stderr"
34+
}
35+
}
36+
finally {
37+
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
38+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
$helperPath = Join-Path (Split-Path -Parent (Split-Path -Parent $PSScriptRoot)) 'helpers\prefix-input.ps1'
2+
. $helperPath
3+
4+
$tempDir = New-PrefixTempDir
5+
try {
6+
$programPath = Join-Path $tempDir 'program.pre'
7+
8+
Set-Content -Path $programPath -Encoding Ascii -Value @'
9+
FREEZE(not_declared)
10+
'@
11+
12+
$result = Invoke-PrefixWithArguments -Arguments @('-private', $programPath)
13+
14+
if ($result.ExitCode -eq 0) {
15+
$stdout = Format-VisibleText $result.Stdout
16+
$stderr = Format-VisibleText $result.Stderr
17+
throw "Expected interpreter to exit nonzero; got 0. STDOUT: $stdout STDERR: $stderr"
18+
}
19+
20+
if (-not ($result.Stderr -match 'Traceback')) {
21+
$stderr = Format-VisibleText $result.Stderr
22+
throw "Expected 'Traceback' in stderr: $stderr"
23+
}
24+
25+
if (-not ($result.Stderr -match 'RuntimeError')) {
26+
$stderr = Format-VisibleText $result.Stderr
27+
throw "Expected 'RuntimeError' in stderr: $stderr"
28+
}
29+
30+
if ($result.Stderr -match 'State log index') {
31+
$stderr = Format-VisibleText $result.Stderr
32+
throw "Unexpected state log in private mode: $stderr"
33+
}
34+
35+
if ($result.Stderr -match 'Env snapshot') {
36+
$stderr = Format-VisibleText $result.Stderr
37+
throw "Unexpected env snapshot in private mode: $stderr"
38+
}
39+
}
40+
finally {
41+
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
42+
}

0 commit comments

Comments
 (0)