Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 71 additions & 10 deletions eng/scripts/Analyze-Code.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,44 +20,99 @@ Analyzing code with
"@

if ($CheckWasm) {
Invoke-LoggedCommand "rustup target add wasm32-unknown-unknown"
# Temporary fix to exit immediately on failure. LogError should Write-Error
# instead
$command = "rustup target add wasm32-unknown-unknown"
Invoke-LoggedCommand $command
if ($LastExitCode) {
Write-Error "Failed to execute $command"
}
}

if ($Deny) {
Invoke-LoggedCommand "cargo install cargo-deny --locked"
# Temporary fix to exit immediately on failure. LogError should Write-Error
# instead
$command = "cargo install cargo-deny --locked"
Invoke-LoggedCommand $command
if ($LastExitCode) {
Write-Error "Failed to execute $command"
}
}

Invoke-LoggedCommand "cargo check --package azure_core --all-features --all-targets --keep-going"
# Temporary fix to exit immediately on failure. LogError should Write-Error
# instead
$command = "cargo check --package azure_core --all-features --all-targets --keep-going"
Invoke-LoggedCommand $command
if ($LastExitCode) {
Write-Error "Failed to execute $command"
}

Invoke-LoggedCommand "cargo fmt --all -- --check"
# Temporary fix to exit immediately on failure. LogError should Write-Error
# instead
$command = "cargo fmt --all -- --check"
Invoke-LoggedCommand $command
if ($LastExitCode) {
Write-Error "Failed to execute $command"
}

Invoke-LoggedCommand "cargo clippy --workspace --all-features --all-targets --keep-going --no-deps"
# Temporary fix to exit immediately on failure. LogError should Write-Error
# instead
$command = "cargo clippy --workspace --all-features --all-targets --keep-going --no-deps"
Invoke-LoggedCommand $command
if ($LastExitCode) {
Write-Error "Failed to execute $command"
}

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

Invoke-LoggedCommand "cargo clippy --target=wasm32-unknown-unknown --workspace --keep-going --no-deps"
# Temporary fix to exit immediately on failure. LogError should Write-Error
# instead
$command = "cargo clippy --target=wasm32-unknown-unknown --workspace --keep-going --no-deps"
Invoke-LoggedCommand $command
if ($LastExitCode) {
Write-Error "Failed to execute $command"
}

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

if ($Deny) {
Invoke-LoggedCommand "cargo deny --all-features check"
# Temporary fix to exit immediately on failure. LogError should Write-Error
# instead
$command = "cargo deny --all-features check"
Invoke-LoggedCommand $command
if ($LastExitCode) {
Write-Error "Failed to execute $command"
}
}

Invoke-LoggedCommand "cargo doc --workspace --no-deps --all-features"
# Temporary fix to exit immediately on failure. LogError should Write-Error
# instead
$command = "cargo doc --workspace --no-deps --all-features"
Invoke-LoggedCommand $command
if ($LastExitCode) {
Write-Error "Failed to execute $command"
}

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

if (!$SkipPackageAnalysis) {
if (!(Test-Path $PackageInfoDirectory)) {
Write-Host "Analyzing workspace`n"
return Invoke-LoggedCommand "&$verifyDependenciesScript $RepoRoot/Cargo.toml"
# Temporary fix to exit immediately on failure. LogError should Write-Error
# instead
$command = "&$verifyDependenciesScript $RepoRoot/Cargo.toml"
$result = Invoke-LoggedCommand $command
if ($LastExitCode) {
Write-Error "Failed to execute $command"
}
return $result
}

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

foreach ($package in $packagesToTest) {
Write-Host "Analyzing package '$($package.Name)' in directory '$($package.DirectoryPath)'`n"
Invoke-LoggedCommand "&$verifyDependenciesScript $($package.DirectoryPath)/Cargo.toml"
# Temporary fix to exit immediately on failure. LogError should Write-Error
# instead
$command = "&$verifyDependenciesScript $($package.DirectoryPath)/Cargo.toml"
Invoke-LoggedCommand $command
if ($LastExitCode) {
Write-Error "Failed to execute $command"
}
}
}
24 changes: 21 additions & 3 deletions eng/scripts/Test-Packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,31 @@ foreach ($package in $packagesToTest) {

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

Invoke-LoggedCommand "cargo build --keep-going" -GroupOutput
# Temporary fix to exit immediately on failure. LogError should Write-Error
# instead
$command = "cargo build --keep-going"
Invoke-LoggedCommand $command -GroupOutput
if ($LastExitCode) {
Write-Error "Failed to execute $command"
}
Write-Host "`n`n"

Invoke-LoggedCommand "cargo test --doc --no-fail-fast" -GroupOutput
# Temporary fix to exit immediately on failure. LogError should Write-Error
# instead
$command = "cargo test --doc --no-fail-fast"
Invoke-LoggedCommand $command -GroupOutput
if ($LastExitCode) {
Write-Error "Failed to execute $command"
}
Write-Host "`n`n"

Invoke-LoggedCommand "cargo test --all-targets --no-fail-fast" -GroupOutput
# Temporary fix to exit immediately on failure. LogError should Write-Error
# instead
$command = "cargo test --all-targets --no-fail-fast"
Invoke-LoggedCommand $command -GroupOutput
if ($LastExitCode) {
Write-Error "Failed to execute $command"
}
Write-Host "`n`n"

$cleanupScript = Join-Path $packageDirectory "Test-Cleanup.ps1"
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/azure_core/tests/core_error_http_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async fn deconstruct_raw_response() -> Result<(), Box<dyn std::error::Error>> {
assert_eq!(status, &StatusCode::BadRequest);
assert_eq!(error_code.as_deref(), Some("BadParameter"));
assert!(
matches!(raw_response, Some(r) if str::from_utf8(r.body())?.contains("Unknown parameter"))
matches!(raw_response, Some(r) if str::from_utf8(r.body())?.contains("test-error"))
);

Ok(())
Expand Down
Loading