| Index: chrome/test/base/js2gtest.js
|
| diff --git a/chrome/test/base/js2gtest.js b/chrome/test/base/js2gtest.js
|
| index 19e063c86c451ff5421f180405abaa4f66265be5..8d0f7e734bb1eeb2a92629c2d24246998e86e7de 100644
|
| --- a/chrome/test/base/js2gtest.js
|
| +++ b/chrome/test/base/js2gtest.js
|
| @@ -36,13 +36,6 @@ var jsFile = arguments[1];
|
| var jsFileBase = arguments[2];
|
|
|
| /**
|
| - * The cwd, as determined by the paths of |jsFile| and |jsFileBase|.
|
| - * This is usually relative to the root source directory and points to the
|
| - * directory where the GYP rule processing the js file lives.
|
| - */
|
| -var jsDirBase = jsFileBase.replace(jsFile, '');
|
| -
|
| -/**
|
| * Path to Closure library style deps.js file.
|
| * @type {string?}
|
| */
|
| @@ -158,27 +151,24 @@ function maybeGenHeader(testFixture) {
|
|
|
|
|
| /**
|
| + * @type {Array<{path: string, base: string>}
|
| + */
|
| +var pathStack = [];
|
| +
|
| +
|
| +/**
|
| * Convert the |includeFile| to paths appropriate for immediate
|
| * inclusion (path) and runtime inclusion (base).
|
| * @param {string} includeFile The file to include.
|
| * @return {{path: string, base: string}} Object describing the paths
|
| * for |includeFile|. |path| is relative to cwd; |base| is relative to
|
| - * source root.
|
| + * source root.
|
| */
|
| function includeFileToPaths(includeFile) {
|
| - if (includeFile.indexOf(jsDirBase) == 0) {
|
| - // The caller supplied a path relative to root source.
|
| - var relPath = includeFile.replace(jsDirBase, '');
|
| - return {
|
| - path: relPath,
|
| - base: jsDirBase + relPath
|
| - };
|
| - }
|
| -
|
| - // The caller supplied a path relative to the input js file's directory (cwd).
|
| + paths = pathStack[pathStack.length - 1];
|
| return {
|
| - path: jsFile.replace(/[^\/\\]+$/, includeFile),
|
| - base: jsFileBase.replace(/[^\/\\]+$/, includeFile),
|
| + path: paths.path.replace(/[^\/\\]+$/, includeFile),
|
| + base: paths.base.replace(/[^\/\\]+$/, includeFile),
|
| };
|
| }
|
|
|
| @@ -304,9 +294,7 @@ function GEN_BLOCK(commentEncodedCode) {
|
| /**
|
| * Generate includes for the current |jsFile| by including them
|
| * immediately and at runtime.
|
| - * The paths are allowed to be:
|
| - * 1. relative to the root src directory (i.e. similar to #include's).
|
| - * 2. relative to the directory specified in the GYP rule for the file.
|
| + * The paths must be relative to the directory of the current file.
|
| * @param {Array<string>} includes Paths to JavaScript files to
|
| * include immediately and at runtime.
|
| */
|
| @@ -314,7 +302,9 @@ function GEN_INCLUDE(includes) {
|
| for (var i = 0; i < includes.length; i++) {
|
| var includePaths = includeFileToPaths(includes[i]);
|
| var js = read(includePaths.path);
|
| + pathStack.push(includePaths);
|
| ('global', eval)(js);
|
| + pathStack.pop();
|
| genIncludes.push(includePaths.base);
|
| }
|
| }
|
| @@ -396,4 +386,6 @@ function TEST_F(testFixture, testFunction, testBody) {
|
|
|
| // Now that generation functions are defined, load in |jsFile|.
|
| var js = read(jsFile);
|
| +pathStack.push({path: jsFile, base: jsFileBase});
|
| eval(js);
|
| +pathStack.pop();
|
|
|