mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #84863 from ramonasuncion/test-moduleinterface-replace-find
[Test][ModuleInterface] Replace find with find_files utility
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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() {}
|
||||
|
||||
@@ -2984,6 +2984,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,
|
||||
|
||||
26
utils/find_files
Executable file
26
utils/find_files
Executable file
@@ -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()
|
||||
@@ -56,6 +56,7 @@ _KNOWN_SCRIPT_PATHS = [
|
||||
_SWIFT_PATH / "utils/symbolicate-linux-fatal",
|
||||
_SWIFT_PATH / "utils/update-checkout",
|
||||
_SWIFT_PATH / "utils/viewcfg",
|
||||
_SWIFT_PATH / "utils/find_files"
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user