|
| 1 | +//===----------------------------------------------------------------------===// |
| 2 | +// |
| 3 | +// This source file is part of the Swift open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2025 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 SWBCore |
| 16 | +import SWBTestSupport |
| 17 | +@_spi(Testing) import SWBUtil |
| 18 | + |
| 19 | +import SWBTaskExecution |
| 20 | +import SWBProtocol |
| 21 | + |
| 22 | +@Suite |
| 23 | +fileprivate struct DependencyVerificationBuildOperationTests: CoreBasedTests { |
| 24 | + |
| 25 | + @Test(.requireSDKs(.macOS)) |
| 26 | + func actualMinimalFramework() async throws { |
| 27 | + try await withTemporaryDirectory { tmpDirPath async throws -> Void in |
| 28 | + let testWorkspace = TestWorkspace( |
| 29 | + "Test", |
| 30 | + sourceRoot: tmpDirPath.join("Test"), |
| 31 | + projects: [ |
| 32 | + TestProject( |
| 33 | + "aProject", |
| 34 | + groupTree: TestGroup( |
| 35 | + "Sources", path: "Sources", |
| 36 | + children: [ |
| 37 | + TestFile("CoreFoo.m") |
| 38 | + ]), |
| 39 | + buildConfigurations: [ |
| 40 | + TestBuildConfiguration( |
| 41 | + "Debug", |
| 42 | + buildSettings: [ |
| 43 | + "PRODUCT_NAME": "$(TARGET_NAME)", |
| 44 | + "CLANG_ENABLE_MODULES": "NO", |
| 45 | + "GENERATE_INFOPLIST_FILE": "YES", |
| 46 | + "DEPENDENCIES": "Foundation UIKit", |
| 47 | + // Disable the SetOwnerAndGroup action by setting them to empty values. |
| 48 | + "INSTALL_GROUP": "", |
| 49 | + "INSTALL_OWNER": "", |
| 50 | + ] |
| 51 | + ) |
| 52 | + ], |
| 53 | + targets: [ |
| 54 | + TestStandardTarget( |
| 55 | + "CoreFoo", type: .framework, |
| 56 | + buildPhases: [ |
| 57 | + TestSourcesBuildPhase(["CoreFoo.m"]) |
| 58 | + ]) |
| 59 | + ]) |
| 60 | + ] |
| 61 | + ) |
| 62 | + |
| 63 | + let tester = try await BuildOperationTester(getCore(), testWorkspace, simulated: false) |
| 64 | + let SRCROOT = testWorkspace.sourceRoot.join("aProject") |
| 65 | + |
| 66 | + // Write the source files. |
| 67 | + try await tester.fs.writeFileContents(SRCROOT.join("Sources/CoreFoo.m")) { contents in |
| 68 | + contents <<< """ |
| 69 | + #include <Foundation/Foundation.h> |
| 70 | + #include <Accelerate/Accelerate.h> |
| 71 | +
|
| 72 | + void f0(void) { }; |
| 73 | + """ |
| 74 | + } |
| 75 | + |
| 76 | + let parameters = BuildParameters( |
| 77 | + action: .install, configuration: "Debug", |
| 78 | + overrides: [ |
| 79 | + "DSTROOT": tmpDirPath.join("dst").str |
| 80 | + ]) |
| 81 | + |
| 82 | + try await tester.checkBuild(parameters: parameters, runDestination: .macOS, persistent: true) { results in |
| 83 | + results.checkError(.contains("Undeclared dependencies: \n Accelerate")) |
| 84 | + } |
| 85 | + } |
| 86 | + } |
| 87 | +} |
0 commit comments