Skip to content

Commit c79c953

Browse files
fixup move build operation test into DependencyValidationTests
1 parent 6c3a6c2 commit c79c953

File tree

2 files changed

+70
-100
lines changed

2 files changed

+70
-100
lines changed

Tests/SWBBuildSystemTests/DependencyValidationTests.swift

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ fileprivate struct DependencyValidationTests: CoreBasedTests {
328328
}
329329

330330
@Test(.requireSDKs(.host))
331-
func validateModuleDependencies() async throws {
331+
func validateModuleDependenciesSwift() async throws {
332332
try await withTemporaryDirectory { tmpDir in
333333
let testWorkspace = try await TestWorkspace(
334334
"Test",
@@ -458,4 +458,73 @@ fileprivate struct DependencyValidationTests: CoreBasedTests {
458458
}
459459
}
460460
}
461+
462+
@Test(.requireSDKs(.host))
463+
func validateModuleDependenciesClang() async throws {
464+
try await withTemporaryDirectory { tmpDir async throws -> Void in
465+
let testWorkspace = TestWorkspace(
466+
"Test",
467+
sourceRoot: tmpDir.join("Test"),
468+
projects: [
469+
TestProject(
470+
"aProject",
471+
groupTree: TestGroup(
472+
"Sources", path: "Sources",
473+
children: [
474+
TestFile("CoreFoo.m")
475+
]),
476+
buildConfigurations: [
477+
TestBuildConfiguration(
478+
"Debug",
479+
buildSettings: [
480+
"PRODUCT_NAME": "$(TARGET_NAME)",
481+
"CLANG_ENABLE_MODULES": "YES",
482+
"CLANG_ENABLE_EXPLICIT_MODULES": "YES",
483+
"GENERATE_INFOPLIST_FILE": "YES",
484+
"MODULE_DEPENDENCIES": "Foundation",
485+
"VALIDATE_MODULE_DEPENDENCIES": "YES_ERROR",
486+
"SDKROOT": "$(HOST_PLATFORM)",
487+
"SUPPORTED_PLATFORMS": "$(HOST_PLATFORM)",
488+
"DSTROOT": tmpDir.join("dstroot").str,
489+
]
490+
)
491+
],
492+
targets: [
493+
TestStandardTarget(
494+
"CoreFoo", type: .framework,
495+
buildPhases: [
496+
TestSourcesBuildPhase(["CoreFoo.m"]),
497+
TestFrameworksBuildPhase()
498+
])
499+
])
500+
]
501+
)
502+
503+
let tester = try await BuildOperationTester(getCore(), testWorkspace, simulated: false)
504+
let SRCROOT = testWorkspace.sourceRoot.join("aProject")
505+
506+
// Write the source files.
507+
try await tester.fs.writeFileContents(SRCROOT.join("Sources/CoreFoo.m")) { contents in
508+
contents <<< """
509+
#include <Foundation/Foundation.h>
510+
#include <Accelerate/Accelerate.h>
511+
512+
void f0(void) { };
513+
"""
514+
}
515+
516+
if try await clangFeatures.has(.printHeadersDirectPerFile) {
517+
// Expect complaint about undeclared dependency
518+
try await tester.checkBuild(parameters: BuildParameters(configuration: "Debug"), runDestination: .host, persistent: true) { results in
519+
results.checkError(.contains("Missing entries in MODULE_DEPENDENCIES: Accelerate"))
520+
}
521+
522+
// Declaring dependencies resolves the problem
523+
try await tester.checkBuild(parameters: BuildParameters(configuration: "Debug", overrides: ["MODULE_DEPENDENCIES": "Foundation Accelerate"]), runDestination: .host, persistent: true) { results in
524+
results.checkNoErrors()
525+
}
526+
}
527+
}
528+
}
529+
461530
}

Tests/SWBBuildSystemTests/DependencyVerificationBuildOperationTests.swift

Lines changed: 0 additions & 99 deletions
This file was deleted.

0 commit comments

Comments
 (0)