From 5b54058ad7b760cf949c87f000f20be8ec6f706d Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Thu, 24 Sep 2020 16:51:49 -0400 Subject: [PATCH] Enable configuration of templates for generated tests. Fixes gh-1049 --- CONTRIBUTING.md | 3 +- tools/generation/lib/case.py | 7 ++-- tools/generation/lib/expander.py | 16 ++++++--- .../normal/a-nested/path2-glob-expr.js | 2 +- .../normal/a-path1-glob-expr.js | 2 +- .../normal/b-nested/path2-glob-expr.js | 2 +- .../normal/b-path1-glob-expr.js | 2 +- .../glob/normal-multiple-templates.js | 36 +++++++++++++++++++ .../glob/normal2-multiple-templates.js | 19 ++++++++++ .../a-nested/path2-multiple-templates.js | 19 ++++++++++ .../normal/a-no-info-multiple-templates.js | 15 ++++++++ .../normal/a-path1-multiple-templates.js | 36 +++++++++++++++++++ .../normal/b-features-multiple-templates.js | 14 ++++++++ .../b-nested/path2-multiple-templates.js | 19 ++++++++++ .../normal/b-path1-multiple-templates.js | 36 +++++++++++++++++++ tools/generation/test/fixtures/glob-expr.case | 2 +- .../fixtures/glob-expr/a/features.template | 8 +++++ .../a/info-multiline-folding.template | 30 ++++++++++++++++ .../fixtures/glob-expr/a/no-info.template | 9 +++++ .../test/fixtures/glob-expr/a/normal.template | 30 ++++++++++++++++ .../fixtures/glob-expr/a/normal2.template | 13 +++++++ .../fixtures/glob-expr/b/features.template | 8 +++++ .../b/info-multiline-folding.template | 30 ++++++++++++++++ .../fixtures/glob-expr/b/no-info.template | 9 +++++ .../test/fixtures/glob-expr/b/normal.template | 30 ++++++++++++++++ .../fixtures/glob-expr/b/normal2.template | 13 +++++++ .../test/fixtures/multiple-templates.case | 32 +++++++++++++++++ .../fixtures/multiple/a/features.template | 8 +++++ .../a/info-multiline-folding.template | 30 ++++++++++++++++ .../test/fixtures/multiple/a/no-info.template | 9 +++++ .../test/fixtures/multiple/a/normal.template | 30 ++++++++++++++++ .../test/fixtures/multiple/a/normal2.template | 13 +++++++ .../fixtures/multiple/b/features.template | 8 +++++ .../b/info-multiline-folding.template | 30 ++++++++++++++++ .../test/fixtures/multiple/b/no-info.template | 9 +++++ .../test/fixtures/multiple/b/normal.template | 30 ++++++++++++++++ .../test/fixtures/multiple/b/normal2.template | 13 +++++++ .../fixtures/multiple/glob/features.template | 8 +++++ .../glob/info-multiline-folding.template | 30 ++++++++++++++++ .../fixtures/multiple/glob/no-info.template | 9 +++++ .../fixtures/multiple/glob/normal.template | 30 ++++++++++++++++ .../fixtures/multiple/glob/normal2.template | 13 +++++++ tools/generation/test/run.py | 10 ++++++ 43 files changed, 708 insertions(+), 14 deletions(-) rename tools/generation/test/expected/{glob => glob-expr}/normal/a-nested/path2-glob-expr.js (88%) rename tools/generation/test/expected/{glob => glob-expr}/normal/a-path1-glob-expr.js (92%) rename tools/generation/test/expected/{glob => glob-expr}/normal/b-nested/path2-glob-expr.js (88%) rename tools/generation/test/expected/{glob => glob-expr}/normal/b-path1-glob-expr.js (92%) create mode 100644 tools/generation/test/expected/multiple/glob/normal-multiple-templates.js create mode 100644 tools/generation/test/expected/multiple/glob/normal2-multiple-templates.js create mode 100644 tools/generation/test/expected/multiple/normal/a-nested/path2-multiple-templates.js create mode 100644 tools/generation/test/expected/multiple/normal/a-no-info-multiple-templates.js create mode 100644 tools/generation/test/expected/multiple/normal/a-path1-multiple-templates.js create mode 100644 tools/generation/test/expected/multiple/normal/b-features-multiple-templates.js create mode 100644 tools/generation/test/expected/multiple/normal/b-nested/path2-multiple-templates.js create mode 100644 tools/generation/test/expected/multiple/normal/b-path1-multiple-templates.js create mode 100644 tools/generation/test/fixtures/glob-expr/a/features.template create mode 100644 tools/generation/test/fixtures/glob-expr/a/info-multiline-folding.template create mode 100644 tools/generation/test/fixtures/glob-expr/a/no-info.template create mode 100644 tools/generation/test/fixtures/glob-expr/a/normal.template create mode 100644 tools/generation/test/fixtures/glob-expr/a/normal2.template create mode 100644 tools/generation/test/fixtures/glob-expr/b/features.template create mode 100644 tools/generation/test/fixtures/glob-expr/b/info-multiline-folding.template create mode 100644 tools/generation/test/fixtures/glob-expr/b/no-info.template create mode 100644 tools/generation/test/fixtures/glob-expr/b/normal.template create mode 100644 tools/generation/test/fixtures/glob-expr/b/normal2.template create mode 100644 tools/generation/test/fixtures/multiple-templates.case create mode 100644 tools/generation/test/fixtures/multiple/a/features.template create mode 100644 tools/generation/test/fixtures/multiple/a/info-multiline-folding.template create mode 100644 tools/generation/test/fixtures/multiple/a/no-info.template create mode 100644 tools/generation/test/fixtures/multiple/a/normal.template create mode 100644 tools/generation/test/fixtures/multiple/a/normal2.template create mode 100644 tools/generation/test/fixtures/multiple/b/features.template create mode 100644 tools/generation/test/fixtures/multiple/b/info-multiline-folding.template create mode 100644 tools/generation/test/fixtures/multiple/b/no-info.template create mode 100644 tools/generation/test/fixtures/multiple/b/normal.template create mode 100644 tools/generation/test/fixtures/multiple/b/normal2.template create mode 100644 tools/generation/test/fixtures/multiple/glob/features.template create mode 100644 tools/generation/test/fixtures/multiple/glob/info-multiline-folding.template create mode 100644 tools/generation/test/fixtures/multiple/glob/no-info.template create mode 100644 tools/generation/test/fixtures/multiple/glob/normal.template create mode 100644 tools/generation/test/fixtures/multiple/glob/normal2.template diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index eda0f168d9..e42909297d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -385,7 +385,8 @@ Test cases and test templates specify meta-data using the same YAML frontmatter ### test cases (`*.case`) Field | Description ------|------------- -`template` | name of the sub-directory to locate templates for this test +`template` | a template file, directory or glob expression. +`templates` | a list of template file, directory or glob expressions. `desc` | see the frontmatter definition of the "desc" field. The generated test will have a have final "desc" value which is this text appended with the test template's "name" field in parentheses. `info` | see the frontmatter definition of the "info" field. The generated test will have a have final "info" value which is this text concatenated at the end of the test templates's "info" text. `features` | see the frontmatter definition of the "features" field. The generated test will have a final feature list in combination with the template's feature field. diff --git a/tools/generation/lib/case.py b/tools/generation/lib/case.py index 83fd0fd4d4..c90a7055ab 100644 --- a/tools/generation/lib/case.py +++ b/tools/generation/lib/case.py @@ -22,14 +22,13 @@ class Case: region_name = None region_start = 0 lines = source.split('\n') - matches = re.finditer(metaPattern, source, re.MULTILINE) + search = re.search(metaPattern, source, re.DOTALL|re.MULTILINE) - for matchNum, match in enumerate(matches, start=1): - meta = "{match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group()) + if search: + meta = search.group() meta = parse_yaml(meta[2:-2]) if meta and not case['meta']: case['meta'] = meta - break for comment in find_comments(source): match = regionStartPattern.match(comment['source']) diff --git a/tools/generation/lib/expander.py b/tools/generation/lib/expander.py index 04075506e1..b979eed066 100644 --- a/tools/generation/lib/expander.py +++ b/tools/generation/lib/expander.py @@ -60,9 +60,17 @@ class Expander: def expand_case(self, file_name, encoding): case = Case(file_name, encoding) + localtemplates = []; - template_class = case.attribs['meta']['template'] - templates = self.templates.get(template_class) + if 'template' in case.attribs['meta']: + localtemplates.append(case.attribs['meta']['template']) - for template in self._get_templates(template_class, encoding): - yield template.expand(file_name, os.path.basename(file_name[:-5]), case.attribs, encoding) + if 'templates' in case.attribs['meta']: + localtemplates.extend(case.attribs['meta']['templates']) + + for t in localtemplates: + template_class = t + templates = self.templates.get(template_class) + + for template in self._get_templates(template_class, encoding): + yield template.expand(file_name, os.path.basename(file_name[:-5]), case.attribs, encoding) diff --git a/tools/generation/test/expected/glob/normal/a-nested/path2-glob-expr.js b/tools/generation/test/expected/glob-expr/normal/a-nested/path2-glob-expr.js similarity index 88% rename from tools/generation/test/expected/glob/normal/a-nested/path2-glob-expr.js rename to tools/generation/test/expected/glob-expr/normal/a-nested/path2-glob-expr.js index 686c1e7320..10e3d78f04 100644 --- a/tools/generation/test/expected/glob/normal/a-nested/path2-glob-expr.js +++ b/tools/generation/test/expected/glob-expr/normal/a-nested/path2-glob-expr.js @@ -1,6 +1,6 @@ // This file was procedurally generated from the following sources: // - tools/generation/test/fixtures/glob-expr.case -// - tools/generation/test/fixtures/glob/a/normal2.template +// - tools/generation/test/fixtures/glob-expr/a/normal2.template /*--- description: foobar (Second template name) esid: sec-a-generic-id diff --git a/tools/generation/test/expected/glob/normal/a-path1-glob-expr.js b/tools/generation/test/expected/glob-expr/normal/a-path1-glob-expr.js similarity index 92% rename from tools/generation/test/expected/glob/normal/a-path1-glob-expr.js rename to tools/generation/test/expected/glob-expr/normal/a-path1-glob-expr.js index 85a6847ae3..88e9ef2dad 100644 --- a/tools/generation/test/expected/glob/normal/a-path1-glob-expr.js +++ b/tools/generation/test/expected/glob-expr/normal/a-path1-glob-expr.js @@ -1,6 +1,6 @@ // This file was procedurally generated from the following sources: // - tools/generation/test/fixtures/glob-expr.case -// - tools/generation/test/fixtures/glob/a/normal.template +// - tools/generation/test/fixtures/glob-expr/a/normal.template /*--- description: foobar (First template name) es6id: 1.2.3 diff --git a/tools/generation/test/expected/glob/normal/b-nested/path2-glob-expr.js b/tools/generation/test/expected/glob-expr/normal/b-nested/path2-glob-expr.js similarity index 88% rename from tools/generation/test/expected/glob/normal/b-nested/path2-glob-expr.js rename to tools/generation/test/expected/glob-expr/normal/b-nested/path2-glob-expr.js index aee8489509..985011abc3 100644 --- a/tools/generation/test/expected/glob/normal/b-nested/path2-glob-expr.js +++ b/tools/generation/test/expected/glob-expr/normal/b-nested/path2-glob-expr.js @@ -1,6 +1,6 @@ // This file was procedurally generated from the following sources: // - tools/generation/test/fixtures/glob-expr.case -// - tools/generation/test/fixtures/glob/b/normal2.template +// - tools/generation/test/fixtures/glob-expr/b/normal2.template /*--- description: foobar (Second template name) esid: sec-a-generic-id diff --git a/tools/generation/test/expected/glob/normal/b-path1-glob-expr.js b/tools/generation/test/expected/glob-expr/normal/b-path1-glob-expr.js similarity index 92% rename from tools/generation/test/expected/glob/normal/b-path1-glob-expr.js rename to tools/generation/test/expected/glob-expr/normal/b-path1-glob-expr.js index 59706e94f1..4752aa2a97 100644 --- a/tools/generation/test/expected/glob/normal/b-path1-glob-expr.js +++ b/tools/generation/test/expected/glob-expr/normal/b-path1-glob-expr.js @@ -1,6 +1,6 @@ // This file was procedurally generated from the following sources: // - tools/generation/test/fixtures/glob-expr.case -// - tools/generation/test/fixtures/glob/b/normal.template +// - tools/generation/test/fixtures/glob-expr/b/normal.template /*--- description: foobar (First template name) es6id: 1.2.3 diff --git a/tools/generation/test/expected/multiple/glob/normal-multiple-templates.js b/tools/generation/test/expected/multiple/glob/normal-multiple-templates.js new file mode 100644 index 0000000000..e8d81f2af9 --- /dev/null +++ b/tools/generation/test/expected/multiple/glob/normal-multiple-templates.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - tools/generation/test/fixtures/multiple-templates.case +// - tools/generation/test/fixtures/multiple/glob/normal.template +/*--- +description: foobar (First template name) +es6id: 1.2.3 +flags: [generated, a, b, c, d] +includes: [foo.js] +info: | + template info + + case info +---*/ + +before-First value-between-Third value (Special characters like `≠` should be tolerated.)-after + +before*Second value*between*First value*after + +before/* " */Third value (Special characters like `≠` should be tolerated.)after + +// Special characters like `≠` should be tolerated. + +The following should not be expanded: + +/* */*{ first }*/ +/* +*/*{ first }*/ +//*{ first }*/ +// /*{ first }*/ +Quote characters: " ' ` +"Quote characters: ' ' `" +'Quote characters: " " `' +` +Quote characters: " ' '` + +'This is "teardown" code.'; diff --git a/tools/generation/test/expected/multiple/glob/normal2-multiple-templates.js b/tools/generation/test/expected/multiple/glob/normal2-multiple-templates.js new file mode 100644 index 0000000000..d4347f0d9a --- /dev/null +++ b/tools/generation/test/expected/multiple/glob/normal2-multiple-templates.js @@ -0,0 +1,19 @@ +// This file was procedurally generated from the following sources: +// - tools/generation/test/fixtures/multiple-templates.case +// - tools/generation/test/fixtures/multiple/glob/normal2.template +/*--- +description: foobar (Second template name) +esid: sec-a-generic-id +flags: [generated, a, b] +includes: [foo.js, bar.js] +info: | + template info + + case info +---*/ + +before-Third value (Special characters like `≠` should be tolerated.)Second value-after + +/* Improperly-terminated comments should not break the tokenizer * + +'This is "teardown" code.'; diff --git a/tools/generation/test/expected/multiple/normal/a-nested/path2-multiple-templates.js b/tools/generation/test/expected/multiple/normal/a-nested/path2-multiple-templates.js new file mode 100644 index 0000000000..608b411526 --- /dev/null +++ b/tools/generation/test/expected/multiple/normal/a-nested/path2-multiple-templates.js @@ -0,0 +1,19 @@ +// This file was procedurally generated from the following sources: +// - tools/generation/test/fixtures/multiple-templates.case +// - tools/generation/test/fixtures/multiple/a/normal2.template +/*--- +description: foobar (Second template name) +esid: sec-a-generic-id +flags: [generated, a, b] +includes: [foo.js, bar.js] +info: | + template info + + case info +---*/ + +before-Third value (Special characters like `≠` should be tolerated.)Second value-after + +/* Improperly-terminated comments should not break the tokenizer * + +'This is "teardown" code.'; diff --git a/tools/generation/test/expected/multiple/normal/a-no-info-multiple-templates.js b/tools/generation/test/expected/multiple/normal/a-no-info-multiple-templates.js new file mode 100644 index 0000000000..1aa5a0597d --- /dev/null +++ b/tools/generation/test/expected/multiple/normal/a-no-info-multiple-templates.js @@ -0,0 +1,15 @@ +// This file was procedurally generated from the following sources: +// - tools/generation/test/fixtures/multiple-templates.case +// - tools/generation/test/fixtures/multiple/a/no-info.template +/*--- +description: foobar (First template name) +es6id: 1.2.3 +flags: [generated, a, b] +includes: [foo.js] +info: | + case info +---*/ + +First value + +'This is "teardown" code.'; diff --git a/tools/generation/test/expected/multiple/normal/a-path1-multiple-templates.js b/tools/generation/test/expected/multiple/normal/a-path1-multiple-templates.js new file mode 100644 index 0000000000..756de7b29b --- /dev/null +++ b/tools/generation/test/expected/multiple/normal/a-path1-multiple-templates.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - tools/generation/test/fixtures/multiple-templates.case +// - tools/generation/test/fixtures/multiple/a/normal.template +/*--- +description: foobar (First template name) +es6id: 1.2.3 +flags: [generated, a, b, c, d] +includes: [foo.js] +info: | + template info + + case info +---*/ + +before-First value-between-Third value (Special characters like `≠` should be tolerated.)-after + +before*Second value*between*First value*after + +before/* " */Third value (Special characters like `≠` should be tolerated.)after + +// Special characters like `≠` should be tolerated. + +The following should not be expanded: + +/* */*{ first }*/ +/* +*/*{ first }*/ +//*{ first }*/ +// /*{ first }*/ +Quote characters: " ' ` +"Quote characters: ' ' `" +'Quote characters: " " `' +` +Quote characters: " ' '` + +'This is "teardown" code.'; diff --git a/tools/generation/test/expected/multiple/normal/b-features-multiple-templates.js b/tools/generation/test/expected/multiple/normal/b-features-multiple-templates.js new file mode 100644 index 0000000000..62ba93fefd --- /dev/null +++ b/tools/generation/test/expected/multiple/normal/b-features-multiple-templates.js @@ -0,0 +1,14 @@ +// This file was procedurally generated from the following sources: +// - tools/generation/test/fixtures/multiple-templates.case +// - tools/generation/test/fixtures/multiple/b/features.template +/*--- +description: foobar (First template name) +es6id: 1.2.3 +features: [f1] +flags: [generated, a, b] +includes: [foo.js] +info: | + case info +---*/ + +'This is "teardown" code.'; diff --git a/tools/generation/test/expected/multiple/normal/b-nested/path2-multiple-templates.js b/tools/generation/test/expected/multiple/normal/b-nested/path2-multiple-templates.js new file mode 100644 index 0000000000..ac093f00ce --- /dev/null +++ b/tools/generation/test/expected/multiple/normal/b-nested/path2-multiple-templates.js @@ -0,0 +1,19 @@ +// This file was procedurally generated from the following sources: +// - tools/generation/test/fixtures/multiple-templates.case +// - tools/generation/test/fixtures/multiple/b/normal2.template +/*--- +description: foobar (Second template name) +esid: sec-a-generic-id +flags: [generated, a, b] +includes: [foo.js, bar.js] +info: | + template info + + case info +---*/ + +before-Third value (Special characters like `≠` should be tolerated.)Second value-after + +/* Improperly-terminated comments should not break the tokenizer * + +'This is "teardown" code.'; diff --git a/tools/generation/test/expected/multiple/normal/b-path1-multiple-templates.js b/tools/generation/test/expected/multiple/normal/b-path1-multiple-templates.js new file mode 100644 index 0000000000..558545bc6d --- /dev/null +++ b/tools/generation/test/expected/multiple/normal/b-path1-multiple-templates.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - tools/generation/test/fixtures/multiple-templates.case +// - tools/generation/test/fixtures/multiple/b/normal.template +/*--- +description: foobar (First template name) +es6id: 1.2.3 +flags: [generated, a, b, c, d] +includes: [foo.js] +info: | + template info + + case info +---*/ + +before-First value-between-Third value (Special characters like `≠` should be tolerated.)-after + +before*Second value*between*First value*after + +before/* " */Third value (Special characters like `≠` should be tolerated.)after + +// Special characters like `≠` should be tolerated. + +The following should not be expanded: + +/* */*{ first }*/ +/* +*/*{ first }*/ +//*{ first }*/ +// /*{ first }*/ +Quote characters: " ' ` +"Quote characters: ' ' `" +'Quote characters: " " `' +` +Quote characters: " ' '` + +'This is "teardown" code.'; diff --git a/tools/generation/test/fixtures/glob-expr.case b/tools/generation/test/fixtures/glob-expr.case index b7e6c431d2..98323dac61 100644 --- a/tools/generation/test/fixtures/glob-expr.case +++ b/tools/generation/test/fixtures/glob-expr.case @@ -1,7 +1,7 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -template: glob/**/normal*.template +template: glob-expr/**/normal*.template desc: foobar info: case info flags: [a, b] diff --git a/tools/generation/test/fixtures/glob-expr/a/features.template b/tools/generation/test/fixtures/glob-expr/a/features.template new file mode 100644 index 0000000000..7814a86930 --- /dev/null +++ b/tools/generation/test/fixtures/glob-expr/a/features.template @@ -0,0 +1,8 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: First template name +path: glob-expr/normal/a-features- +es6id: 1.2.3 +features: [f1] +---*/ diff --git a/tools/generation/test/fixtures/glob-expr/a/info-multiline-folding.template b/tools/generation/test/fixtures/glob-expr/a/info-multiline-folding.template new file mode 100644 index 0000000000..9bc16d164a --- /dev/null +++ b/tools/generation/test/fixtures/glob-expr/a/info-multiline-folding.template @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: First template name +path: glob-expr/normal/a-info-multiline-folding- +es6id: 1.2.3 +info: | + This is an "info" field with an + + empty line + Trailing white space in the template: + should be preserved: + + + + + + + +---*/ + +// Trailing white space in the test body: +// should be preserved: + + + + + + + diff --git a/tools/generation/test/fixtures/glob-expr/a/no-info.template b/tools/generation/test/fixtures/glob-expr/a/no-info.template new file mode 100644 index 0000000000..899f70b353 --- /dev/null +++ b/tools/generation/test/fixtures/glob-expr/a/no-info.template @@ -0,0 +1,9 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: First template name +path: glob-expr/normal/a-no-info- +es6id: 1.2.3 +---*/ + +/*{ first }*/ diff --git a/tools/generation/test/fixtures/glob-expr/a/normal.template b/tools/generation/test/fixtures/glob-expr/a/normal.template new file mode 100644 index 0000000000..0ea2a4ca52 --- /dev/null +++ b/tools/generation/test/fixtures/glob-expr/a/normal.template @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: First template name +path: glob-expr/normal/a-path1- +es6id: 1.2.3 +info: template info +flags: [c, d] +---*/ + +before-/*{ first }*/-between-/*{ third }*/-after + +before*/*{ second }*/*between*/*{ first }*/*after + +before/* " *//*{ third }*/after + +// Special characters like `≠` should be tolerated. + +The following should not be expanded: + +/* */*{ first }*/ +/* +*/*{ first }*/ +//*{ first }*/ +// /*{ first }*/ +/*{ fourth }*/ +"/*{ fourth }*/" +'/*{ fourth }*/' +` +/*{ fourth }*/` diff --git a/tools/generation/test/fixtures/glob-expr/a/normal2.template b/tools/generation/test/fixtures/glob-expr/a/normal2.template new file mode 100644 index 0000000000..022f4e906d --- /dev/null +++ b/tools/generation/test/fixtures/glob-expr/a/normal2.template @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: Second template name +path: glob-expr/normal/a-nested/path2- +esid: sec-a-generic-id +includes: [bar.js] +info: template info +---*/ + +before-/*{ third }*//*{ second }*/-after + +/* Improperly-terminated comments should not break the tokenizer * diff --git a/tools/generation/test/fixtures/glob-expr/b/features.template b/tools/generation/test/fixtures/glob-expr/b/features.template new file mode 100644 index 0000000000..d2e57c0592 --- /dev/null +++ b/tools/generation/test/fixtures/glob-expr/b/features.template @@ -0,0 +1,8 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: First template name +path: glob-expr/normal/b-features- +es6id: 1.2.3 +features: [f1] +---*/ diff --git a/tools/generation/test/fixtures/glob-expr/b/info-multiline-folding.template b/tools/generation/test/fixtures/glob-expr/b/info-multiline-folding.template new file mode 100644 index 0000000000..9cd7a542f4 --- /dev/null +++ b/tools/generation/test/fixtures/glob-expr/b/info-multiline-folding.template @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: First template name +path: glob-expr/normal/b-info-multiline-folding- +es6id: 1.2.3 +info: | + This is an "info" field with an + + empty line + Trailing white space in the template: + should be preserved: + + + + + + + +---*/ + +// Trailing white space in the test body: +// should be preserved: + + + + + + + diff --git a/tools/generation/test/fixtures/glob-expr/b/no-info.template b/tools/generation/test/fixtures/glob-expr/b/no-info.template new file mode 100644 index 0000000000..20e647899c --- /dev/null +++ b/tools/generation/test/fixtures/glob-expr/b/no-info.template @@ -0,0 +1,9 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: First template name +path: glob-expr/normal/b-no-info- +es6id: 1.2.3 +---*/ + +/*{ first }*/ diff --git a/tools/generation/test/fixtures/glob-expr/b/normal.template b/tools/generation/test/fixtures/glob-expr/b/normal.template new file mode 100644 index 0000000000..58a26a8682 --- /dev/null +++ b/tools/generation/test/fixtures/glob-expr/b/normal.template @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: First template name +path: glob-expr/normal/b-path1- +es6id: 1.2.3 +info: template info +flags: [c, d] +---*/ + +before-/*{ first }*/-between-/*{ third }*/-after + +before*/*{ second }*/*between*/*{ first }*/*after + +before/* " *//*{ third }*/after + +// Special characters like `≠` should be tolerated. + +The following should not be expanded: + +/* */*{ first }*/ +/* +*/*{ first }*/ +//*{ first }*/ +// /*{ first }*/ +/*{ fourth }*/ +"/*{ fourth }*/" +'/*{ fourth }*/' +` +/*{ fourth }*/` diff --git a/tools/generation/test/fixtures/glob-expr/b/normal2.template b/tools/generation/test/fixtures/glob-expr/b/normal2.template new file mode 100644 index 0000000000..a10a4be88c --- /dev/null +++ b/tools/generation/test/fixtures/glob-expr/b/normal2.template @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: Second template name +path: glob-expr/normal/b-nested/path2- +esid: sec-a-generic-id +includes: [bar.js] +info: template info +---*/ + +before-/*{ third }*//*{ second }*/-after + +/* Improperly-terminated comments should not break the tokenizer * diff --git a/tools/generation/test/fixtures/multiple-templates.case b/tools/generation/test/fixtures/multiple-templates.case new file mode 100644 index 0000000000..3833daef06 --- /dev/null +++ b/tools/generation/test/fixtures/multiple-templates.case @@ -0,0 +1,32 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +templates: + - multiple/**/normal*.template + - multiple/b/features.template + - multiple/a/no-info.template +desc: foobar +info: case info +flags: [a, b] +includes: [foo.js] +---*/ + +Because this test appears before any "region" delimiters, it should not appear +in the generated files. + +// - first +this is not a valid region delimiter + +/* *//- first +this is also not a valid region delimiter + +//- first +First value +//- second +Second value +//- third +Third value (Special characters like `≠` should be tolerated.) +//- fourth +Quote characters: " ' ` +//- teardown +'This is "teardown" code.'; diff --git a/tools/generation/test/fixtures/multiple/a/features.template b/tools/generation/test/fixtures/multiple/a/features.template new file mode 100644 index 0000000000..2a9ea4286f --- /dev/null +++ b/tools/generation/test/fixtures/multiple/a/features.template @@ -0,0 +1,8 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: First template name +path: multiple/normal/a-features- +es6id: 1.2.3 +features: [f1] +---*/ diff --git a/tools/generation/test/fixtures/multiple/a/info-multiline-folding.template b/tools/generation/test/fixtures/multiple/a/info-multiline-folding.template new file mode 100644 index 0000000000..1be553403a --- /dev/null +++ b/tools/generation/test/fixtures/multiple/a/info-multiline-folding.template @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: First template name +path: multiple/normal/a-info-multiline-folding- +es6id: 1.2.3 +info: | + This is an "info" field with an + + empty line + Trailing white space in the template: + should be preserved: + + + + + + + +---*/ + +// Trailing white space in the test body: +// should be preserved: + + + + + + + diff --git a/tools/generation/test/fixtures/multiple/a/no-info.template b/tools/generation/test/fixtures/multiple/a/no-info.template new file mode 100644 index 0000000000..1aff040e19 --- /dev/null +++ b/tools/generation/test/fixtures/multiple/a/no-info.template @@ -0,0 +1,9 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: First template name +path: multiple/normal/a-no-info- +es6id: 1.2.3 +---*/ + +/*{ first }*/ diff --git a/tools/generation/test/fixtures/multiple/a/normal.template b/tools/generation/test/fixtures/multiple/a/normal.template new file mode 100644 index 0000000000..cf8ae881ff --- /dev/null +++ b/tools/generation/test/fixtures/multiple/a/normal.template @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: First template name +path: multiple/normal/a-path1- +es6id: 1.2.3 +info: template info +flags: [c, d] +---*/ + +before-/*{ first }*/-between-/*{ third }*/-after + +before*/*{ second }*/*between*/*{ first }*/*after + +before/* " *//*{ third }*/after + +// Special characters like `≠` should be tolerated. + +The following should not be expanded: + +/* */*{ first }*/ +/* +*/*{ first }*/ +//*{ first }*/ +// /*{ first }*/ +/*{ fourth }*/ +"/*{ fourth }*/" +'/*{ fourth }*/' +` +/*{ fourth }*/` diff --git a/tools/generation/test/fixtures/multiple/a/normal2.template b/tools/generation/test/fixtures/multiple/a/normal2.template new file mode 100644 index 0000000000..437a6435e7 --- /dev/null +++ b/tools/generation/test/fixtures/multiple/a/normal2.template @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: Second template name +path: multiple/normal/a-nested/path2- +esid: sec-a-generic-id +includes: [bar.js] +info: template info +---*/ + +before-/*{ third }*//*{ second }*/-after + +/* Improperly-terminated comments should not break the tokenizer * diff --git a/tools/generation/test/fixtures/multiple/b/features.template b/tools/generation/test/fixtures/multiple/b/features.template new file mode 100644 index 0000000000..f4e01a0a6a --- /dev/null +++ b/tools/generation/test/fixtures/multiple/b/features.template @@ -0,0 +1,8 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: First template name +path: multiple/normal/b-features- +es6id: 1.2.3 +features: [f1] +---*/ diff --git a/tools/generation/test/fixtures/multiple/b/info-multiline-folding.template b/tools/generation/test/fixtures/multiple/b/info-multiline-folding.template new file mode 100644 index 0000000000..f152ba0221 --- /dev/null +++ b/tools/generation/test/fixtures/multiple/b/info-multiline-folding.template @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: First template name +path: multiple/normal/b-info-multiline-folding- +es6id: 1.2.3 +info: | + This is an "info" field with an + + empty line + Trailing white space in the template: + should be preserved: + + + + + + + +---*/ + +// Trailing white space in the test body: +// should be preserved: + + + + + + + diff --git a/tools/generation/test/fixtures/multiple/b/no-info.template b/tools/generation/test/fixtures/multiple/b/no-info.template new file mode 100644 index 0000000000..46903abf75 --- /dev/null +++ b/tools/generation/test/fixtures/multiple/b/no-info.template @@ -0,0 +1,9 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: First template name +path: multiple/normal/b-no-info- +es6id: 1.2.3 +---*/ + +/*{ first }*/ diff --git a/tools/generation/test/fixtures/multiple/b/normal.template b/tools/generation/test/fixtures/multiple/b/normal.template new file mode 100644 index 0000000000..1e381fcd54 --- /dev/null +++ b/tools/generation/test/fixtures/multiple/b/normal.template @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: First template name +path: multiple/normal/b-path1- +es6id: 1.2.3 +info: template info +flags: [c, d] +---*/ + +before-/*{ first }*/-between-/*{ third }*/-after + +before*/*{ second }*/*between*/*{ first }*/*after + +before/* " *//*{ third }*/after + +// Special characters like `≠` should be tolerated. + +The following should not be expanded: + +/* */*{ first }*/ +/* +*/*{ first }*/ +//*{ first }*/ +// /*{ first }*/ +/*{ fourth }*/ +"/*{ fourth }*/" +'/*{ fourth }*/' +` +/*{ fourth }*/` diff --git a/tools/generation/test/fixtures/multiple/b/normal2.template b/tools/generation/test/fixtures/multiple/b/normal2.template new file mode 100644 index 0000000000..795584871b --- /dev/null +++ b/tools/generation/test/fixtures/multiple/b/normal2.template @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: Second template name +path: multiple/normal/b-nested/path2- +esid: sec-a-generic-id +includes: [bar.js] +info: template info +---*/ + +before-/*{ third }*//*{ second }*/-after + +/* Improperly-terminated comments should not break the tokenizer * diff --git a/tools/generation/test/fixtures/multiple/glob/features.template b/tools/generation/test/fixtures/multiple/glob/features.template new file mode 100644 index 0000000000..677d762af0 --- /dev/null +++ b/tools/generation/test/fixtures/multiple/glob/features.template @@ -0,0 +1,8 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: First template name +path: multiple/glob/features- +es6id: 1.2.3 +features: [f1] +---*/ diff --git a/tools/generation/test/fixtures/multiple/glob/info-multiline-folding.template b/tools/generation/test/fixtures/multiple/glob/info-multiline-folding.template new file mode 100644 index 0000000000..d5e32735f4 --- /dev/null +++ b/tools/generation/test/fixtures/multiple/glob/info-multiline-folding.template @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: First template name +path: multiple/glob/normal/info-multiline-folding- +es6id: 1.2.3 +info: | + This is an "info" field with an + + empty line + Trailing white space in the template: + should be preserved: + + + + + + + +---*/ + +// Trailing white space in the test body: +// should be preserved: + + + + + + + diff --git a/tools/generation/test/fixtures/multiple/glob/no-info.template b/tools/generation/test/fixtures/multiple/glob/no-info.template new file mode 100644 index 0000000000..0a772426df --- /dev/null +++ b/tools/generation/test/fixtures/multiple/glob/no-info.template @@ -0,0 +1,9 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: First template name +path: multiple/glob/normal/no-info- +es6id: 1.2.3 +---*/ + +/*{ first }*/ diff --git a/tools/generation/test/fixtures/multiple/glob/normal.template b/tools/generation/test/fixtures/multiple/glob/normal.template new file mode 100644 index 0000000000..5ec9f9126b --- /dev/null +++ b/tools/generation/test/fixtures/multiple/glob/normal.template @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: First template name +path: multiple/glob/normal- +es6id: 1.2.3 +info: template info +flags: [c, d] +---*/ + +before-/*{ first }*/-between-/*{ third }*/-after + +before*/*{ second }*/*between*/*{ first }*/*after + +before/* " *//*{ third }*/after + +// Special characters like `≠` should be tolerated. + +The following should not be expanded: + +/* */*{ first }*/ +/* +*/*{ first }*/ +//*{ first }*/ +// /*{ first }*/ +/*{ fourth }*/ +"/*{ fourth }*/" +'/*{ fourth }*/' +` +/*{ fourth }*/` diff --git a/tools/generation/test/fixtures/multiple/glob/normal2.template b/tools/generation/test/fixtures/multiple/glob/normal2.template new file mode 100644 index 0000000000..c93e5ebfbf --- /dev/null +++ b/tools/generation/test/fixtures/multiple/glob/normal2.template @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +name: Second template name +path: multiple/glob/normal2- +esid: sec-a-generic-id +includes: [bar.js] +info: template info +---*/ + +before-/*{ third }*//*{ second }*/-after + +/* Improperly-terminated comments should not break the tokenizer * diff --git a/tools/generation/test/run.py b/tools/generation/test/run.py index baf2d3127e..98af0aba99 100755 --- a/tools/generation/test/run.py +++ b/tools/generation/test/run.py @@ -54,6 +54,16 @@ class TestGeneration(unittest.TestCase): self.assertEqual(result['returncode'], 0) self.compareTrees('glob') + def test_glob_expr(self): + result = self.fixture('glob-expr.case') + self.assertEqual(result['returncode'], 0) + self.compareTrees('glob-expr') + + def test_multiple_templates(self): + result = self.fixture('multiple-templates.case') + self.assertEqual(result['returncode'], 0) + self.compareTrees('multiple-templates') + def test_normal(self): result = self.fixture('normal.case') self.assertEqual(result['returncode'], 0)