Skip to content
Draft
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: 10 additions & 71 deletions eng/scripts/Analyze-Code.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,99 +20,44 @@ Analyzing code with
"@

if ($CheckWasm) {
# 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"
}
Invoke-LoggedCommand "rustup target add wasm32-unknown-unknown"
}

if ($Deny) {
# 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 install cargo-deny --locked"
}

# 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 check --package azure_core --all-features --all-targets --keep-going"

# 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 fmt --all -- --check"

# 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"
}
Invoke-LoggedCommand "cargo clippy --workspace --all-features --all-targets --keep-going --no-deps"

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"'

# 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"
}
Invoke-LoggedCommand "cargo clippy --target=wasm32-unknown-unknown --workspace --keep-going --no-deps"

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

if ($Deny) {
# 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 deny --all-features check"
}

# 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"
}
Invoke-LoggedCommand "cargo doc --workspace --no-deps --all-features"

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

if (!$SkipPackageAnalysis) {
if (!(Test-Path $PackageInfoDirectory)) {
Write-Host "Analyzing workspace`n"
# 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
return Invoke-LoggedCommand "&$verifyDependenciesScript $RepoRoot/Cargo.toml"
}

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

foreach ($package in $packagesToTest) {
Write-Host "Analyzing package '$($package.Name)' in directory '$($package.DirectoryPath)'`n"
# 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"
}
Invoke-LoggedCommand "&$verifyDependenciesScript $($package.DirectoryPath)/Cargo.toml"
}
}
24 changes: 3 additions & 21 deletions eng/scripts/Test-Packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,13 @@ foreach ($package in $packagesToTest) {

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

# 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"
}
Invoke-LoggedCommand "cargo build --keep-going" -GroupOutput
Write-Host "`n`n"

# 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"
}
Invoke-LoggedCommand "cargo test --doc --no-fail-fast" -GroupOutput
Write-Host "`n`n"

# 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"
}
Invoke-LoggedCommand "cargo test --all-targets --no-fail-fast" -GroupOutput
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-failure"))
);

Ok(())
Expand Down
Loading