From 0589987e7f139b3257fd3c7d391832194f392479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bergstr=C3=B6m?= Date: Thu, 31 Dec 2015 17:32:42 +1100 Subject: [PATCH] test: inherit JOBS from environment In some virtualized environments the amount of available resources are misleading; for instance `multiprocessing.cpu_count()` on our current 4-core smartos vm's returns `48`. This is not a bug, merely how the vm host provides information about available hardware. Avoid running into issues by overriding `cpu_count()` with `JOBS`. PR-URL: https://github.com/nodejs/node/pull/4495 Reviewed-By: Brian White --- tools/test.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/test.py b/tools/test.py index 4baca769c25ee5..a864b0ef6140d3 100755 --- a/tools/test.py +++ b/tools/test.py @@ -1337,7 +1337,10 @@ def ProcessOptions(options): print "The test group to run (n) must be smaller than number of groups (m)." return False if options.J: - options.j = multiprocessing.cpu_count() + # inherit JOBS from environment if provided. some virtualised systems + # tends to exaggerate the number of available cpus/cores. + cores = os.environ.get('JOBS') + options.j = int(cores) if cores is not None else multiprocessing.cpu_count() if options.flaky_tests not in ["run", "skip", "dontcare"]: print "Unknown flaky-tests mode %s" % options.flaky_tests return False