Skip to content

Commit 47fa765

Browse files
joyeecheungaduh95
authored andcommitted
tools: optimize wildcard execution in tools/test.py
Previously for each matching test, it would execute multiple `node -p` commands to decide the configurations of the executable. That means if there are 100 tests matched, it will run the Node.js executable 4*100 times to retrieve the same configurations repeatedly. This changes the loop order so that it only execute these commands once and reuse the results for all matching tests. PR-URL: #60266 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]>
1 parent df8396a commit 47fa765

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

tools/test.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,27 +1712,28 @@ def Main():
17121712
all_unused = [ ]
17131713
unclassified_tests = [ ]
17141714
globally_unused_rules = None
1715-
for path in paths:
1716-
for arch in options.arch:
1717-
for mode in options.mode:
1718-
vm = context.GetVm(arch, mode)
1719-
if not exists(vm):
1720-
print("Can't find shell executable: '%s'" % vm)
1721-
continue
1722-
archEngineContext = Execute([vm, "-p", "process.arch"], context)
1723-
vmArch = archEngineContext.stdout.rstrip()
1724-
if archEngineContext.exit_code != 0 or vmArch == "undefined":
1725-
print("Can't determine the arch of: '%s'" % vm)
1726-
print(archEngineContext.stderr.rstrip())
1727-
continue
1728-
env = {
1729-
'mode': mode,
1730-
'system': utils.GuessOS(),
1731-
'arch': vmArch,
1732-
'type': get_env_type(vm, options.type, context),
1733-
'asan': get_asan_state(vm, context),
1734-
'pointer_compression': get_pointer_compression_state(vm, context),
1735-
}
1715+
1716+
for arch in options.arch:
1717+
for mode in options.mode:
1718+
vm = context.GetVm(arch, mode)
1719+
if not exists(vm):
1720+
print("Can't find shell executable: '%s'" % vm)
1721+
continue
1722+
archEngineContext = Execute([vm, "-p", "process.arch"], context)
1723+
vmArch = archEngineContext.stdout.rstrip()
1724+
if archEngineContext.exit_code != 0 or vmArch == "undefined":
1725+
print("Can't determine the arch of: '%s'" % vm)
1726+
print(archEngineContext.stderr.rstrip())
1727+
continue
1728+
env = {
1729+
'mode': mode,
1730+
'system': utils.GuessOS(),
1731+
'arch': vmArch,
1732+
'type': get_env_type(vm, options.type, context),
1733+
'asan': get_asan_state(vm, context),
1734+
'pointer_compression': get_pointer_compression_state(vm, context),
1735+
}
1736+
for path in paths:
17361737
test_list = root.ListTests([], path, context, arch, mode)
17371738
unclassified_tests += test_list
17381739
cases, unused_rules = config.ClassifyTests(test_list, env)

0 commit comments

Comments
 (0)