Skip to content

Commit 37e75ae

Browse files
committed
Ensure we parse diagnostics from CustomTasks in PIF
1 parent c9c7265 commit 37e75ae

File tree

2 files changed

+104
-1
lines changed

2 files changed

+104
-1
lines changed

Sources/SWBCore/CustomTaskTypeDescription.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public final class CustomTaskTypeDescription: TaskTypeDescription {
5252
}
5353

5454
public func customOutputParserType(for task: any ExecutableTask) -> (any TaskOutputParser.Type)? {
55-
nil
55+
ShellScriptOutputParser.self
5656
}
5757

5858
public func interestingPath(for task: any ExecutableTask) -> Path? {
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift open source project
4+
//
5+
// Copyright (c) 2024 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import Testing
14+
15+
import SWBBuildSystem
16+
import SWBCore
17+
import SWBTestSupport
18+
import SWBTaskExecution
19+
import SWBUtil
20+
21+
@Suite
22+
fileprivate struct CustomTaskBuildOperationTests: CoreBasedTests {
23+
24+
@Test(.requireSDKs(.host))
25+
func outputParsing() async throws {
26+
try await withTemporaryDirectory { tmpDir in
27+
let testProject = TestProject(
28+
"aProject",
29+
sourceRoot: tmpDir,
30+
groupTree: TestGroup(
31+
"SomeFiles", path: "Sources",
32+
children: [
33+
TestFile("tool.swift"),
34+
TestFile("foo.c"),
35+
]),
36+
buildConfigurations: [
37+
TestBuildConfiguration(
38+
"Debug",
39+
buildSettings: [
40+
"GENERATE_INFOPLIST_FILE": "YES",
41+
"PRODUCT_NAME": "$(TARGET_NAME)",
42+
"SWIFT_VERSION": try await swiftVersion,
43+
"SDKROOT": "auto",
44+
"CODE_SIGNING_ALLOWED": "NO",
45+
]),
46+
],
47+
targets: [
48+
TestStandardTarget(
49+
"CoreFoo", type: .dynamicLibrary,
50+
buildPhases: [
51+
TestSourcesBuildPhase(["foo.c"])
52+
],
53+
customTasks: [
54+
TestCustomTask(
55+
commandLine: ["$(BUILD_DIR)/$(CONFIGURATION)/tool"],
56+
environment: [:],
57+
workingDirectory: tmpDir.str,
58+
executionDescription: "My Custom Task",
59+
inputs: ["$(BUILD_DIR)/$(CONFIGURATION)/tool"],
60+
outputs: [Path.root.join("output").str],
61+
enableSandboxing: false,
62+
preparesForIndexing: false)
63+
],
64+
dependencies: ["tool"]
65+
),
66+
TestStandardTarget(
67+
"tool", type: .hostBuildTool,
68+
buildPhases: [
69+
TestSourcesBuildPhase(["tool.swift"])
70+
]
71+
),
72+
])
73+
let core = try await getCore()
74+
let tester = try await BuildOperationTester(core, testProject, simulated: false)
75+
76+
let parameters = BuildParameters(action: .build, configuration: "Debug")
77+
78+
try await tester.fs.writeFileContents(tmpDir.join("Sources").join("tool.swift")) { stream in
79+
stream <<<
80+
"""
81+
@main
82+
struct Entry {
83+
static func main() {
84+
print("warning: this is a warning")
85+
}
86+
}
87+
"""
88+
}
89+
90+
try await tester.fs.writeFileContents(tmpDir.join("Sources").join("foo.c")) { stream in
91+
stream <<<
92+
"""
93+
void foo(void) {}
94+
"""
95+
}
96+
97+
try await tester.checkBuild(parameters: parameters) { results in
98+
results.checkWarning(.contains("this is a warning"))
99+
results.checkNoDiagnostics()
100+
}
101+
}
102+
}
103+
}

0 commit comments

Comments
 (0)