diff --git a/test/ModuleInterface/ModuleCache/module-cache-deployment-target-irrelevant.swift b/test/ModuleInterface/ModuleCache/module-cache-deployment-target-irrelevant.swift index 13f132c586477..24b452967577a 100644 --- a/test/ModuleInterface/ModuleCache/module-cache-deployment-target-irrelevant.swift +++ b/test/ModuleInterface/ModuleCache/module-cache-deployment-target-irrelevant.swift @@ -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 diff --git a/test/ModuleInterface/ModuleCache/module-cache-options.swift b/test/ModuleInterface/ModuleCache/module-cache-options.swift index 7e271444276d1..57ba2a6dfd1f5 100644 --- a/test/ModuleInterface/ModuleCache/module-cache-options.swift +++ b/test/ModuleInterface/ModuleCache/module-cache-options.swift @@ -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() {} diff --git a/test/lit.cfg b/test/lit.cfg index 344a12183c8a5..ee7b14908c65b 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -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, diff --git a/utils/find_files b/utils/find_files new file mode 100755 index 0000000000000..e6b271c5c6fb9 --- /dev/null +++ b/utils/find_files @@ -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 ", 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() \ No newline at end of file diff --git a/utils/python_format.py b/utils/python_format.py index dd7ff32f0888a..d0e406e90acb0 100755 --- a/utils/python_format.py +++ b/utils/python_format.py @@ -56,6 +56,7 @@ _SWIFT_PATH / "utils/symbolicate-linux-fatal", _SWIFT_PATH / "utils/update-checkout", _SWIFT_PATH / "utils/viewcfg", + _SWIFT_PATH / "utils/find_files" ]