Skip to content

Commit 2cc1aec

Browse files
authored
Narrowly fix Test-Packages.ps1 and Analyze-Code.ps1 (#3106)
1 parent 2444b6f commit 2cc1aec

File tree

2 files changed

+92
-13
lines changed

2 files changed

+92
-13
lines changed

eng/scripts/Analyze-Code.ps1

Lines changed: 71 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,44 +20,99 @@ Analyzing code with
2020
"@
2121

2222
if ($CheckWasm) {
23-
Invoke-LoggedCommand "rustup target add wasm32-unknown-unknown"
23+
# Temporary fix to exit immediately on failure. LogError should Write-Error
24+
# instead
25+
$command = "rustup target add wasm32-unknown-unknown"
26+
Invoke-LoggedCommand $command
27+
if ($LastExitCode) {
28+
Write-Error "Failed to execute $command"
29+
}
2430
}
2531

2632
if ($Deny) {
27-
Invoke-LoggedCommand "cargo install cargo-deny --locked"
33+
# Temporary fix to exit immediately on failure. LogError should Write-Error
34+
# instead
35+
$command = "cargo install cargo-deny --locked"
36+
Invoke-LoggedCommand $command
37+
if ($LastExitCode) {
38+
Write-Error "Failed to execute $command"
39+
}
2840
}
2941

30-
Invoke-LoggedCommand "cargo check --package azure_core --all-features --all-targets --keep-going"
42+
# Temporary fix to exit immediately on failure. LogError should Write-Error
43+
# instead
44+
$command = "cargo check --package azure_core --all-features --all-targets --keep-going"
45+
Invoke-LoggedCommand $command
46+
if ($LastExitCode) {
47+
Write-Error "Failed to execute $command"
48+
}
3149

32-
Invoke-LoggedCommand "cargo fmt --all -- --check"
50+
# Temporary fix to exit immediately on failure. LogError should Write-Error
51+
# instead
52+
$command = "cargo fmt --all -- --check"
53+
Invoke-LoggedCommand $command
54+
if ($LastExitCode) {
55+
Write-Error "Failed to execute $command"
56+
}
3357

34-
Invoke-LoggedCommand "cargo clippy --workspace --all-features --all-targets --keep-going --no-deps"
58+
# Temporary fix to exit immediately on failure. LogError should Write-Error
59+
# instead
60+
$command = "cargo clippy --workspace --all-features --all-targets --keep-going --no-deps"
61+
Invoke-LoggedCommand $command
62+
if ($LastExitCode) {
63+
Write-Error "Failed to execute $command"
64+
}
3565

3666
if ($CheckWasm) {
3767
# Save the original RUSTFLAGS to restore later
3868
$OriginalRustFlags = $env:RUSTFLAGS
3969
# This is needed to ensure that the `getrandom` crate uses the `wasm_js` backend
4070
$env:RUSTFLAGS = ${env:RUSTFLAGS} + ' --cfg getrandom_backend="wasm_js"'
4171

42-
Invoke-LoggedCommand "cargo clippy --target=wasm32-unknown-unknown --workspace --keep-going --no-deps"
72+
# Temporary fix to exit immediately on failure. LogError should Write-Error
73+
# instead
74+
$command = "cargo clippy --target=wasm32-unknown-unknown --workspace --keep-going --no-deps"
75+
Invoke-LoggedCommand $command
76+
if ($LastExitCode) {
77+
Write-Error "Failed to execute $command"
78+
}
4379

4480
# Restore the original RUSTFLAGS, since the getrandom config option can only be set for wasm32-unknown-unknown builds.
4581
$env:RUSTFLAGS = $OriginalRustFlags
4682
}
4783

4884
if ($Deny) {
49-
Invoke-LoggedCommand "cargo deny --all-features check"
85+
# Temporary fix to exit immediately on failure. LogError should Write-Error
86+
# instead
87+
$command = "cargo deny --all-features check"
88+
Invoke-LoggedCommand $command
89+
if ($LastExitCode) {
90+
Write-Error "Failed to execute $command"
91+
}
5092
}
5193

52-
Invoke-LoggedCommand "cargo doc --workspace --no-deps --all-features"
94+
# Temporary fix to exit immediately on failure. LogError should Write-Error
95+
# instead
96+
$command = "cargo doc --workspace --no-deps --all-features"
97+
Invoke-LoggedCommand $command
98+
if ($LastExitCode) {
99+
Write-Error "Failed to execute $command"
100+
}
53101

54102
# Verify package dependencies
55103
$verifyDependenciesScript = Join-Path $RepoRoot 'eng' 'scripts' 'verify-dependencies.rs' -Resolve
56104

57105
if (!$SkipPackageAnalysis) {
58106
if (!(Test-Path $PackageInfoDirectory)) {
59107
Write-Host "Analyzing workspace`n"
60-
return Invoke-LoggedCommand "&$verifyDependenciesScript $RepoRoot/Cargo.toml"
108+
# Temporary fix to exit immediately on failure. LogError should Write-Error
109+
# instead
110+
$command = "&$verifyDependenciesScript $RepoRoot/Cargo.toml"
111+
$result = Invoke-LoggedCommand $command
112+
if ($LastExitCode) {
113+
Write-Error "Failed to execute $command"
114+
}
115+
return $result
61116
}
62117

63118
$packagesToTest = Get-ChildItem $PackageInfoDirectory -Filter "*.json" -Recurse
@@ -66,6 +121,12 @@ if (!$SkipPackageAnalysis) {
66121

67122
foreach ($package in $packagesToTest) {
68123
Write-Host "Analyzing package '$($package.Name)' in directory '$($package.DirectoryPath)'`n"
69-
Invoke-LoggedCommand "&$verifyDependenciesScript $($package.DirectoryPath)/Cargo.toml"
124+
# Temporary fix to exit immediately on failure. LogError should Write-Error
125+
# instead
126+
$command = "&$verifyDependenciesScript $($package.DirectoryPath)/Cargo.toml"
127+
Invoke-LoggedCommand $command
128+
if ($LastExitCode) {
129+
Write-Error "Failed to execute $command"
130+
}
70131
}
71132
}

eng/scripts/Test-Packages.ps1

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,31 @@ foreach ($package in $packagesToTest) {
5656

5757
Write-Host "`n`nTesting package: '$($package.Name)'`n"
5858

59-
Invoke-LoggedCommand "cargo build --keep-going" -GroupOutput
59+
# Temporary fix to exit immediately on failure. LogError should Write-Error
60+
# instead
61+
$command = "cargo build --keep-going"
62+
Invoke-LoggedCommand $command -GroupOutput
63+
if ($LastExitCode) {
64+
Write-Error "Failed to execute $command"
65+
}
6066
Write-Host "`n`n"
6167

62-
Invoke-LoggedCommand "cargo test --doc --no-fail-fast" -GroupOutput
68+
# Temporary fix to exit immediately on failure. LogError should Write-Error
69+
# instead
70+
$command = "cargo test --doc --no-fail-fast"
71+
Invoke-LoggedCommand $command -GroupOutput
72+
if ($LastExitCode) {
73+
Write-Error "Failed to execute $command"
74+
}
6375
Write-Host "`n`n"
6476

65-
Invoke-LoggedCommand "cargo test --all-targets --no-fail-fast" -GroupOutput
77+
# Temporary fix to exit immediately on failure. LogError should Write-Error
78+
# instead
79+
$command = "cargo test --all-targets --no-fail-fast"
80+
Invoke-LoggedCommand $command -GroupOutput
81+
if ($LastExitCode) {
82+
Write-Error "Failed to execute $command"
83+
}
6684
Write-Host "`n`n"
6785

6886
$cleanupScript = Join-Path $packageDirectory "Test-Cleanup.ps1"

0 commit comments

Comments
 (0)