Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Unified Diff: chrome/test/base/js2gtest.js

Issue 1145243006: Port chromevox build to GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@externs
Patch Set: Workaround hardlink related spuroius rebuild issue by using a stamp file (not ideal). Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/base/js2gtest.gni ('k') | chrome/third_party/chromevox/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « chrome/test/base/js2gtest.gni ('k') | chrome/third_party/chromevox/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698