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
This commit is contained in:
Emil Sjolander
2016-08-15 09:15:07 -07:00
committed by Facebook Github Bot 6
parent c373056d80
commit 28bc42a988
2 changed files with 34 additions and 3 deletions

View File

@@ -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 !== '<div id="default"></div>';
}).map(function(line) {
return ' * ' + line;
}).reduce(function(curr, prev) {
return curr + '\n' + prev;
}));
lines.push(' *');
lines.push(' */');
lines.push('');
lines.push([
'#include <CSSLayout/CSSLayout-internal.h>',
'#include <CSSLayoutTestUtils/CSSLayoutTestUtils.h>',
'#include <gtest/gtest.h>',
'',
];
].reduce(function(curr, prev) {
return curr + '\n' + prev;
}));
for (var i = 0; i < layoutTree.length - 1; i++) {
lines.push('TEST(CSSLayoutTest, INSERT_NAME_HERE) {');