aboutsummaryrefslogtreecommitdiff
path: root/js/commonjs/rewrite_tests_for_commonjs.js
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2016-02-04 14:58:45 -0800
committerJosh Haberman <jhaberman@gmail.com>2016-02-18 10:30:21 -0800
commitd6a186a8f18c1b14979e0244c0434b5b89c0f8a9 (patch)
tree9dbeae7f2bc3b075369961a08e7109a72259916a /js/commonjs/rewrite_tests_for_commonjs.js
parent9e60036c1b1db947d29cbaaa668aeae19e7d2068 (diff)
downloadprotobuf-d6a186a8f18c1b14979e0244c0434b5b89c0f8a9.tar.gz
protobuf-d6a186a8f18c1b14979e0244c0434b5b89c0f8a9.tar.bz2
protobuf-d6a186a8f18c1b14979e0244c0434b5b89c0f8a9.zip
Added some documentation in comments.
Diffstat (limited to 'js/commonjs/rewrite_tests_for_commonjs.js')
-rw-r--r--js/commonjs/rewrite_tests_for_commonjs.js22
1 files changed, 21 insertions, 1 deletions
diff --git a/js/commonjs/rewrite_tests_for_commonjs.js b/js/commonjs/rewrite_tests_for_commonjs.js
index 4dc0a22d..d49f8a93 100644
--- a/js/commonjs/rewrite_tests_for_commonjs.js
+++ b/js/commonjs/rewrite_tests_for_commonjs.js
@@ -1,5 +1,25 @@
/**
- * @fileoverview Description of this file.
+ * @fileoverview Utility to translate test files to CommonJS imports.
+ *
+ * This is a somewhat hacky tool designed to do one very specific thing.
+ * All of the test files in *_test.js are written with Closure-style
+ * imports (goog.require()). This works great for running the tests
+ * against Closure-style generated code, but we also want to run the
+ * tests against CommonJS-style generated code without having to fork
+ * the tests.
+ *
+ * Closure-style imports import each individual type by name. This is
+ * very different than CommonJS imports which are by file. So we put
+ * special comments in these tests like:
+ *
+ * // CommonJS-LoadFromFile: test_pb
+ * goog.require('proto.jspb.test.CloneExtension');
+ * goog.require('proto.jspb.test.Complex');
+ * goog.require('proto.jspb.test.DefaultValues');
+ *
+ * This script parses that special comment and uses it to generate proper
+ * CommonJS require() statements so that the tests can run and pass using
+ * CommonJS imports.
*/
var lineReader = require('readline').createInterface({