[generation] Support changing to existing files (#583)

When inspecting previously-generated files, a new `Test` instance should
be used. This avoids over-writing the in-memory representation of the
latest test, and allows previously-existing test files to be partially
updated according to subsequent changes in their respective source/case
files.
This commit is contained in:
jugglinmike 2016-04-25 12:20:23 -04:00 committed by Leo Balter
parent bc0a40c51c
commit 54fcbf7ae0

View File

@ -43,14 +43,15 @@ def create(args):
for test in exp.expand('utf-8', caseFile): for test in exp.expand('utf-8', caseFile):
if args.out: if args.out:
try: try:
test.load(args.out) existing = Test(test.file_name)
existing.load(args.out)
if args.no_clobber: if args.no_clobber:
print_error( print_error(
'Refusing to overwrite file: ' + test.file_name) 'Refusing to overwrite file: ' + test.file_name)
exit(1) exit(1)
if not test.is_generated(): if not existing.is_generated():
print_error( print_error(
'Refusing to overwrite non-generated file: ' + 'Refusing to overwrite non-generated file: ' +
test.file_name) test.file_name)