2828 _SWIFT_PATH / "benchmark/scripts/Benchmark_Driver" ,
2929 _SWIFT_PATH / "benchmark/scripts/Benchmark_DTrace.in" ,
3030 _SWIFT_PATH / "benchmark/scripts/Benchmark_GuardMalloc.in" ,
31+ _SWIFT_PATH / "benchmark/scripts/Benchmark_QuickCheck.in" ,
3132 _SWIFT_PATH / "benchmark/scripts/Benchmark_RuntimeLeaksRunner.in" ,
33+ _SWIFT_PATH / "benchmark/scripts/run_smoke_bench" ,
3234 _SWIFT_PATH / "docs/scripts/ns-html2rst" ,
3335 _SWIFT_PATH / "test/Driver/Inputs/fake-toolchain/ld" ,
3436 _SWIFT_PATH / "utils/80+-check" ,
@@ -100,6 +102,14 @@ def _is_package_installed(name):
100102def parse_args ():
101103 parser = argparse .ArgumentParser ()
102104
105+ parser .add_argument (
106+ "paths" ,
107+ type = Path ,
108+ metavar = "PATH" ,
109+ nargs = "*" ,
110+ help = "Source path to format." ,
111+ )
112+
103113 parser .add_argument (
104114 "--check" ,
105115 action = "store_true" ,
@@ -110,7 +120,7 @@ def parse_args():
110120 "-v" ,
111121 "--verbose" ,
112122 action = "store_true" ,
113- help = "Also emit messages to stderr about files that were not changed" ,
123+ help = "Emit messages to stderr about files that were not changed. " ,
114124 )
115125
116126 return parser .parse_args ()
@@ -136,7 +146,23 @@ def main():
136146 if args .verbose :
137147 command .append ("--verbose" )
138148
139- command += [str (path ) for path in _get_python_sources ()]
149+ requested_paths = [path .resolve () for path in args .paths ]
150+
151+ # Narrow down the set of paths to format to only those paths which are either
152+ # included in the set of requested paths or are subpaths of the requested paths.
153+ format_paths = {
154+ known_path
155+ for path in requested_paths
156+ for known_path in _get_python_sources ()
157+ if path == known_path or path in known_path .parents
158+ }
159+
160+ # Add requested paths that exists, but aren't included in the format set.
161+ for path in requested_paths :
162+ if path not in format_paths and path .exists ():
163+ format_paths .add (path )
164+
165+ command += sorted ([str (path ) for path in format_paths ])
140166
141167 return subprocess .call (command )
142168
0 commit comments