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
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
//
// Phase 4: make sure we only compiled LeafModule and OtherModule one time:
//
// RUN: NUM_LEAF_MODULES=$(find %t/modulecache -type f -name 'LeafModule-*.swiftmodule' | wc -l)
// RUN: NUM_OTHER_MODULES=$(find %t/modulecache -type f -name 'OtherModule-*.swiftmodule' | wc -l)
// RUN: if [ ! $NUM_LEAF_MODULES -eq 1 ]; then echo "Should only be 1 LeafModule, found $NUM_LEAF_MODULES"; exit 1; fi
// RUN: if [ ! $NUM_OTHER_MODULES -eq 1 ]; then echo "Should only be 1 OtherModule, found $NUM_OTHER_MODULES"; exit 1; fi
// RUN: %find_files %t/modulecache 'LeafModule-*.swiftmodule' | %llvm_obj_root/bin/count 1
// RUN: %find_files %t/modulecache 'OtherModule-*.swiftmodule' | %llvm_obj_root/bin/count 1
import LeafModule
import OtherModule
7 changes: 3 additions & 4 deletions test/ModuleInterface/ModuleCache/module-cache-options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
// RUN: %target-swift-frontend -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import -I %t -module-cache-path %t/swiftcache -emit-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -emit-module -o /dev/null
// RUN: %target-swift-frontend -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import -I %t -module-cache-path %t/swiftcache -Xcc -fmodules-cache-path=%t/clangcache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %t/main.swift

// RUN: NUM_SWIFT_MODULES=$(find %t/swiftcache -type f -name '*.swiftmodule' | wc -l)
// RUN: NUM_CLANG_MODULES=$(find %t/clangcache -type f -name '*.pcm' | wc -l)
/// Two swift modules, Leaf and Other
// RUN: if [ ! $NUM_SWIFT_MODULES -eq 2 ]; then echo "Should only be 2 Swift Modules, found $NUM_SWIFT_MODULES"; exit 1; fi
// RUN: %find_files %t/swiftcache '*.swiftmodule' | %llvm_obj_root/bin/count 2
/// Two clang modules, shim and A
// RUN: if [ ! $NUM_CLANG_MODULES -eq 2 ]; then echo "Should only be 2 Clang Modules, found $NUM_CLANG_MODULES"; exit 1; fi
// RUN: %find_files %t/clangcache '*.pcm' | %llvm_obj_root/bin/count 2


//--- leaf.swift
public func LeafFunc() {}
Expand Down
2 changes: 2 additions & 0 deletions test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2981,6 +2981,8 @@ config.substitutions.append(('%round-trip-syntax-test',
'%s %s' % (shell_quote(sys.executable),
config.round_trip_syntax_test)))
config.substitutions.append(('%rth', '%s %s' % (shell_quote(sys.executable), config.rth)))
config.substitutions.append(('%find_files', '%s %s' % (shell_quote(sys.executable),
make_path(config.swift_utils, 'find_files'))))
config.substitutions.append(('%scale-test',
'{} {} --swiftc-binary={} --tmpdir=%t --exclude-timers'.format(
shell_quote(sys.executable), config.scale_test,
Expand Down
26 changes: 26 additions & 0 deletions utils/find_files
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python3
# Recursively find files matching a glob pattern. Replaces Unix (find) in lit tests
# for cross-platform compatibility

import sys
from pathlib import Path

def usage():
print("Usage: find_files <directory> <pattern>", file=sys.stderr)
sys.exit(2)

def main():
if len(sys.argv) != 3:
usage()
root, pattern = sys.argv[1], sys.argv[2]
p = Path(root)
if not p.exists():
print(f"Directory not found: {root}", file=sys.stderr)
sys.exit(2)
for x in p.rglob(pattern):
if x.is_file():
print(x)
sys.exit(0)

if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions utils/python_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
_SWIFT_PATH / "utils/symbolicate-linux-fatal",
_SWIFT_PATH / "utils/update-checkout",
_SWIFT_PATH / "utils/viewcfg",
_SWIFT_PATH / "utils/find_files"
]


Expand Down