[Piglit] [PATCH] piglit_run: New overwrite options {next, no}
Dylan Baker
baker.dylan.c at gmail.com
Wed May 8 16:52:42 PDT 2013
Have you tested this? When I try to run with just -o (nothing added after)
it attempts to scoop up the next positional argument as the argument for
-o, and fails.
Also, instead of using \ escapes, line up the quotation marks on the left
and python will magically concatenate the strings.
Have you considered instead adding an exclusive argument as an alternative
to --overwrite, something like --rename? these would just need to be simple
'store_true'/'store_false' sort of switches.
On Wed, May 8, 2013 at 3:15 PM, Ben Widawsky <ben at bwidawsk.net> wrote:
> Some of us (ie. not just me) like to script piglit runs. As such we've
> all baked in versions of our own auto result directory naming, or as an
> alternative accidentally overwritten the results we've wanted.. To make
> things easier for people, add two new options under the -o (overwrite)
> flag.
>
> [-o {yes,no,next}]
>
> yes: default, and previous behavior. Just do it.
> no: warn, and exit if you try to overwrite the results dir.
> next: create a new results dir with an appended number.
>
> For example, if one invokes:
> > piglit-run.py -o next tests/igt.tests results/ppgtt-ctx
> and results/ppgtt-ctx exists...
> results would be written to results/ppgtt-ctx.1.
>
> To keep the code relatively simple, it won't be smart if the user
> specifies a number in their invocation. ie. if after doing the above,
> > piglit-run.py -o next tests/igt.tests results/ppgtt-ctx.1
>
> results/ppgtt-ctx.1.1 would be created.
>
> CC: Kenneth Graunke <kenneth at whitecape.org>
> Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
> ---
> piglit-run.py | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
>
> diff --git a/piglit-run.py b/piglit-run.py
> index 6d6ec77..175ee56 100755
> --- a/piglit-run.py
> +++ b/piglit-run.py
> @@ -28,6 +28,7 @@ import sys, os
> import time
> import traceback
> import json
> +import re
>
> sys.path.append(path.dirname(path.realpath(sys.argv[0])))
> import framework.core as core
> @@ -72,6 +73,12 @@ def main():
> action = "append",
> metavar = "<regex>",
> help = "Exclude matching tests (can be used
> more than once)")
> + parser.add_argument("-o", "--overwrite",
> + default = "yes",
> + choices = ["yes", "no", "next"],
> + help = "Results directory overwrite options. " \
> + "\"next\" will create a new directory
> name " \
> + "based on the old similarly names ones")
>
> # The new option going forward should be --no-concurrency, but to
> # maintain backwards compatability the --c, --concurrent option
> should
> @@ -149,6 +156,22 @@ def main():
> else:
> profileFilename = args.testProfile
> resultsDir = args.resultsPath
> + if os.path.isdir(resultsDir):
> + if args.overwrite == "no":
> + sys.exit(resultsDir + " Already exists,
> and overwrite was no")
> + elif args.overwrite == "next":
> + suffixes = [0] # If we found the dir, we
> have at least 1
> +
> + # Find the highest numbered results dir
> + pattern =
> re.compile(os.path.basename(resultsDir) + "\.*(\d+)")
> + parent =
> os.path.abspath(os.path.join(resultsDir, os.pardir))
> + for file in os.listdir(parent):
> + m = pattern.match(file)
> + if m:
> + suffixes.append(m.group(1))
> +
> + # Add 1 to the highest, and move along
> + resultsDir += "." +
> str((int(max(suffixes))+1))
>
> # Pass arguments into Environment
> env = core.Environment(concurrent=args.concurrency,
> --
> 1.8.2.2
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20130508/164c84b6/attachment-0001.html>
More information about the Piglit
mailing list