From c82686a9dc598fe2d677ce6222d876f6e3506cc8 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Fri, 4 Feb 2022 09:35:12 -0700 Subject: test runner: accept -j 0 to mean detect cpu count Signed-off-by: Mats Wichmann --- CHANGES.txt | 2 ++ runtest.py | 31 +++++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 005b0a4..8d3af21 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -46,6 +46,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER Calls now look like 'debug("template %s", text)' rather than 'debug("template %s" % text)' so the logging system does the interpolation only when/if needed (was a pylint warning). + - runtest.py now accepts -j 0 to auto-detect number of usable + processors for testing threads. RELEASE 4.3.0 - Tue, 16 Nov 2021 18:12:46 -0700 diff --git a/runtest.py b/runtest.py index 386e73a..c05e1c1 100755 --- a/runtest.py +++ b/runtest.py @@ -43,7 +43,6 @@ suppress_output = False script = os.path.basename(sys.argv[0]) usagestr = """\ %(script)s [OPTIONS] [TEST ...] - %(script)s -h|--help """ % locals() epilogstr = """\ @@ -86,7 +85,7 @@ parser.add_argument('-D', '--devmode', action='store_true', parser.add_argument('-e', '--external', action='store_true', help="Run the script in external mode (for external Tools)") parser.add_argument('-j', '--jobs', metavar='JOBS', default=1, type=int, - help="Run tests in JOBS parallel jobs.") + help="Run tests in JOBS parallel jobs (0 for cpu_count).") parser.add_argument('-l', '--list', action='store_true', dest='list_only', help="List available tests and exit.") parser.add_argument('-n', '--no-exec', action='store_false', @@ -136,10 +135,10 @@ outctl.add_argument('-s', '--short-progress', action='store_true', outctl.add_argument('-t', '--time', action='store_true', dest='print_times', help="Print test execution time.") outctl.add_argument('--verbose', metavar='LEVEL', type=int, choices=range(1, 4), - help="""Set verbose level: - 1 = print executed commands, - 2 = print commands and non-zero output, - 3 = print commands and all output.""") + help="""Set verbose level + (1=print executed commands, + 2=print commands and non-zero output, + 3=print commands and all output).""") # maybe add? # outctl.add_argument('--version', action='version', version='%s 1.0' % script) @@ -175,7 +174,7 @@ if args.testlistfile: except FileNotFoundError: sys.stderr.write( parser.format_usage() - + "error: -f/--file testlist file \"%s\" not found\n" % p + + 'error: -f/--file testlist file "%s" not found\n' % p ) sys.exit(1) @@ -191,10 +190,26 @@ if args.excludelistfile: except FileNotFoundError: sys.stderr.write( parser.format_usage() - + "error: --exclude-list file \"%s\" not found\n" % p + + 'error: --exclude-list file "%s" not found\n' % p ) sys.exit(1) +if args.jobs == 0: + try: + # on Linux, check available rather then physical CPUs + args.jobs = len(os.sched_getaffinity(0)) + except AttributeError: + # Windows + args.jobs = os.cpu_count() + +# sanity check +if args.jobs == 0: + sys.stderr.write( + parser.format_usage() + + "Unable to detect CPU count, give -j a non-zero value\n" + ) + sys.exit(1) + if args.jobs > 1 or args.output: # 1. don't let tests write stdout/stderr directly if multi-job, # else outputs will interleave and be hard to read. -- cgit v0.12 From 3201282c14f6661d6f7d141f56f21ceabe69d765 Mon Sep 17 00:00:00 2001 From: Vishwajith-K <31800616+Vishwajith-K@users.noreply.github.com> Date: Sat, 5 Feb 2022 22:54:59 +0530 Subject: typo fix --- CONTRIBUTING.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 84d4825..c179678 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -1,7 +1,7 @@ Contributing to SCons ##################### -Introdction +Introduction =========== Thanks for taking the time to contribute! @@ -15,7 +15,7 @@ think we're only interested in contributions to code. If you're going to contribute, we'd love to get to know you a bit and understand and what problems you're looking to solve, -or what you are intending to improve, whether that's documnetation, +or what you are intending to improve, whether that's documentation, code, examples, tutorials, etc. A great way to introduce yourself is to to hop onto the `SCons Discord Server `_ to chat. You don't have to be a regular Discord user, -- cgit v0.12 From bf778b2637ed12c6a7d456a4ffb7f9ad40bdcc97 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sat, 5 Feb 2022 12:26:28 -0700 Subject: Docs: Fix a typo and use more entities [skip appveyor] Fixes #4096 (thanks to @Vishwajith-K for reporting) Changed references in this file to use &consvar; and &consenv; entities. + Use the entity for PATH as well. + Update the entity reference for DUMP. Also fix unrelated missing-entity referring to SConscriptChdir method. Signed-off-by: Mats Wichmann --- SCons/Environment.xml | 2 +- doc/user/troubleshoot.xml | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/SCons/Environment.xml b/SCons/Environment.xml index e10aef3..f471866 100644 --- a/SCons/Environment.xml +++ b/SCons/Environment.xml @@ -2882,7 +2882,7 @@ when all the directories in which SConscript files may be found don't necessarily exist locally.) You may enable and disable this ability by calling -SConscriptChdir() +&f-SConscriptChdir; multiple times. diff --git a/doc/user/troubleshoot.xml b/doc/user/troubleshoot.xml index 3906af6..24020ab 100644 --- a/doc/user/troubleshoot.xml +++ b/doc/user/troubleshoot.xml @@ -261,13 +261,13 @@ file3.c
- What's in That Construction Environment? the &Dump; Method + What's in That Construction Environment? the &f-Dump; Method - When you create a construction environment, + When you create a &consenv;, &SCons; populates it - with construction variables that are set up + with &consvars; that are set up for various compilers, linkers and utilities that it finds on your system. Although this is usually helpful and what you want, @@ -276,10 +276,10 @@ file3.c expect to be set. In situations like this, it's sometimes helpful to use the - construction environment &Dump; method + &consenv; &f-link-Dump; method to print all or some of - the construction variables. - Note that the &Dump; method + the &consvars;. + Note that the &f-Dump; method returns the representation of the variables in the environment @@ -318,11 +318,11 @@ print(env.Dump()) - The construction environments in these examples have + The &consenvs; in these examples have actually been restricted to just gcc and Visual C++, respectively. In a real-life situation, - the construction environments will + the &consenvs; will likely contain a great many more variables. Also note that we've massaged the example output above to make the memory address of all objects a constant 0x700000. @@ -336,7 +336,7 @@ print(env.Dump()) To make it easier to see just what you're interested in, the &Dump; method allows you to - specify a specific constrcution variable + specify a specific &consvar; that you want to disply. For example, it's not unusual to want to verify -- cgit v0.12