summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMike Pennisi <mike@mikepennisi.com>2016-04-26 10:03:56 -0400
committerMike Pennisi <mike@mikepennisi.com>2016-04-26 16:12:49 -0400
commit3777273b5dc12bd75d01422a2f5f130454c67da2 (patch)
tree39772a192d689de2515b0239e379b2d6d04c5300 /tools
parent82051d8f6a533e17a636f185c4e11f859c48b323 (diff)
downloadqtdeclarative-testsuites-3777273b5dc12bd75d01422a2f5f130454c67da2.tar.gz
[generation] Avoid generating trailing whitespace
Diffstat (limited to 'tools')
-rw-r--r--tools/generation/lib/template.py6
-rw-r--r--tools/generation/test/expected/normal/info-multiline-folding-normal.js36
-rw-r--r--tools/generation/test/fixtures/normal/info-multiline-folding.template30
3 files changed, 71 insertions, 1 deletions
diff --git a/tools/generation/lib/template.py b/tools/generation/lib/template.py
index bdd3eb1bc..92b8016f3 100644
--- a/tools/generation/lib/template.py
+++ b/tools/generation/lib/template.py
@@ -20,7 +20,11 @@ def indent(text, prefix = ' '):
else:
lines = text.split('\n')
- return prefix + ('\n' + prefix).join(lines)
+ indented = map(
+ lambda line: line if len(line) == 0 else prefix + line,
+ lines)
+
+ return '\n'.join(indented)
class Template:
def __init__(self, filename):
diff --git a/tools/generation/test/expected/normal/info-multiline-folding-normal.js b/tools/generation/test/expected/normal/info-multiline-folding-normal.js
new file mode 100644
index 000000000..0c9a1f167
--- /dev/null
+++ b/tools/generation/test/expected/normal/info-multiline-folding-normal.js
@@ -0,0 +1,36 @@
+// This file was procedurally generated from the following sources:
+// - tools/generation/test/fixtures/normal.case
+// - tools/generation/test/fixtures/normal/info-multiline-folding.template
+/*---
+description: foobar (First template name)
+es6id: 1.2.3
+flags: [generated, a, b]
+includes: [foo.js]
+info: >
+ This is an "info" field with an
+
+ empty line
+ Trailing white space in the template:
+ should be preserved:
+
+
+
+
+
+
+
+
+ case info
+---*/
+
+// Trailing white space in the test body:
+// should be preserved:
+
+
+
+
+
+
+
+
+'This is "teardown" code.';
diff --git a/tools/generation/test/fixtures/normal/info-multiline-folding.template b/tools/generation/test/fixtures/normal/info-multiline-folding.template
new file mode 100644
index 000000000..d2ede4bf7
--- /dev/null
+++ b/tools/generation/test/fixtures/normal/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: 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:
+
+
+
+
+
+
+