Skip to content

Commit 648734d

Browse files
committed
Add edited to unsafeAllowedPackages
1 parent 42aaad6 commit 648734d

File tree

2 files changed

+65
-2
lines changed

2 files changed

+65
-2
lines changed

Sources/Workspace/Workspace+Manifests.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ extension Workspace {
147147
result.insert(packageRef)
148148
}
149149

150-
case .registryDownload, .edited, .custom:
150+
case .registryDownload, .custom:
151151
continue
152-
case .fileSystem:
152+
case .fileSystem, .edited:
153153
result.insert(dependency.packageRef)
154154
}
155155
}

Tests/WorkspaceTests/WorkspaceTests.swift

+63
Original file line numberDiff line numberDiff line change
@@ -2387,6 +2387,69 @@ final class WorkspaceTests: XCTestCase {
23872387
}
23882388
}
23892389

2390+
func testUnsafeFlagsInEditedPackage() async throws {
2391+
let sandbox = AbsolutePath("/tmp/ws/")
2392+
let fs = InMemoryFileSystem()
2393+
2394+
let workspace = try await MockWorkspace(
2395+
sandbox: sandbox,
2396+
fileSystem: fs,
2397+
roots: [
2398+
MockPackage(
2399+
name: "Root",
2400+
targets: [
2401+
MockTarget(
2402+
name: "Root",
2403+
dependencies: ["Foo"],
2404+
settings: [
2405+
.init(tool: .swift, kind: .unsafeFlags(["-F","/tmp"]))
2406+
]
2407+
),
2408+
],
2409+
products: [],
2410+
dependencies: [
2411+
// Must be a branch or revision for unsafe flags
2412+
.sourceControl(path: "./Foo", requirement: .revision("1.0.0")),
2413+
]
2414+
),
2415+
],
2416+
packages: [
2417+
MockPackage(
2418+
name: "Foo",
2419+
targets: [
2420+
MockTarget(
2421+
name: "Foo",
2422+
settings: [
2423+
.init(tool: .swift, kind: .unsafeFlags(["-F","/tmp"]))
2424+
]
2425+
),
2426+
],
2427+
products: [
2428+
MockProduct(name: "Foo", modules: ["Foo"]),
2429+
],
2430+
versions: ["1.0.0", nil]
2431+
),
2432+
]
2433+
)
2434+
2435+
try await workspace.checkPackageGraph(roots: ["Root"]) { graph, diagnostics in
2436+
PackageGraphTester(graph) { result in
2437+
result.check(roots: .plain("Root"))
2438+
result.check(packages: .plain("root"), .plain("Foo"))
2439+
}
2440+
XCTAssertNoDiagnostics(diagnostics)
2441+
}
2442+
2443+
let editedFooPath = AbsolutePath("/tmp/ws/Foo")
2444+
await workspace.checkEdit(packageIdentity: "Foo", path: editedFooPath) { diagnostics in
2445+
XCTAssertNoDiagnostics(diagnostics)
2446+
}
2447+
2448+
try await workspace.checkPackageGraph(roots: ["Root"]) { _, diagnostics in
2449+
XCTAssertNoDiagnostics(diagnostics)
2450+
}
2451+
}
2452+
23902453
func testMissingEditCanRestoreOriginalCheckout() async throws {
23912454
let sandbox = AbsolutePath("/tmp/ws/")
23922455
let fs = InMemoryFileSystem()

0 commit comments

Comments
 (0)