On Thu, Mar 22, 2012 at 6:07 AM, Miroslav Rezanina <mreza...@redhat.com> wrote:
> I use to call get_started script after autotest update to have correct setup.
> Unfortunately, it does not update config files in case sample version changed.
> To ensure this, I have to deleate these config files to get them updated.
>
> Here's patch that check if sample and used version differ and print diff
> in case they do with question to use this sample. It's first version that
> just replace config file with sample. It's usable in 90% of case as I usualy
> modify only tests.cfg.
>
> What do you think, is this usefull feature? Or would be better to try merge
> configs instead of replace with sample?

It's an interesting idea, definitely. Need to think a bit more about
it, will get back to you on this.

> Regards,
> Miroslav Rezanina
>
> Patch:
> ---
> diff --git a/client/virt/virt_utils.py b/client/virt/virt_utils.py
> index 16125b7..a3ac164 100644
> --- a/client/virt/virt_utils.py
> +++ b/client/virt/virt_utils.py
> @@ -3564,7 +3564,21 @@ def virt_test_assistant(test_name, test_dir, base_dir, 
> de
>             logging.debug("Creating config file %s from sample", dst_file)
>             shutil.copyfile(src_file, dst_file)
>         else:
> -            logging.debug("Config file %s exists, not touching" % dst_file)
> +            diff_result = utils.run("diff %s %s" % (src_file, dst_file),
> +                           ignore_status=True)
> +            if diff_result.exit_status != 0:
> +               logging.debug("%s result:\n %s" %
> +                              (diff_result.command,diff_result.stdout))
> +                answer = utils.ask("Config file  %s differs from %s. 
> Overwrite?
> +                                   % (dst_file,src_file))
> +                if answer == "y":
> +                   logging.debug("Restoring config file %s from sample"
> +                                 % dst_file)
> +                   shutil.copyfile(src_file, dst_file)
> +                else:
> +                   logging.debug("Preserving existing %s file" % dst_file)
> +            else:
> +                logging.debug("Config file %s exists, not touching" % 
> dst_file)
>
>     logging.info("")
>     step += 1
>
> _______________________________________________
> Autotest mailing list
> Autotest@test.kernel.org
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest



-- 
Lucas
_______________________________________________
Autotest mailing list
Autotest@test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to