|
| 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 | +import SWBTestSupport |
| 15 | +import SWBCore |
| 16 | +import SWBUtil |
| 17 | + |
| 18 | +@Suite |
| 19 | +fileprivate struct MetalTests: CoreBasedTests { |
| 20 | + @Test(.requireSDKs(.macOS), .skipInGitHubActions("Metal toolchain is not installed on GitHub runners")) |
| 21 | + func indexOptions() async throws { |
| 22 | + try await withTemporaryDirectory { tmpDir in |
| 23 | + let testProject = TestProject( |
| 24 | + "ProjectName", |
| 25 | + sourceRoot: tmpDir, |
| 26 | + groupTree: TestGroup( |
| 27 | + "SomeFiles", |
| 28 | + children: [ |
| 29 | + TestFile("File1.metal") |
| 30 | + ]), |
| 31 | + targets: [ |
| 32 | + TestStandardTarget( |
| 33 | + "Test", |
| 34 | + type: .staticLibrary, |
| 35 | + buildConfigurations: [ |
| 36 | + TestBuildConfiguration( |
| 37 | + "Debug", |
| 38 | + buildSettings: [ |
| 39 | + "COMPILER_INDEX_STORE_ENABLE": "YES", |
| 40 | + "INDEX_DATA_STORE_DIR": tmpDir.join("index").str, |
| 41 | + "INDEX_STORE_COMPRESS": "YES", |
| 42 | + "INDEX_STORE_ONLY_PROJECT_FILES": "YES", |
| 43 | + "CLANG_INDEX_STORE_IGNORE_MACROS": "YES", |
| 44 | + ] |
| 45 | + ), |
| 46 | + ], |
| 47 | + buildPhases: [ |
| 48 | + TestSourcesBuildPhase(["File1.metal"]), |
| 49 | + ] |
| 50 | + ) |
| 51 | + ]) |
| 52 | + |
| 53 | + let core = try await getCore() |
| 54 | + let tester = try TaskConstructionTester(core, testProject) |
| 55 | + await tester.checkBuild(BuildParameters(configuration: "Debug", commandLineOverrides: ["INDEX_ENABLE_DATA_STORE": "YES"]), runDestination: .macOS) { results in |
| 56 | + results.checkTask(.matchRuleType("CompileMetalFile")) { compileTask in |
| 57 | + compileTask.checkCommandLineContains(["-index-store-path"]) |
| 58 | + compileTask.checkCommandLineContains(["-index-ignore-system-symbols"]) |
| 59 | + compileTask.checkCommandLineContains(["-index-ignore-pcms"]) |
| 60 | + // metal doesn't support index store compression at the moment. |
| 61 | + compileTask.checkCommandLineDoesNotContain("-index-store-compress") |
| 62 | + } |
| 63 | + } |
| 64 | + // Check that we don't emit any index-related options when INDEX_ENABLE_DATA_STORE is not enabled |
| 65 | + await tester.checkBuild(BuildParameters(configuration: "Debug", commandLineOverrides: [:]), runDestination: .macOS) { results in |
| 66 | + results.checkTask(.matchRuleType("CompileMetalFile")) { compileTask in |
| 67 | + compileTask.checkCommandLineDoesNotContain("-index-store-path") |
| 68 | + compileTask.checkCommandLineDoesNotContain("-index-store-compress") |
| 69 | + compileTask.checkCommandLineDoesNotContain("-index-ignore-system-symbols") |
| 70 | + compileTask.checkCommandLineDoesNotContain("-index-ignore-pcms") |
| 71 | + } |
| 72 | + } |
| 73 | + } |
| 74 | + } |
| 75 | +} |
0 commit comments