mirror of https://github.com/tc39/test262.git
Default to not regenerate test files that are newer than their case and template
This commit is contained in:
parent
1925fa1a3b
commit
e07f577a9c
|
@ -57,6 +57,13 @@ def create(args):
|
|||
'Refusing to overwrite file: ' + test.file_name)
|
||||
exit(1)
|
||||
|
||||
if not args.regenerate:
|
||||
test_file = os.path.join(args.out, test.file_name)
|
||||
test_mtime = os.path.getmtime(test_file)
|
||||
source_files = test.source_file_names
|
||||
if all(test_mtime > os.path.getmtime(f) for f in source_files):
|
||||
continue
|
||||
|
||||
if not existing.is_generated():
|
||||
print_error(
|
||||
'Refusing to overwrite non-generated file: ' +
|
||||
|
@ -80,6 +87,8 @@ create_parser.add_argument('-p', '--parents', action='store_true',
|
|||
help='''Create non-existent directories as necessary.''')
|
||||
create_parser.add_argument('-n', '--no-clobber', action='store_true',
|
||||
help='''Abort if any test file already exists.''')
|
||||
create_parser.add_argument('-r', '--regenerate', action='store_true',
|
||||
help='''Regenerate test files that are already newer than their source data.''')
|
||||
create_parser.add_argument('cases',
|
||||
help='''Test cases to generate. May be a file or a directory.''')
|
||||
create_parser.set_defaults(func=create)
|
||||
|
|
|
@ -216,4 +216,5 @@ class Template:
|
|||
body = self.expand_regions(self.source, case_values)
|
||||
return codecs.encode(frontmatter + '\n' + body, encoding)
|
||||
return Test(self.attribs['meta']['path'] + case_name + '.js',
|
||||
dynamic_source=get_source)
|
||||
dynamic_source=get_source,
|
||||
source_file_names=(self.filename, case_filename))
|
||||
|
|
|
@ -17,9 +17,10 @@ def after_parse(fn):
|
|||
class Test:
|
||||
"""Representation of a generated test. Specifies a file location which may
|
||||
or may not exist."""
|
||||
def __init__(self, file_name, dynamic_source=None):
|
||||
def __init__(self, file_name, dynamic_source=None, source_file_names=None):
|
||||
self.file_name = file_name
|
||||
self.dynamic_source = dynamic_source
|
||||
self.source_file_names = source_file_names
|
||||
self.source = None
|
||||
self.attribs = dict(meta=None)
|
||||
|
||||
|
|
Loading…
Reference in New Issue