|
| 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 Basics |
| 14 | +@testable import Build |
| 15 | +import PackageGraph |
| 16 | +import PackageModel |
| 17 | +import SPMTestSupport |
| 18 | +import XCTest |
| 19 | + |
| 20 | +final class ClangTargetBuildDescriptionTests: XCTestCase { |
| 21 | + func testClangIndexStorePath() throws { |
| 22 | + let targetDescription = try makeTargetBuildDescription() |
| 23 | + XCTAssertTrue(try targetDescription.basicArguments().contains("-index-store-path")) |
| 24 | + } |
| 25 | + |
| 26 | + private func makeClangTarget() throws -> ClangTarget { |
| 27 | + try ClangTarget( |
| 28 | + name: "dummy", |
| 29 | + cLanguageStandard: nil, |
| 30 | + cxxLanguageStandard: nil, |
| 31 | + includeDir: .root, |
| 32 | + moduleMapType: .none, |
| 33 | + type: .library, |
| 34 | + path: .root, |
| 35 | + sources: .init(paths: [.root.appending(component: "foo.c")], root: .root), |
| 36 | + usesUnsafeFlags: false |
| 37 | + ) |
| 38 | + } |
| 39 | + |
| 40 | + private func makeResolvedTarget() throws -> ResolvedTarget { |
| 41 | + ResolvedTarget( |
| 42 | + packageIdentity: .plain("dummy"), |
| 43 | + underlying: try makeClangTarget(), |
| 44 | + dependencies: [], |
| 45 | + supportedPlatforms: [], |
| 46 | + platformVersionProvider: .init(implementation: .minimumDeploymentTargetDefault) |
| 47 | + ) |
| 48 | + } |
| 49 | + |
| 50 | + private func makeTargetBuildDescription() throws -> ClangTargetBuildDescription { |
| 51 | + let observability = ObservabilitySystem.makeForTesting(verbose: false) |
| 52 | + return try ClangTargetBuildDescription( |
| 53 | + target: try makeResolvedTarget(), |
| 54 | + toolsVersion: .current, |
| 55 | + buildParameters: mockBuildParameters( |
| 56 | + toolchain: try UserToolchain.default, |
| 57 | + indexStoreMode: .on |
| 58 | + ), |
| 59 | + fileSystem: localFileSystem, |
| 60 | + observabilityScope: observability.topScope |
| 61 | + ) |
| 62 | + } |
| 63 | +} |
0 commit comments