Skip to content

Commit 7bdfee8

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 41cc57e commit 7bdfee8

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
@@ -1715,27 +1715,28 @@ def Main():
17151715
all_unused = [ ]
17161716
unclassified_tests = [ ]
17171717
globally_unused_rules = None
1718-
for path in paths:
1719-
for arch in options.arch:
1720-
for mode in options.mode:
1721-
vm = context.GetVm(arch, mode)
1722-
if not exists(vm):
1723-
print("Can't find shell executable: '%s'" % vm)
1724-
continue
1725-
archEngineContext = Execute([vm, "-p", "process.arch"], context)
1726-
vmArch = archEngineContext.stdout.rstrip()
1727-
if archEngineContext.exit_code != 0 or vmArch == "undefined":
1728-
print("Can't determine the arch of: '%s'" % vm)
1729-
print(archEngineContext.stderr.rstrip())
1730-
continue
1731-
env = {
1732-
'mode': mode,
1733-
'system': utils.GuessOS(),
1734-
'arch': vmArch,
1735-
'type': get_env_type(vm, options.type, context),
1736-
'asan': get_asan_state(vm, context),
1737-
'pointer_compression': get_pointer_compression_state(vm, context),
1738-
}
1718+
1719+
for arch in options.arch:
1720+
for mode in options.mode:
1721+
vm = context.GetVm(arch, mode)
1722+
if not exists(vm):
1723+
print("Can't find shell executable: '%s'" % vm)
1724+
continue
1725+
archEngineContext = Execute([vm, "-p", "process.arch"], context)
1726+
vmArch = archEngineContext.stdout.rstrip()
1727+
if archEngineContext.exit_code != 0 or vmArch == "undefined":
1728+
print("Can't determine the arch of: '%s'" % vm)
1729+
print(archEngineContext.stderr.rstrip())
1730+
continue
1731+
env = {
1732+
'mode': mode,
1733+
'system': utils.GuessOS(),
1734+
'arch': vmArch,
1735+
'type': get_env_type(vm, options.type, context),
1736+
'asan': get_asan_state(vm, context),
1737+
'pointer_compression': get_pointer_compression_state(vm, context),
1738+
}
1739+
for path in paths:
17391740
test_list = root.ListTests([], path, context, arch, mode)
17401741
unclassified_tests += test_list
17411742
cases, unused_rules = config.ClassifyTests(test_list, env)

0 commit comments

Comments
 (0)