[Piglit] [PATCH 1/2] framework/programs/run.py: Delete tests directory if it exists

Daniel Vetter daniel at ffwll.ch
Tue Aug 4 02:39:25 PDT 2015


On Mon, Aug 03, 2015 at 04:46:22PM -0700, Dylan Baker wrote:
> This prevents piglit from aggregating tests from a previous run into the
> new run by deleting the old tests directory before starting.
> 
> Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> ---
>  framework/programs/run.py | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/framework/programs/run.py b/framework/programs/run.py
> index 2981ffa..6465750 100644
> --- a/framework/programs/run.py
> +++ b/framework/programs/run.py
> @@ -28,6 +28,7 @@ import os.path as path
>  import time
>  import ConfigParser
>  import ctypes
> +import shutil
>  
>  from framework import core, backends, exceptions
>  import framework.results
> @@ -265,7 +266,14 @@ def run(input_):
>      # Change working directory to the root of the piglit directory
>      piglit_dir = path.dirname(path.realpath(sys.argv[0]))
>      os.chdir(piglit_dir)
> -    core.checkDir(args.results_path, False)
> +    if os.path.exists(args.results_path):
> +        try:
> +            shutil.rmtree(os.path.join(args.results_path, 'tests'))
> +        except OSError:
> +            pass

Doesn't this have the effect of accidentally removing old results you
might want to keep if you do a type (with e.g. shell completion)? Old
piglit refused to run if the results dir was there iirc, so maybe we need
a --force-overwrite option or similar?
-Daniel

> +    else:
> +        os.makedirs(args.results_path)
> +
>  
>      results = framework.results.TestrunResult()
>      backends.set_meta(args.backend, results)
> -- 
> 2.5.0
> 
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the Piglit mailing list