Commit 8df69f08 authored by Josh Haberman's avatar Josh Haberman

Conformance test for JS now work, though 15 tests fail.

parent f873d321
......@@ -230,12 +230,19 @@ conformance_objc-conformance_objc.$(OBJEXT): Conformance.pbobjc.h google/protobu
endif
# JavaScript well-known types are expected to be in a directory called
# google-protobuf, because they are usually in the google-protobuf npm
# package. But we want to use the sources from our tree, so we recreate
# that directory structure here.
google-protobuf:
mkdir google-protobuf
if USE_EXTERNAL_PROTOC
# Some implementations include pre-generated versions of well-known types.
protoc_middleman: $(conformance_protoc_inputs) $(well_known_type_protoc_inputs)
$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --objc_out=. --python_out=. --php_out=. --js_out=import_style=commonjs,binary:. $(conformance_protoc_inputs)
$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --python_out=. --php_out=. --js_out=import_style=commonjs,binary:. $(well_known_type_protoc_inputs)
protoc_middleman: $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) google-protobuf
$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --objc_out=. --python_out=. --php_out=. --js_out=import_style=commonjs,binary:google-protobuf $(conformance_protoc_inputs)
$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --python_out=. --php_out=. --js_out=import_style=commonjs,binary:google-protobuf $(well_known_type_protoc_inputs)
## $(PROTOC) -I$(srcdir) -I$(top_srcdir) --java_out=lite:lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs)
touch protoc_middleman
......@@ -244,9 +251,9 @@ else
# We have to cd to $(srcdir) before executing protoc because $(protoc_inputs) is
# relative to srcdir, which may not be the same as the current directory when
# building out-of-tree.
protoc_middleman: $(top_srcdir)/src/protoc$(EXEEXT) $(conformance_protoc_inputs) $(well_known_type_protoc_inputs)
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --objc_out=$$oldpwd --python_out=$$oldpwd --php_out=$$oldpwd --js_out=import_style=commonjs,binary:$$oldpwd $(conformance_protoc_inputs) )
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --python_out=$$oldpwd --php_out=$$oldpwd --js_out=import_style=commonjs,binary:$$oldpwd $(well_known_type_protoc_inputs) )
protoc_middleman: $(top_srcdir)/src/protoc$(EXEEXT) $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) google-protobuf
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --objc_out=$$oldpwd --python_out=$$oldpwd --php_out=$$oldpwd --js_out=import_style=commonjs,binary:$$oldpwd/google-protobuf $(conformance_protoc_inputs) )
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --python_out=$$oldpwd --php_out=$$oldpwd --js_out=import_style=commonjs,binary:$$oldpwd/google-protobuf $(well_known_type_protoc_inputs) )
## @mkdir -p lite
## oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --java_out=lite:$$oldpwd/lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) )
touch protoc_middleman
......@@ -336,7 +343,7 @@ test_python_cpp: protoc_middleman conformance-test-runner
./conformance-test-runner --enforce_recommended --failure_list failure_list_python_cpp.txt ./conformance_python.py
test_nodejs: protoc_middleman conformance-test-runner
NODE_PATH=../js:. ./conformance-test-runner ./conformance_nodejs.js
NODE_PATH=../js:. ./conformance-test-runner --enforce_recommended --failure_list failure_list_js.txt ./conformance_nodejs.js
if OBJC_CONFORMANCE_TEST
......
......@@ -33,6 +33,7 @@
*/
var conformance = require('conformance_pb');
var test_messages_proto3 = require('google/protobuf/test_messages_proto3_pb');
var fs = require('fs');
var testCount = 0;
......@@ -42,10 +43,15 @@ function doTest(request) {
var response = new conformance.ConformanceResponse();
try {
if (request.getRequestedOutputFormat() === conformance.WireFormat.JSON) {
response.setSkipped("JSON not supported.");
return response;
}
switch (request.getPayloadCase()) {
case conformance.ConformanceRequest.PayloadCase.PROTOBUF_PAYLOAD:
try {
testMessage = conformance.TestAllTypes.deserializeBinary(
testMessage = test_messages_proto3.TestAllTypes.deserializeBinary(
request.getProtobufPayload());
} catch (err) {
response.setParseError(err.toString());
......@@ -62,14 +68,14 @@ function doTest(request) {
}
switch (request.getRequestedOutputFormat()) {
case conformance.UNSPECIFIED:
case conformance.WireFormat.UNSPECIFIED:
response.setRuntimeError("Unspecified output format");
return response;
case conformance.PROTOBUF:
case conformance.WireFormat.PROTOBUF:
response.setProtobufPayload(testMessage.serializeBinary());
case conformance.JSON:
case conformance.WireFormat.JSON:
response.setSkipped("JSON not supported.");
return response;
......@@ -80,7 +86,7 @@ function doTest(request) {
response.setRuntimeError(err.toString());
}
return response
return response;
}
function onEof(totalRead) {
......@@ -95,21 +101,22 @@ function onEof(totalRead) {
function readBuffer(bytes) {
var buf = new Buffer(bytes);
var totalRead = 0;
//console.warn("Want to read: " + bytes);
while (totalRead < bytes) {
var read;
var read = 0;
try {
//console.warn("Trying to read: " + (bytes - totalRead));
read = fs.readSync(process.stdin.fd, buf, totalRead, bytes - totalRead);
} catch (e) {
if (e.code == 'EOF') {
return onEof(totalRead)
} else if (e.code == 'EAGAIN') {
} else {
throw "conformance_nodejs: Error reading from stdin.";
throw "conformance_nodejs: Error reading from stdin." + e;
}
}
if (read === 0) {
return onEof(totalRead);
}
//console.warn("Read: " + read);
totalRead += read;
}
......@@ -124,14 +131,6 @@ function writeBuffer(buffer) {
}
}
function uint8ArrayToBuffer(arr) {
var buffer = new Buffer(arr.length);
for (var i = 0; i < arr.length; i++) {
buffer[i] = arr[i];
}
return buffer;
}
// Returns true if the test ran successfully, false on legitimate EOF.
// If EOF is encountered in an unexpected place, raises IOError.
function doTestIo() {
......@@ -146,6 +145,7 @@ function doTestIo() {
throw "conformance_nodejs: Failed to read request.";
}
serializedRequest = new Uint8Array(serializedRequest);
var request =
conformance.ConformanceRequest.deserializeBinary(serializedRequest);
var response = doTest(request);
......@@ -155,7 +155,7 @@ function doTestIo() {
lengthBuf = new Buffer(4);
lengthBuf.writeInt32LE(serializedResponse.length, 0);
writeBuffer(lengthBuf);
writeBuffer(uint8ArrayToBuffer(serializedResponse));
writeBuffer(new Buffer(serializedResponse));
testCount += 1
......@@ -164,7 +164,7 @@ function doTestIo() {
while (true) {
if (!doTestIo()) {
console.error('conformance_ruby: received EOF from test runner ' +
console.error('conformance_nodejs: received EOF from test runner ' +
"after " + testCount + " tests, exiting")
break;
}
......
Required.ProtobufInput.RepeatedScalarSelectsLast.INT32.ProtobufOutput
Required.ProtobufInput.RepeatedScalarSelectsLast.UINT32.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.BOOL.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.DOUBLE.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.FIXED32.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.FIXED64.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.FLOAT.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.INT32.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.INT64.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.SFIXED32.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.SFIXED64.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.SINT32.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.SINT64.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.UINT32.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.UINT64.ProtobufOutput
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment