diff options
author | Dylan Baker <baker.dylan.c@gmail.com> | 2013-03-08 11:46:44 -0800 |
---|---|---|
committer | Jordan Justen <jordan.l.justen@intel.com> | 2013-03-10 15:20:27 -0700 |
commit | 11e264ca913415d26c0dadd72e75c810691b1230 (patch) | |
tree | 4b479e752a8a399645eb52bbcecc998fd0df5199 /piglit-run.py | |
parent | 8eaa110624660a60c882e66ea95c004e2ea27ae2 (diff) |
Move re.compile for regex into Core
Move the re.compile into the core.Enivironment constructor, which
reduces code duplication. It also allows us to pass environment data on
initilization of the object, rather that having edit it's attributes
individually.
V2: - Does not remove deprecated options, only marks them as such
V3: - Fixes deperecated warning for tests from V2 always being triggered
Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Diffstat (limited to 'piglit-run.py')
-rwxr-xr-x | piglit-run.py | 60 |
1 files changed, 25 insertions, 35 deletions
diff --git a/piglit-run.py b/piglit-run.py index e5e382269..6d6ec770f 100755 --- a/piglit-run.py +++ b/piglit-run.py @@ -24,7 +24,6 @@ import argparse import os.path as path -import re import sys, os import time import traceback @@ -39,11 +38,8 @@ from framework.threads import synchronized_self ############################################################################# def main(): - env = core.Environment() - parser = argparse.ArgumentParser(sys.argv) - # Either require that a name for the test is passed or that # resume is requested excGroup1 = parser.add_mutually_exclusive_group() @@ -55,8 +51,10 @@ def main(): action = "store_true", help = "Resume an interupted test run") + # Setting the --dry-run flag is equivalent to env.execute=false parser.add_argument("-d", "--dry-run", - action = "store_true", + action = "store_false", + dest = "execute", help = "Do not execute the tests") parser.add_argument("-t", "--include-tests", default = [], @@ -81,7 +79,8 @@ def main(): # supplied, or it throws an error excGroup2 = parser.add_mutually_exclusive_group() excGroup2.add_argument("--no-concurrency", - action = "store_true", + action = "store_false", + dest = "concurrency", help = "Disable concurrent test runs") excGroup2.add_argument("-c", "--concurrent", action = "store", @@ -109,33 +108,26 @@ def main(): if args.platform is not None: os.environ['PIGLIT_PLATFORM'] = args.platform - # Set dry-run - if args.dry_run is True: - env.execute = False - - # Set valgrind - if args.valgrind is True: - env.valgrind = True - - # Turn concurency off if requested - # Deprecated + # Deprecated: + # If the deprecated -c, --concurrent flag is passed, override + # args.concurrency (which would otherwise be set by the --no-concurrency) + # flag and print a warning. if args.concurrent is not None: if (args.concurrent == '1' or args.concurrent == 'on'): - env.concurrent = True + args.concurrency = True print "Warning: Option -c, --concurrent is deprecated, " \ "concurrent test runs are on by default" elif (args.concurrent == '0' or args.concurrent == 'off'): - env.concurrent = False + args.concurrency = False print "Warning: Option -c, --concurrent is deprecated, " \ "use --no-concurrency for non-concurrent test runs" # Ne need for else, since argparse restricts the arguments allowed - # Not deprecated - elif args.no_concurrency is True: - env.concurrent = False - # If the deprecated tests option was passed print a warning if args.tests != []: + # This merges any options passed into the --tests option into the + # ones passed into -t or --tests-include and throws out duplicates + args.include_tests = list(set(args.include_tests + args.tests)) print "Warning: Option --tests is deprecated, use " \ "--include-tests instead" @@ -147,25 +139,23 @@ def main(): # Load settings from the old results JSON old_results = core.loadTestResults(resultsDir) profileFilename = old_results.options['profile'] - for value in old_results.options['filter']: - test_filter.append(value) - env.filter.append(re.compile(value)) - for value in old_results.options['exclude_filter']: - exclude_filter.append(value) - env.exclude_filter.append(re.compile(value)) + + # Changing the args to the old args allows us to set them + # all in one places down the way + args.exclude_tests = old_results.options['exclude_filter'] + args.include_tests = old_results.options['filter'] # Otherwise parse additional settings from the command line else: profileFilename = args.testProfile resultsDir = args.resultsPath - # Set the excluded and included tests regex - for each in args.include_tests: - env.filter.append(re.compile(each)) - for each in args.tests: - env.filter.append(re.compile(each)) - for each in args.exclude_tests: - env.exclude_filter.append(re.compile(each)) + # Pass arguments into Environment + env = core.Environment(concurrent=args.concurrency, + exclude_filter=args.exclude_tests, + include_filter=args.include_tests, + execute=args.execute, + valgrind=args.valgrind) # Change working directory to the root of the piglit directory piglit_dir = path.dirname(path.realpath(sys.argv[0])) |