Skip to content

Add better unit test failure diagnostics for when basic SwiftPM commands fail #3334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 9, 2021
Merged
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
11 changes: 7 additions & 4 deletions Tests/CommandsTests/BuildToolTests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
This source file is part of the Swift.org open source project

Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception

See http://swift.org/LICENSE.txt for license information
Expand Down Expand Up @@ -41,15 +41,18 @@ final class BuildToolTests: XCTestCase {
}

func testUsage() throws {
XCTAssert(try execute(["-help"]).stdout.contains("USAGE: swift build"))
let stdout = try execute(["-help"]).stdout
XCTAssert(stdout.contains("USAGE: swift build"), "got stdout:\n" + stdout)
}

func testSeeAlso() throws {
XCTAssert(try execute(["--help"]).stdout.contains("SEE ALSO: swift run, swift package, swift test"))
let stdout = try execute(["--help"]).stdout
XCTAssert(stdout.contains("SEE ALSO: swift run, swift package, swift test"), "got stdout:\n" + stdout)
}

func testVersion() throws {
XCTAssert(try execute(["--version"]).stdout.contains("Swift Package Manager"))
let stdout = try execute(["--version"]).stdout
XCTAssert(stdout.contains("Swift Package Manager"), "got stdout:\n" + stdout)
}

func testCreatingSanitizers() throws {
Expand Down
11 changes: 7 additions & 4 deletions Tests/CommandsTests/PackageToolTests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
This source file is part of the Swift.org open source project

Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception

See http://swift.org/LICENSE.txt for license information
Expand Down Expand Up @@ -34,15 +34,18 @@ final class PackageToolTests: XCTestCase {
}

func testUsage() throws {
XCTAssert(try execute(["--help"]).stdout.contains("USAGE: swift package"))
let stdout = try execute(["-help"]).stdout
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of a single dash here is intentional so that we test both --help and -help. The build tool test already did this, the others did not.

XCTAssert(stdout.contains("USAGE: swift package"), "got stdout:\n" + stdout)
}

func testSeeAlso() throws {
XCTAssert(try execute(["--help"]).stdout.contains("SEE ALSO: swift build, swift run, swift test"))
let stdout = try execute(["--help"]).stdout
XCTAssert(stdout.contains("SEE ALSO: swift build, swift run, swift test"), "got stdout:\n" + stdout)
}

func testVersion() throws {
XCTAssert(try execute(["--version"]).stdout.contains("Swift Package Manager"))
let stdout = try execute(["--version"]).stdout
XCTAssert(stdout.contains("Swift Package Manager"), "got stdout:\n" + stdout)
}

func testNetrcSupportedOS() throws {
Expand Down
11 changes: 7 additions & 4 deletions Tests/CommandsTests/RunToolTests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
This source file is part of the Swift.org open source project

Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception

See http://swift.org/LICENSE.txt for license information
Expand All @@ -23,15 +23,18 @@ final class RunToolTests: XCTestCase {
}

func testUsage() throws {
XCTAssert(try execute(["--help"]).stdout.contains("USAGE: swift run <options>"))
let stdout = try execute(["-help"]).stdout
XCTAssert(stdout.contains("USAGE: swift run <options>"), "got stdout:\n" + stdout)
}

func testSeeAlso() throws {
XCTAssert(try execute(["--help"]).stdout.contains("SEE ALSO: swift build, swift package, swift test"))
let stdout = try execute(["--help"]).stdout
XCTAssert(stdout.contains("SEE ALSO: swift build, swift package, swift test"), "got stdout:\n" + stdout)
}

func testVersion() throws {
XCTAssert(try execute(["--version"]).stdout.contains("Swift Package Manager"))
let stdout = try execute(["--version"]).stdout
XCTAssert(stdout.contains("Swift Package Manager"), "got stdout:\n" + stdout)
}

func testUnkownProductAndArgumentPassing() throws {
Expand Down
11 changes: 7 additions & 4 deletions Tests/CommandsTests/TestToolTests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
This source file is part of the Swift.org open source project

Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception

See http://swift.org/LICENSE.txt for license information
Expand All @@ -19,15 +19,18 @@ final class TestToolTests: XCTestCase {
}

func testUsage() throws {
XCTAssert(try execute(["--help"]).stdout.contains("USAGE: swift test"))
let stdout = try execute(["-help"]).stdout
XCTAssert(stdout.contains("USAGE: swift test"), "got stdout:\n" + stdout)
}

func testSeeAlso() throws {
XCTAssert(try execute(["--help"]).stdout.contains("SEE ALSO: swift build, swift run, swift package"))
let stdout = try execute(["--help"]).stdout
XCTAssert(stdout.contains("SEE ALSO: swift build, swift run, swift package"), "got stdout:\n" + stdout)
}

func testVersion() throws {
XCTAssert(try execute(["--version"]).stdout.contains("Swift Package Manager"))
let stdout = try execute(["--version"]).stdout
XCTAssert(stdout.contains("Swift Package Manager"), "got stdout:\n" + stdout)
}

func testNumWorkersParallelRequeriment() throws {
Expand Down