From 9cb718e6b61d4e125416b0318f75a29129446a7b Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 21 Jun 2023 17:22:10 -0500 Subject: [PATCH 1/3] AWS SDK CLI test runner fails on failed process cmd --- .../AWSSDKSwiftCLI/Utils/Process+Utils.swift | 6 +++++ .../Utils/ProcessUtilsTests.swift | 26 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/Utils/ProcessUtilsTests.swift diff --git a/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Utils/Process+Utils.swift b/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Utils/Process+Utils.swift index fe8101d11a6..357821d5936 100644 --- a/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Utils/Process+Utils.swift +++ b/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Utils/Process+Utils.swift @@ -6,6 +6,7 @@ // import Foundation +import ArgumentParser extension Process { /// Creates a process using `/usr/bin/env` as the executable @@ -73,6 +74,11 @@ struct ProcessRunner { log("Running process: \(process.commandString)") try process.run() process.waitUntilExit() + print("term reason: \(process.terminationReason)") + let exitCode = ExitCode(process.terminationStatus) + if !exitCode.isSuccess { + throw exitCode + } } #if DEBUG diff --git a/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/Utils/ProcessUtilsTests.swift b/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/Utils/ProcessUtilsTests.swift new file mode 100644 index 00000000000..d2124be186b --- /dev/null +++ b/AWSSDKSwiftCLI/Tests/AWSSDKSwiftCLITests/Utils/ProcessUtilsTests.swift @@ -0,0 +1,26 @@ +// +// Copyright Amazon.com Inc. or its affiliates. +// All Rights Reserved. +// +// SPDX-License-Identifier: Apache-2.0 +// + +@testable import AWSSDKSwiftCLI +import PackageDescription +import ArgumentParser +import XCTest + +class ProcessUtilsTests: XCTestCase { + + func test_exit_itThrowsErrorWithErrorCode() { + let process = Process("false") // this refers to /usr/bin/false which always returns unsuccessfully + do { + try ProcessRunner.standard.run(process) + XCTFail("Process runner should have thrown") + } catch let exitCodeError as ExitCode { + XCTAssertTrue(exitCodeError.rawValue != 0) + } catch { + XCTFail("Process runner threw an unexpected type of error") + } + } +} From 1d664062fba8afa6ce4b1ffef355491fca67fa0e Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 21 Jun 2023 17:28:12 -0500 Subject: [PATCH 2/3] Fixes --- AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Utils/Process+Utils.swift | 1 - sdk.properties | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Utils/Process+Utils.swift b/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Utils/Process+Utils.swift index 357821d5936..4f66da0d358 100644 --- a/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Utils/Process+Utils.swift +++ b/AWSSDKSwiftCLI/Sources/AWSSDKSwiftCLI/Utils/Process+Utils.swift @@ -74,7 +74,6 @@ struct ProcessRunner { log("Running process: \(process.commandString)") try process.run() process.waitUntilExit() - print("term reason: \(process.terminationReason)") let exitCode = ExitCode(process.terminationStatus) if !exitCode.isSuccess { throw exitCode diff --git a/sdk.properties b/sdk.properties index 117789faa8b..839e7de937c 100644 --- a/sdk.properties +++ b/sdk.properties @@ -1 +1 @@ -excludeModels=verifiedpermissions.2021-12-01 +# onlyIncludeModels=verifiedpermissions.2021-12-01 From e1c6a75776fc095a1e3ac8a4972b0e3defdbc181 Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 21 Jun 2023 23:44:17 -0500 Subject: [PATCH 3/3] Revert sdk.properties to match main branch --- sdk.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk.properties b/sdk.properties index 839e7de937c..117789faa8b 100644 --- a/sdk.properties +++ b/sdk.properties @@ -1 +1 @@ -# onlyIncludeModels=verifiedpermissions.2021-12-01 +excludeModels=verifiedpermissions.2021-12-01