Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/CAS/cached_diagnostics_remap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
// RUN: -emit-module -o %t/test.swiftmodule /^test/test.swift -cache-replay-prefix-map /^test %t 2>&1 | %FileCheck %s --check-prefix REMAP

// BRIDGE: /^test/objc.h:3:2: warning: warning in bridging header
// BRIDGE-REMAP: BUILD_DIR{{.*}}{{/|\\}}objc.h:3:2: warning: warning in bridging header
// BRIDGE-REMAP: TMP_DIR{{/|\\}}objc.h:3:2: warning: warning in bridging header
// CHECK: /^test/test.swift:1:10: warning: this is a warning
// REMAP: BUILD_DIR{{.*}}{{/|\\}}test.swift:1:10: warning: this is a warning
// REMAP: TMP_DIR{{/|\\}}test.swift:1:10: warning: this is a warning

//--- test.swift
#warning("this is a warning")
Expand Down
2 changes: 1 addition & 1 deletion test/CAS/debug_info_pcm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// RUN: dwarfdump --debug-info @%t/A.path | %FileCheck %s

// CHECK: DW_AT_GNU_dwo_name
// CHECK-SAME: BUILD_DIR
// CHECK-SAME: TMP_DIR

//--- test.swift
import A
Expand Down
8 changes: 4 additions & 4 deletions test/CAS/module_deps_clang_extras.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
// RUN: %validate-json %t/deps.json &>/dev/null

// RUN: %{python} %S/Inputs/SwiftDepsExtractor.py %t/deps.json Test casFSRootID > %t/fs.casid
// RUN: %cache-tool -cas-path %t/cas -cache-tool-action print-include-tree-list @%t/fs.casid | %FileCheck %s -DDIR=%basename_t -check-prefix FS_ROOT
// RUN: %cache-tool -cas-path %t/cas -cache-tool-action print-include-tree-list @%t/fs.casid | %FileCheck %s -check-prefix FS_ROOT

// FS_ROOT: [[DIR]].tmp/hidden/Dummy.h
// FS_ROOT: [[DIR]].tmp/hidden/a.h
// FS_ROOT: [[DIR]].tmp/hidden/b.h
// FS_ROOT: TMP_DIR/hidden/Dummy.h
// FS_ROOT: TMP_DIR/hidden/a.h
// FS_ROOT: TMP_DIR/hidden/b.h

// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json clang:SwiftShims > %t/shim.cmd
// RUN: %swift_frontend_plain @%t/shim.cmd
Expand Down
2 changes: 1 addition & 1 deletion test/Driver/working-directory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

// RUN: cd %t && %swiftc_driver -driver-print-jobs -working-directory %/S/Inputs -Xcc -working-directory -Xcc %/t -c %/s | %FileCheck %s -check-prefix=CLANG
// CLANG: -Xcc -working-directory -Xcc SOURCE_DIR
// CLANG-SAME: -Xcc -working-directory -Xcc BUILD_DIR
// CLANG-SAME: -Xcc -working-directory -Xcc TMP_DIR

// RUN: cd %t && %swiftc_driver -driver-print-jobs -working-directory %/S/Inputs -c main.swift | %FileCheck %s -check-prefix=OUTPUT_IMPLICIT_OBJ
// OUTPUT_IMPLICIT_OBJ: -o {{"?}}SOURCE_DIR/test/Driver/Inputs{{\\\\|/}}main.o
Expand Down
8 changes: 4 additions & 4 deletions test/Macros/macro_plugin_broken_shlib.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
// RUN: c-index-test -read-diagnostics %t/macro_expand.dia 2>&1 | %FileCheck -check-prefix SERVER %s

// SERVER-NOT: {{error|warning}}
// SERVER: test.swift:1:33: warning: external macro implementation type 'TestPlugin.FooMacro' could not be found for macro 'fooMacro'; failed to load library plugin 'BUILD_DIR/{{.*}}/libTestPlugin.dylib' in plugin server 'BUILD_DIR/{{.*}}/swift-plugin-server'; loader error: dlopen(BUILD_DIR/{{.*}}/libTestPlugin.dylib, {{.*}}): tried: 'BUILD_DIR/{{.*}}/plugins/libTestPlugin.dylib'
// SERVER: test.swift:4:7: error: external macro implementation type 'TestPlugin.FooMacro' could not be found for macro 'fooMacro'; failed to load library plugin 'BUILD_DIR/{{.*}}/libTestPlugin.dylib' in plugin server 'BUILD_DIR/{{.*}}/swift-plugin-server'; loader error: dlopen(BUILD_DIR/{{.*}}/libTestPlugin.dylib, {{.*}}): tried: 'BUILD_DIR/{{.*}}/plugins/libTestPlugin.dylib'
// SERVER: test.swift:1:33: warning: external macro implementation type 'TestPlugin.FooMacro' could not be found for macro 'fooMacro'; failed to load library plugin 'TMP_DIR/plugins/libTestPlugin.dylib' in plugin server 'BUILD_DIR/{{.*}}/swift-plugin-server'; loader error: dlopen(TMP_DIR/plugins/libTestPlugin.dylib, {{.*}}): tried: 'TMP_DIR/plugins/libTestPlugin.dylib'
// SERVER: test.swift:4:7: error: external macro implementation type 'TestPlugin.FooMacro' could not be found for macro 'fooMacro'; failed to load library plugin 'TMP_DIR/plugins/libTestPlugin.dylib' in plugin server 'BUILD_DIR/{{.*}}/swift-plugin-server'; loader error: dlopen(TMP_DIR/plugins/libTestPlugin.dylib, {{.*}}): tried: 'TMP_DIR/plugins/libTestPlugin.dylib'
// SERVER: test.swift:1:33: note: 'fooMacro' declared here
// SERVER-NOT: {{error|warning}}

Expand All @@ -34,8 +34,8 @@
// RUN: c-index-test -read-diagnostics %t/macro_expand_inproc.dia 2>&1 | %FileCheck -check-prefix INPROC %s

// INPROC-NOT: {{error|warning}}
// INPROC: test.swift:1:33: warning: external macro implementation type 'TestPlugin.FooMacro' could not be found for macro 'fooMacro'; failed to load library plugin 'BUILD_DIR/{{.*}}/libTestPlugin.dylib' in plugin server 'BUILD_DIR/{{.*}}/libSwiftInProcPluginServer.dylib'; loader error: dlopen(BUILD_DIR/{{.*}}/libTestPlugin.dylib, 0x0005): tried: 'BUILD_DIR/{{.*}}/libTestPlugin.dylib'
// INPROC: test.swift:4:7: error: external macro implementation type 'TestPlugin.FooMacro' could not be found for macro 'fooMacro'; failed to load library plugin 'BUILD_DIR/{{.*}}/libTestPlugin.dylib' in plugin server 'BUILD_DIR/{{.*}}/libSwiftInProcPluginServer.dylib'; loader error: dlopen(BUILD_DIR/{{.*}}/libTestPlugin.dylib, 0x0005): tried: 'BUILD_DIR/{{.*}}/libTestPlugin.dylib'
// INPROC: test.swift:1:33: warning: external macro implementation type 'TestPlugin.FooMacro' could not be found for macro 'fooMacro'; failed to load library plugin 'TMP_DIR/plugins/libTestPlugin.dylib' in plugin server 'BUILD_DIR/{{.*}}/libSwiftInProcPluginServer.dylib'; loader error: dlopen(TMP_DIR/plugins/libTestPlugin.dylib, 0x0005): tried: 'TMP_DIR/plugins/libTestPlugin.dylib'
// INPROC: test.swift:4:7: error: external macro implementation type 'TestPlugin.FooMacro' could not be found for macro 'fooMacro'; failed to load library plugin 'TMP_DIR/plugins/libTestPlugin.dylib' in plugin server 'BUILD_DIR/{{.*}}/libSwiftInProcPluginServer.dylib'; loader error: dlopen(TMP_DIR/plugins/libTestPlugin.dylib, 0x0005): tried: 'TMP_DIR/plugins/libTestPlugin.dylib'
// INPROC: test.swift:1:33: note: 'fooMacro' declared here
// INPROC-NOT: {{error|warning}}

Expand Down
1 change: 0 additions & 1 deletion test/ModuleInterface/ModuleCache/SDKDependencies.swift
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@
//
// DEPCHANGE-DAG: SdkLib.swiftinterface
// DEPCHANGE-DAG: ExportedLib.swiftinterface
// DEPCHANGE-DAG: SDKDependencies.swift
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bnbarham Turns out this matcher doesn't actually match a file name, just a substring in the expansion of the %t path. There are other matchers in this file that do still match a file name like intended, so I'm not sure if this is just a mistake in the test, or indicative of a regression.

Copy link
Contributor

@bnbarham bnbarham Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably more of a @nkcsgexi, but this seems fine as the test is written - we're not building SDKDependencies.swift here so it makes sense it's not in the dependencies. Though I'm unclear if it was meant to be building SDKDependencies.swift here or not (ie. %s rather than - in the run line above)


import SdkLib

Expand Down
2 changes: 1 addition & 1 deletion test/ModuleInterface/availability-scopes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// RUN: %target-swift-typecheck-module-from-interface(%t/Test.swiftinterface) -module-name Test -dump-availability-scopes 2>&1 | %FileCheck --strict-whitespace %s
// RUN: %target-swift-frontend -compile-module-from-interface %t/Test.swiftinterface -o /dev/null -module-name Test -dump-availability-scopes 2>&1 | %FileCheck --strict-whitespace %s

// CHECK: {{^}}(root {{.*}} file={{.*}}{{/|\\}}availability-scopes.swift.tmp{{/|\\}}Test.swiftinterface
// CHECK: {{^}}(root {{.*}} file=TMP_DIR{{/|\\}}Test.swiftinterface
// CHECK: {{^}} (decl {{.*}}unavailable=* decl=unavailable()
@available(*, unavailable)
public func unavailable() { }
4 changes: 2 additions & 2 deletions test/SILGen/magic_identifier_file_conflicting.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def fixit_loc(start_col, orig_suffix):
//

// CHECK-LABEL: // Mappings from '#fileID' to '#filePath':
// CHECK-NEXT: // 'Foo/magic_identifier_file_conflicting.swift' => 'BUILD_DIR{{.*}}{{[/\\]}}test-{{[^/]+}}{{[/\\]}}SILGen{{[/\\]}}Output{{[/\\]}}magic_identifier_file_conflicting.swift.gyb.tmp{{[/\\]}}magic_identifier_file_conflicting.swift'
// CHECK-NEXT: // 'Foo/magic_identifier_file_conflicting.swift' => 'BUILD_DIR{{.*}}{{[/\\]}}test-{{[^/]+}}{{[/\\]}}SILGen{{[/\\]}}Output{{[/\\]}}magic_identifier_file_conflicting.swift.gyb.tmp{{[/\\]}}other_path_b{{[/\\]}}magic_identifier_file_conflicting.swift' (alternate)
// CHECK-NEXT: // 'Foo/magic_identifier_file_conflicting.swift' => 'TMP_DIR{{[/\\]}}magic_identifier_file_conflicting.swift'
// CHECK-NEXT: // 'Foo/magic_identifier_file_conflicting.swift' => 'TMP_DIR{{[/\\]}}other_path_b{{[/\\]}}magic_identifier_file_conflicting.swift' (alternate)
// CHECK-NEXT: // 'Foo/magic_identifier_file_conflicting.swift' => 'magic_identifier_file_conflicting.swift' (alternate)
// CHECK-NEXT: // 'Foo/magic_identifier_file_conflicting_other.swift' => 'SOURCE_DIR{{[/\\]}}test{{[/\\]}}SILGen{{[/\\]}}Inputs{{[/\\]}}magic_identifier_file_conflicting_other.swift'
// CHECK-NEXT: // 'Foo/other_file_a.swift' => 'other_file_a.swift'
Expand Down
2 changes: 1 addition & 1 deletion test/ScanDependencies/binary_module_only.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foo

// BINARY_MODULE_ONLY: "swiftPrebuiltExternal": "Foo"
// BINARY_MODULE_ONLY: "swiftPrebuiltExternal": {
// BINARY_MODULE_ONLY-NEXT: "compiledModulePath": "BUILD_DIR/{{.*}}/ScanDependencies/Output/binary_module_only.swift.tmp/binaryModuleOnly/Foo.swiftmodule",
// BINARY_MODULE_ONLY-NEXT: "compiledModulePath": "TMP_DIR/binaryModuleOnly/Foo.swiftmodule",

// HAS_NO_COMPILED-NOT: "{{.*}}Foo.swiftmodule{{.*}}.swiftmodule"

Expand Down
2 changes: 1 addition & 1 deletion test/ScanDependencies/cxx-overlay-source-lookup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/// --------Main module
// CHECK-LABEL: "modulePath": "deps.swiftmodule",
// CHECK-NEXT: "sourceFiles": [
// CHECK-NEXT: cxx-overlay-source-lookup.swift
// CHECK-NEXT: client.swift
// CHECK-NEXT: ],
// CHECK: "directDependencies": [
// CHECK-DAG: "swift": "Swift"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// RUN: not %target-swift-frontend -scan-dependencies -module-cache-path %t/module-cache %t/test.swift -o %t/deps.json -I %t/inputs -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import -module-name CycleKit &> %t/out.txt
// RUN: %FileCheck --check-prefix=CHECK-NONSDK %s < %t/out.txt

// CHECK-NONSDK: note: source target 'CycleKit' shadowing a Swift module with the same name at: '{{.*}}{{/|\\}}diagnose_dependency_cycle_shadow.swift.tmp{{/|\\}}inputs'
// CHECK-NONSDK: note: source target 'CycleKit' shadowing a Swift module with the same name at: 'TMP_DIR{{/|\\}}inputs'

// SDK dependency shadowing
// RUN: not %target-swift-frontend -scan-dependencies -module-cache-path %t/module-cache %t/test.swift -o %t/deps.json -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import -module-name CycleKit -sdk %t/mock.sdk &> %t/out-sdk.txt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

// RUN: %target-swift-frontend -emit-module -emit-module-path %t/Foo.swiftmodule -disable-implicit-swift-modules -module-cache-path %t.module-cache -explicit-swift-module-map-file %t/inputs/map.json -Rmodule-loading -Xcc -Rmodule-import %s 2>&1 | %FileCheck %s

// CHECK: <unknown>:0: remark: importing module 'A' from {{.*}}{{/|\\}}explicit-module-map-clang-and-swift.swift.tmp{{/|\\}}inputs{{/|\\}}A.pcm'
// CHECK: <unknown>:0: remark: importing module 'A' from 'TMP_DIR{{/|\\}}inputs{{/|\\}}A.pcm'

import A

Expand Down
16 changes: 8 additions & 8 deletions test/ScanDependencies/preserve_used_vfs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,34 +131,34 @@ func testIndirect() { funcRedirectedIndirect() }
// CHECK: "-compile-module-from-interface"
// CHECK: "-ivfsoverlay",
// CHECK-NEXT: "-Xcc",
// CHECK-NEXT: "{{.*}}{{/|\\}}preserve_used_vfs.swift.tmp{{/|\\}}overlay.yaml",
// CHECK-NEXT: "TMP_DIR{{/|\\}}overlay.yaml",
// CHECK-NEXT: "-Xcc",
// CHECK-NEXT: "-ivfsoverlay",
// CHECK-NEXT: "-Xcc",
// CHECK-NEXT: "{{.*}}{{/|\\}}preserve_used_vfs.swift.tmp{{/|\\}}overlay-2.yaml",
// CHECK-NEXT: "TMP_DIR{{/|\\}}overlay-2.yaml",
// CHECK: ],

/// --------Clang module F
// CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}F-{{.*}}.pcm",
// CHECK: "commandLine": [
// CHECK: "-vfsoverlay",
// CHECK-NEXT: "{{.*}}{{/|\\}}preserve_used_vfs.swift.tmp{{/|\\}}overlay.yaml",
// CHECK-NEXT: "TMP_DIR{{/|\\}}overlay.yaml",
// CHECK-NEXT: "-vfsoverlay",
// CHECK-NEXT: "{{.*}}{{/|\\}}preserve_used_vfs.swift.tmp{{/|\\}}overlay-2.yaml",
// CHECK-NEXT: "TMP_DIR{{/|\\}}overlay-2.yaml",
// CHECK: "-ivfsoverlay",
// CHECK-NEXT: "-Xcc",
// CHECK-NEXT: "{{.*}}{{/|\\}}preserve_used_vfs.swift.tmp{{/|\\}}overlay.yaml",
// CHECK-NEXT: "TMP_DIR{{/|\\}}overlay.yaml",
// CHECK-NEXT: "-Xcc",
// CHECK-NEXT: "-ivfsoverlay",
// CHECK-NEXT: "-Xcc",
// CHECK-NEXT: "{{.*}}{{/|\\}}preserve_used_vfs.swift.tmp{{/|\\}}overlay-2.yaml",
// CHECK-NEXT: "TMP_DIR{{/|\\}}overlay-2.yaml",
// CHECK: ]

/// --------Clang module Indirect
// CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}Indirect-{{.*}}.pcm",
// CHECK-NOT: overlay.yaml
// CHECK: "-vfsoverlay",
// CHECK-NEXT: "{{.*}}{{/|\\}}preserve_used_vfs.swift.tmp{{/|\\}}overlay-2.yaml",
// CHECK-NEXT: "TMP_DIR{{/|\\}}overlay-2.yaml",
// CHECK: "-ivfsoverlay",
// CHECK-NEXT: "-Xcc",
// CHECK-NEXT: "{{.*}}{{/|\\}}preserve_used_vfs.swift.tmp{{/|\\}}overlay-2.yaml",
// CHECK-NEXT: "TMP_DIR{{/|\\}}overlay-2.yaml",
6 changes: 3 additions & 3 deletions test/ScanDependencies/separate_clang_scan_cache.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// RUN: %empty-directory(%t.module-cache)
// RUN: %empty-directory(%t.scanner-cache)

// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t.module-cache -clang-scanner-module-cache-path %t.scanner-cache %s -o %t.deps.json -I %S/Inputs/SwiftDifferent -dump-clang-diagnostics 2>&1 | %FileCheck %s --check-prefix=CHECK-CLANG-COMMAND
// RUN: %validate-json %t.deps.json | %FileCheck %s --check-prefix=CHECK-DEPS
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t.module-cache -clang-scanner-module-cache-path %t.scanner-cache %s -o %t.deps.json -I %S/Inputs/SwiftDifferent -dump-clang-diagnostics 2>&1 | %FileCheck %s --check-prefix=CHECK-CLANG-COMMAND --enable-yaml-compatibility
// RUN: %validate-json %t.deps.json | %FileCheck %s --check-prefix=CHECK-DEPS --enable-yaml-compatibility

// Ensure we prefer clang scanner module cache path
// CHECK-CLANG-COMMAND: '-fmodules-cache-path={{.*}}.scanner-cache'

// Ensure we the modules' output path is set to the module cache
// CHECK-DEPS: "swift": "A"
// CHECK-DEPS: "swift": "A"
// CHECK-DEPS: "modulePath": "{{.*}}separate_clang_scan_cache.swift.tmp.module-cache{{/|\\\\}}A-{{.*}}.swiftmodule"
// CHECK-DEPS: "modulePath": "TMP_DIR.module-cache{{/|\\\\}}A-{{.*}}.swiftmodule"

import A
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// RUN: %empty-directory(%t.module-cache)
// RUN: %empty-directory(%t.scanner-cache)

// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t.module-cache -clang-scanner-module-cache-path %t.scanner-cache %s -o %t.deps.json -I %S/Inputs/SwiftDifferent -import-objc-header %S/Inputs/CHeaders/Bridging.h -dump-clang-diagnostics 2>&1 | %FileCheck %s --check-prefix=CHECK-CLANG-COMMAND
// RUN: %validate-json %t.deps.json | %FileCheck %s --check-prefix=CHECK-DEPS
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t.module-cache -clang-scanner-module-cache-path %t.scanner-cache %s -o %t.deps.json -I %S/Inputs/SwiftDifferent -import-objc-header %S/Inputs/CHeaders/Bridging.h -dump-clang-diagnostics 2>&1 | %FileCheck %s --check-prefix=CHECK-CLANG-COMMAND --enable-yaml-compatibility
// RUN: %validate-json %t.deps.json | %FileCheck %s --check-prefix=CHECK-DEPS --enable-yaml-compatibility

// Ensure we prefer clang scanner module cache path
// CHECK-CLANG-COMMAND: '-fmodules-cache-path={{.*}}.scanner-cache'
Expand All @@ -14,12 +14,12 @@
// CHECK-DEPS: "clang": "F"
// CHECK-DEPS-NEXT: },
// CHECK-DEPS-NEXT: {
// CHECK-DEPS-NEXT: "modulePath": "{{.*}}separate_clang_scan_cache_bridging.swift.tmp.module-cache{{/|\\\\}}F-{{.*}}.pcm"
// CHECK-DEPS-NEXT: "modulePath": "TMP_DIR.module-cache{{/|\\\\}}F-{{.*}}.pcm"

// CHECK-DEPS: "swift": "A"
// CHECK-DEPS-NEXT: },
// CHECK-DEPS-NEXT: {
// CHECK-DEPS-NEXT: "modulePath": "{{.*}}separate_clang_scan_cache_bridging.swift.tmp.module-cache{{/|\\\\}}A-{{.*}}.swiftmodule"
// CHECK-DEPS-NEXT: "modulePath": "TMP_DIR.module-cache{{/|\\\\}}A-{{.*}}.swiftmodule"



Expand Down
2 changes: 1 addition & 1 deletion test/SourceKit/Indexing/indexstore_multifile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct Foo {
// CHECK: indexstore_multifile.o-{{.*}}
// CHECK: module-name: indexstoremodule
// CHECK: main-path: SOURCE_DIR{{/|\\}}test{{/|\\}}SourceKit{{/|\\}}Indexing{{/|\\}}indexstore_multifile.swift
// CHECK: out-file: BUILD_DIR{{.*}}indexstore_multifile.o
// CHECK: out-file: TMP_DIR{{/|\\}}indexstore_multifile.o
// CHECK: is-debug: 1
// CHECK: Unit | system | Swift | {{.*}}{{/|\\}}Swift.swiftmodule
// CHECK: Record | user | SOURCE_DIR{{/|\\}}test{{/|\\}}SourceKit{{/|\\}}Indexing{{/|\\}}indexstore_multifile.swift | indexstore_multifile.swift-{{.*}}
13 changes: 4 additions & 9 deletions test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3114,17 +3114,12 @@ if hasattr(config, 'target_link_sdk_future_version'):
config.substitutions.append(('%target-link-sdk-future-version',
config.target_link_sdk_future_version))

run_filecheck = '%s %s --allow-unused-prefixes --sanitize BUILD_DIR=%s --sanitize SOURCE_DIR=%s --ignore-runtime-warnings --use-filecheck %s %s %s' % (
run_filecheck = '%s %s --allow-unused-prefixes --sanitize TMP_DIR=%s --sanitize BUILD_DIR=%s --sanitize SOURCE_DIR=%s --ignore-runtime-warnings --use-filecheck %s %s %s' % (
shell_quote(sys.executable),
shell_quote(config.PathSanitizingFileCheck),
# LLVM Lit performs realpath with the config path, so all paths are relative
# to the real path. cmake_binary_dir and swift_src_root come from CMake, which
# might not do real path. Because we have to match what Lit uses against what
# we provide we use realpath here. Because PathSanitizingFileCheck only
# understands sanitize patterns with forward slashes, and realpath normalizes
# the slashes, we have to replace them back to forward slashes.
shell_quote(lit.util.abs_path_preserve_drive(config.cmake_binary_dir).replace("\\", "/")),
shell_quote(lit.util.abs_path_preserve_drive(config.swift_src_root).replace("\\", "/")),
shell_quote('%t'),
shell_quote(config.cmake_binary_dir),
shell_quote(config.swift_src_root),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like its breaking developer setups. The abs_path_preserve_drive is critical to ensure that the correct drive is referenced

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

normalize_if_path does the same thing but in PathSanitizingFileCheck, since %t can't be passed to abs_path_preserve_drive before test execution.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I follow; I don't see the call to it there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shell_quote(config.filecheck),
'--color' if config.color_output else '',
'--enable-windows-compatibility' if kIsWindows else '')
Expand Down
20 changes: 18 additions & 2 deletions utils/PathSanitizingFileCheck
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,26 @@

import argparse
import io
import os
import platform
import re
import subprocess
import sys

# LLVM Lit performs realpath with the config path, so all paths are relative
# to the real path. Paths that come from CMake (like cmake_binary_dir and
# swift_src_root), might not do real path. Use realpath to normalize. Because
# this normalizes Windows paths to use backslashes, we have to replace them
# back to forward slashes.
def normalize_if_path(s):
# Check dirname for cases like a file named `%t.out.txt`
# There won't be a `%t` path, but we still want to match this path substring.
if not os.path.exists(s) and not os.path.exists(os.path.dirname(s)):
return s
if platform.system() == "Windows":
return os.path.abspath(s).replace('\\', '/')
else:
return os.path.realpath(s)

def main():
parser = argparse.ArgumentParser(
Expand Down Expand Up @@ -78,13 +94,13 @@ constants.""")

stdin = io.open(sys.stdin.fileno(), 'r', encoding='utf-8', errors='ignore').read()

for s in args.sanitize_strings:
for s in sorted(args.sanitize_strings, key=len, reverse=True):
replacement, pattern = s.split('=', 1)
# Since we want to use pattern as a regex in some platforms, we need
# to escape it first, and then replace the escaped slash
# literal (r'\\/') for our platform-dependent slash regex.
stdin = re.sub(re.sub(r'\\/' if sys.version_info[0] < 3 else r'/',
slashes_re, re.escape(pattern)),
slashes_re, re.escape(normalize_if_path(pattern))),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@compnerd This is the call to normalize_if_path

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but I don't see the call to the function inside the implementation of normalize_if_path.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see. It basically does the same thing, with some extra on top. Here's what the implementation of abs_path_preserve_drive looks like: https://github.com/llvm/llvm-project/blob/27d8441f8282c740903529d8a6b73401fc6c17fa/llvm/utils/lit/lit/util.py#L124

replacement, stdin)

# Because we force the backtracer on in the tests, we can get runtime
Expand Down