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
12 changes: 12 additions & 0 deletions .swiftpm/configuration/coverage.html.report.args.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--tab-size=10
--coverage-watermark=80,20
--enable-vtable-value-profiling
--show-branch-summary
--show-region-summary
--show-branches=percent
--show-mcdc-summary
--show-expansions
--show-instantiations
--show-regions
--show-directory-coverage
--show-line-counts
8 changes: 8 additions & 0 deletions Fixtures/Coverage/Simple/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
/.build
/Packages
xcuserdata/
DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
26 changes: 26 additions & 0 deletions Fixtures/Coverage/Simple/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// swift-tools-version: 6.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Simple",
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "Simple",
targets: ["Simple"]
),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "Simple"
),
.testTarget(
name: "SimpleTests",
dependencies: ["Simple"]
),
]
)
10 changes: 10 additions & 0 deletions Fixtures/Coverage/Simple/Sources/Simple/Simple.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// The Swift Programming Language
// https://docs.swift.org/swift-book

public func greet(name: String = "world") -> String {
return "Hello, \(name)!"
}

public func libA() -> String {
return "libA"
}
24 changes: 24 additions & 0 deletions Fixtures/Coverage/Simple/Tests/SimpleTests/SimpleTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Testing
import XCTest
@testable import Simple

@Test(
arguments: [
"Bob",
"Alice",
"",
]
)
func testGreet(
name: String
) async throws {
let actual = greet(name: name)

#expect(actual == "Hello, \(name)!")
}

final class SimpleTests: XCTestCase {
func testExample() throws {
XCTAssertEqual(libA(), "libA", "Actual is not as expected")
}
}
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
// The 'swift-argument-parser' version declared here must match that
// used by 'swift-driver' and 'sourcekit-lsp'. Please coordinate
// dependency version changes here with those projects.
.package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "1.5.1")),
.package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "1.6.1")),
.package(url: "https://github.com/apple/swift-crypto.git", .upToNextMinor(from: "3.0.0")),
.package(url: "https://github.com/swiftlang/swift-syntax.git", branch: relatedDependenciesBranch),
.package(url: "https://github.com/apple/swift-system.git", from: "1.1.1"),
Expand Down
9 changes: 7 additions & 2 deletions Sources/Basics/FileSystem/AbsolutePath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,19 @@ public struct AbsolutePath: Hashable, Sendable {
/// The input string will be normalized if needed, as described in the
/// documentation for AbsolutePath.
public init(validating pathString: String) throws {
self.underlying = try .init(validating: pathString)
self.underlying = try .init(
validating: pathString.trimmingCharacters(in: .whitespacesAndNewlines),
)
}

/// Initializes an AbsolutePath from a string that may be either absolute
/// or relative; if relative, `basePath` is used as the anchor; if absolute,
/// it is used as is, and in this case `basePath` is ignored.
public init(validating pathString: String, relativeTo basePath: AbsolutePath) throws {
self.underlying = try .init(validating: pathString, relativeTo: basePath.underlying)
self.underlying = try .init(
validating: pathString.trimmingCharacters(in: .whitespacesAndNewlines),
relativeTo: basePath.underlying,
)
}

/// Initializes the AbsolutePath by concatenating a relative path to an
Expand Down
6 changes: 4 additions & 2 deletions Sources/Basics/FileSystem/RelativePath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

import Foundation
import struct TSCBasic.RelativePath

// public for transition
Expand Down Expand Up @@ -40,7 +40,9 @@ public struct RelativePath: Hashable, Sendable {

/// Convenience initializer that verifies that the path is relative.
public init(validating pathString: String) throws {
self.underlying = try .init(validating: pathString)
self.underlying = try .init(
validating: pathString.trimmingCharacters(in: .whitespacesAndNewlines),
)
}

/// Directory component. For a relative path without any path separators,
Expand Down
12 changes: 9 additions & 3 deletions Sources/Commands/SwiftBuildCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,15 @@ struct BuildCommandOptions: ParsableArguments {
var buildTests: Bool = false

/// Whether to enable code coverage.
@Flag(name: .customLong("code-coverage"),
inversion: .prefixedEnableDisable,
help: "Enable code coverage.")
@Flag(
name: [
.customLong("codecov"),
.customLong("code-coverage"),
.customLong("coverage"),
],
inversion: .prefixedEnableDisable,
help: "Enable code coverage.",
)
var enableCodeCoverage: Bool = false

/// If the binary output path should be printed.
Expand Down
Loading