From 28bc42a988c4ce1ee7c714ae16871ea3209de932 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Mon, 15 Aug 2016 09:15:07 -0700 Subject: [PATCH] Add generation script header to generated tests Summary: Add header to generated code so that code can easily be re-generated in case test generation is improved in the future. Reviewed By: lucasr Differential Revision: D3715181 fbshipit-source-id: 593baa691c2d7c7f171c6673898fb8a2ecf0e008 --- gentest/gentest.js | 27 ++++++++++++++++++++++++--- tests/CSSLayoutFlexBasisTest.cpp | 10 ++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/gentest/gentest.js b/gentest/gentest.js index 198dcbb2..18199b95 100755 --- a/gentest/gentest.js +++ b/gentest/gentest.js @@ -8,10 +8,10 @@ */ window.onload = function() { - printTest(calculateTree(document.body.children[0])); + printTest(document.body.children[0], calculateTree(document.body.children[0])); } -function printTest(layoutTree) { +function printTest(rootNode, layoutTree) { var lines = [ '/**', ' * Copyright (c) 2014-present, Facebook, Inc.', @@ -22,11 +22,32 @@ function printTest(layoutTree) { ' * of patent rights can be found in the PATENTS file in the same directory.', ' */', '', + ]; + + lines.push('/**'); + lines.push(' * @Generated by gentest/gentest.sh with the following input'); + lines.push(' *'); + lines.push(rootNode.innerHTML.split('\n').map(function(line) { + return line.trim(); + }).filter(function(line) { + return line.length > 0 && line !== '
'; + }).map(function(line) { + return ' * ' + line; + }).reduce(function(curr, prev) { + return curr + '\n' + prev; + })); + lines.push(' *'); + lines.push(' */'); + lines.push(''); + + lines.push([ '#include ', '#include ', '#include ', '', - ]; + ].reduce(function(curr, prev) { + return curr + '\n' + prev; + })); for (var i = 0; i < layoutTree.length - 1; i++) { lines.push('TEST(CSSLayoutTest, INSERT_NAME_HERE) {'); diff --git a/tests/CSSLayoutFlexBasisTest.cpp b/tests/CSSLayoutFlexBasisTest.cpp index cfed1e51..62730596 100644 --- a/tests/CSSLayoutFlexBasisTest.cpp +++ b/tests/CSSLayoutFlexBasisTest.cpp @@ -7,6 +7,16 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +/** + * @Generated by gentest/gentest.sh with the following input + * + *
+ *
+ *
+ *
+ * + */ + #include #include #include