[Piglit] [PATCH v3 7/7] Move re.compile for regex into Core

Ken Phillis Jr kphillisjr at gmail.com
Sun Mar 10 17:47:14 PDT 2013


I just noticed that two of the commits had a typo... however, it
appears to be fixed in the latest commitss:

http://cgit.freedesktop.org/piglit/commit/?id=ee9b0a8d27d9ef5025336559c6dee4e387074af3
http://cgit.freedesktop.org/piglit/commit/?id=4e693a861158cf146b885e552d2297cec00a3170

DEPRICATED should be DEPRECATED

Also, I noticed that the deprecation warning has two different case
sets where one is "Deprecated:" and "DEPRECATED:"... these probably
should be made the same when printing out the information.
On Sun, Mar 10, 2013 at 5:27 PM, Jordan Justen <jljusten at gmail.com> wrote:
> v3 is now pushed.
>
> I fixed two typos related to --no-concurrency, and made
> piglit-print-commands.py also use args.tests != [].
>
> Thanks,
>
> -Jordan
>
> On Fri, Mar 8, 2013 at 11:46 AM, Dylan Baker <baker.dylan.c at gmail.com> wrote:
>> 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 at gmail.com>
>> ---
>>  framework/core.py        | 26 +++++++++++++++------
>>  piglit-print-commands.py | 29 +++++++++++------------
>>  piglit-run.py            | 60 ++++++++++++++++++++----------------------------
>>  3 files changed, 58 insertions(+), 57 deletions(-)
>>
>> diff --git a/framework/core.py b/framework/core.py
>> index 645598f..3856ddf 100644
>> --- a/framework/core.py
>> +++ b/framework/core.py
>> @@ -371,14 +371,26 @@ class TestrunResult:
>>  #############################################################################
>>
>>  class Environment:
>> -       def __init__(self):
>> -               # If disabled, runs all tests serially from the main thread.
>> -               self.concurrent = True
>> -               self.execute = True
>> -               self.filter = []
>> +       def __init__(self, concurrent=True, execute=True, include_filter=[],
>> +                       exclude_filter=[], valgrind=False):
>> +               self.concurrent     = concurrent
>> +               self.execute        = execute
>> +               self.filter         = []
>>                 self.exclude_filter = []
>> -               self.exclude_tests = set()
>> -               self.valgrind = False
>> +               self.exclude_tests  = set()
>> +               self.valgrind       = valgrind
>> +
>> +               """
>> +               The filter lists that are read in should be a list of string objects,
>> +               however, the filters need to be a list or regex object.
>> +
>> +               This code uses re.compile to rebuild the lists and set self.filter
>> +               """
>> +               for each in include_filter:
>> +                       self.filter.append(re.compile(each))
>> +               for each in exclude_filter:
>> +                       self.exclude_filter.append(re.compile(each))
>> +
>>
>>         def run(self, command):
>>                 try:
>> diff --git a/piglit-print-commands.py b/piglit-print-commands.py
>> index 9dd2290..617952c 100755
>> --- a/piglit-print-commands.py
>> +++ b/piglit-print-commands.py
>> @@ -24,7 +24,6 @@
>>
>>  import argparse
>>  import os.path as path
>> -import re
>>  import sys, os
>>  import time
>>  import traceback
>> @@ -64,25 +63,25 @@ def main():
>>
>>         args = parser.parse_args()
>>
>> -       env = core.Environment()
>> -
>> -       # If --tests is called warn that it is deprecated
>> -       if args.tests is no []:
>> -               print "Warning: Option --tests is deprecated. Use --include-tests"
>> -
>> -       # Append includes and excludes to env
>> -       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))
>> +       # Deprecated
>> +       # --include-tests is the standard going forward, but for backwards
>> +       # compatability merge args.tests into args.include_tests and drop
>> +       # duplicates
>> +       if args.tests is not []:
>> +               print "Warnings: Option --tests is deprecated, use --include-tests"
>> +               args.include_tests = list(set(args.include_tests + args.tests))
>> +
>> +       # Set the environment, pass in the included and excluded tests
>> +       env = core.Environment(
>> +                       exclude_filter=args.exclude_tests,
>> +                       include_filter=args.include_tests,
>> +                       )
>>
>>         # Change to the piglit's path
>>         piglit_dir = path.dirname(path.realpath(sys.argv[0]))
>>         os.chdir(piglit_dir)
>>
>> -       profile = core.loadTestProfile(args.testFile)
>> +       profile = core.loadTestProfile(args.testProfile)
>>
>>         def getCommand(test):
>>                 command = ''
>> diff --git a/piglit-run.py b/piglit-run.py
>> index 2d0afc1..17e6f6c 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-concurrencc)
>> +       # 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-concurrent 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]))
>> --
>> 1.8.1.4
>>
>> _______________________________________________
>> Piglit mailing list
>> Piglit at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/piglit
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list