Chromium Code Reviews| Index: chrome/test/base/js2gtest.js |
| diff --git a/chrome/test/base/js2gtest.js b/chrome/test/base/js2gtest.js |
| index 995a2576c566d02a9c28e8f864873943babf997b..db2aa15fc19fe39b9eea336637c18b1200621226 100644 |
| --- a/chrome/test/base/js2gtest.js |
| +++ b/chrome/test/base/js2gtest.js |
| @@ -10,6 +10,9 @@ var jsFile = arguments[1]; |
| var jsFileBase = arguments[2]; |
| var outputFile = arguments[3]; |
| var testType = arguments[4]; |
| +var testF; |
| +var typedeffedCppFixtures = {}; |
| +var genIncludes = []; |
| // Generate the file to stdout. |
| print('// GENERATED FILE'); |
| @@ -17,8 +20,6 @@ print('// ' + arguments.join(' ')); |
| print('// PLEASE DO NOT HAND EDIT!'); |
| print(); |
| -var testF; |
| - |
| if (testType === 'unit') { |
| print('#include "chrome/test/base/v8_unit_test.h"'); |
| testing.Test.prototype.typedefCppFixture = 'V8UnitTest'; |
| @@ -32,11 +33,25 @@ print('#include "googleurl/src/gurl.h"'); |
| print('#include "testing/gtest/include/gtest/gtest.h"'); |
| print(); |
| +function incFileToPaths(includeFile) { |
|
dpapad
2011/11/03 16:14:34
Prefer the full name includeFileToPaths over the a
Sheridan Rawlins
2011/11/05 16:51:25
FWIW, this is javascript
http://google-styleguide.
Sheridan Rawlins
2011/11/05 22:28:02
Hmm... missed the document part... tackling in th
|
| + return { |
| + path: jsFile.replace(/[^\/]+$/, includeFile), |
| + base: jsFileBase.replace(/[^\/]+$/, includeFile), |
| + }; |
| +} |
| + |
| function GEN(code) { |
| print(code); |
| } |
| -var typedeffedCppFixtures = {}; |
| +function GEN_INCLUDE(includes) { |
| + for(var i = 0; i < includes.length; ++i) { |
|
dpapad
2011/11/03 16:14:34
Space after for.
arv (Not doing code reviews)
2011/11/03 19:04:12
nit
i++
Sheridan Rawlins
2011/11/05 16:51:25
Done.
Sheridan Rawlins
2011/11/05 16:51:25
Done.
|
| + var incPaths = incFileToPaths(includes[i]); |
| + var js = read(incPaths.path); |
| + eval(js); |
|
arv (Not doing code reviews)
2011/11/03 19:04:12
I assume we don't want to eval this in the scope o
Sheridan Rawlins
2011/11/05 16:51:25
Done.
|
| + genIncludes = genIncludes.concat(incPaths.base); |
|
arv (Not doing code reviews)
2011/11/03 19:04:12
push?
Sheridan Rawlins
2011/11/05 16:51:25
Yeah, that's what I wanted, but the thing being pu
Sheridan Rawlins
2011/11/05 22:28:02
Sorry, I guess in this loop, it's a singular item.
|
| + } |
| +} |
| function TEST_F(testFixture, testFunction, testBody) { |
| var browsePreload = this[testFixture].prototype.browsePreload; |
|
arv (Not doing code reviews)
2011/11/09 03:02:06
var proto = this[testFixture].prototype;
|
| @@ -48,6 +63,11 @@ function TEST_F(testFixture, testFunction, testBody) { |
| this[testFixture].prototype.isAsync + ', '; |
| var testShouldFail = this[testFixture].prototype.testShouldFail; |
| var testPredicate = testShouldFail ? 'ASSERT_FALSE' : 'ASSERT_TRUE'; |
| + var addLibraries = genIncludes.concat( |
| + this[testFixture].prototype.addLibraries.map( |
|
arv (Not doing code reviews)
2011/11/03 19:04:12
This looks strange. Why are we getting this from t
Sheridan Rawlins
2011/11/05 16:51:25
I wanted to give the best of both worlds:
1) GEN_I
Sheridan Rawlins
2011/11/05 22:28:02
Or was your concern with using the prototype? If
arv (Not doing code reviews)
2011/11/09 03:02:06
I found it strange that you interact with the prot
|
| + function(incFile) { |
| + return incFileToPaths(incFile).base; |
| + })); |
| if (typedefCppFixture && !(testFixture in typedeffedCppFixtures)) { |
| print('typedef ' + typedefCppFixture + ' ' + testFixture + ';'); |
| @@ -57,6 +77,10 @@ function TEST_F(testFixture, testFunction, testBody) { |
| print(testF + '(' + testFixture + ', ' + testFunction + ') {'); |
| if (testGenPreamble) |
| testGenPreamble(testFixture, testFunction); |
| + for(var i = 0; i < addLibraries.length; ++i) { |
|
dpapad
2011/11/03 16:14:34
Space after for.
Sheridan Rawlins
2011/11/05 16:51:25
Done.
|
| + print(' AddLibrary(FilePath(FILE_PATH_LITERAL("' + |
| + addLibraries[i].replace(/\\/g, '/') + '")));'); |
| + } |
| print(' AddLibrary(FilePath(FILE_PATH_LITERAL("' + |
| jsFileBase.replace(/\\/g, '/') + '")));'); |
| if (browsePreload) { |