Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
15239361
Commit
15239361
authored
Mar 31, 2016
by
Josh Haberman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for CommonJS tests.
parent
aeacf516
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
8 deletions
+30
-8
export_testdeps.js
js/commonjs/export_testdeps.js
+18
-0
rewrite_tests_for_commonjs.js
js/commonjs/rewrite_tests_for_commonjs.js
+12
-8
No files found.
js/commonjs/export_testdeps.js
0 → 100644
View file @
15239361
/**
* @fileoverview Export symbols needed by tests in CommonJS style.
*
* This file is like export.js, but for symbols that are only used by tests.
* However we exclude assert functions here, because they are exported into
* the global namespace, so those are handled as a special case in
* export_asserts.js.
*/
goog
.
require
(
'goog.crypt.base64'
);
goog
.
require
(
'jspb.arith.Int64'
);
goog
.
require
(
'jspb.arith.UInt64'
);
goog
.
require
(
'jspb.BinaryEncoder'
);
goog
.
require
(
'jspb.BinaryDecoder'
);
goog
.
require
(
'jspb.utils'
);
exports
.
goog
=
goog
;
exports
.
jspb
=
jspb
;
js/commonjs/rewrite_tests_for_commonjs.js
View file @
15239361
...
...
@@ -61,6 +61,18 @@ function camelCase(str) {
var
module
=
null
;
var
pkg
=
null
;
// Header: goes in every file at the top.
console
.
log
(
"var global = Function('return this')();"
);
console
.
log
(
"var googleProtobuf = require('google-protobuf');"
);
console
.
log
(
"var testdeps = require('testdeps_commonjs');"
);
console
.
log
(
"global.goog = testdeps.goog;"
);
console
.
log
(
"global.jspb = testdeps.jspb;"
);
console
.
log
(
"var asserts = require('closure_asserts_commonjs');"
);
console
.
log
(
""
);
console
.
log
(
"// Bring asserts into the global namespace."
);
console
.
log
(
"googleProtobuf.object.extend(global, asserts);"
);
lineReader
.
on
(
'line'
,
function
(
line
)
{
var
isRequire
=
line
.
match
(
/goog
\.
require
\(
'
([^
'
]
*
)
'
\)
/
);
var
isLoadFromFile
=
line
.
match
(
/CommonJS-LoadFromFile:
(\S
*
)
(
.*
)
/
);
...
...
@@ -72,14 +84,6 @@ lineReader.on('line', function(line) {
console
.
log
(
"googleProtobuf.exportSymbol('"
+
fullSym
+
"', "
+
module
+
sym
+
', global);'
);
}
}
else
if
(
isLoadFromFile
)
{
if
(
!
module
)
{
console
.
log
(
"var googleProtobuf = require('google-protobuf');"
);
console
.
log
(
"var asserts = require('closure_asserts_commonjs');"
);
console
.
log
(
"var global = Function('return this')();"
);
console
.
log
(
""
);
console
.
log
(
"// Bring asserts into the global namespace."
);
console
.
log
(
"googleProtobuf.object.extend(global, asserts);"
);
}
var
module_path
=
isLoadFromFile
[
1
].
split
(
'/'
);
module
=
camelCase
(
module_path
[
module_path
.
length
-
1
]);
pkg
=
isLoadFromFile
[
2
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment