Skip to content

Commit

Permalink
Improved testing, including checking gotoc's FileDescriptorSet output…
Browse files Browse the repository at this point in the history
… against protoc.
  • Loading branch information
dsymonds committed Mar 26, 2016
1 parent 29da0d8 commit 37e69c0
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 2 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
*.6
.*.swp
.DS_Store
6.out
_testmain.go
gotoc
testdata/*.actual
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ minidiff:
mv testdata/mini.pb.go testdata/mini-gotoc.pb.go
protoc --go_out=. testdata/mini.proto
mv testdata/mini.pb.go testdata/mini-protoc.pb.go
sed -i '' '/^var fileDescriptor/,/^}$$/d' testdata/mini-{gotoc,protoc}.pb.go
diff -ud testdata/mini-{gotoc,protoc}.pb.go || true

regtest:
Expand Down
2 changes: 2 additions & 0 deletions testdata/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.baseline
_baseline.raw
2 changes: 2 additions & 0 deletions testdata/1.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Just the basics

syntax = "proto2";

message A {
required int32 a = 1;
optional string b = 2;
Expand Down
2 changes: 2 additions & 0 deletions testdata/2.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Nested message, plus some message references.

syntax = "proto2";

message A {
message B {
}
Expand Down
2 changes: 2 additions & 0 deletions testdata/3.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Default values.

syntax = "proto2";

message A {
optional int32 int = 1 [default=7];
optional bool boolean = 2 [default=true];
Expand Down
2 changes: 2 additions & 0 deletions testdata/4.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Group.

syntax = "proto2";

message A {
optional group B = 1 {
required string x = 2;
Expand Down
9 changes: 9 additions & 0 deletions testdata/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ cd $(dirname $0)
MAX=100
GOTOC=../gotoc
PROTOCMP=./protocmp
PROTOBUF=$HOME/src/protobuf

go build -o protocmp protocmp.go

Expand All @@ -19,6 +20,14 @@ for ((i=1; $i <= $MAX; i=$((i+1)))); do
echo "==> FAILED" 1>&2
failures=$(($failures + 1))
}

protoc --descriptor_set_out=_baseline.raw $i.proto
protoc --decode=google.protobuf.FileDescriptorSet -I $PROTOBUF $PROTOBUF/src/google/protobuf/descriptor.proto \
< _baseline.raw > $i.baseline
$PROTOCMP $i.expected $i.baseline || {
echo "==> BASELINE MISMATCH" 1>&2
failures=$(($failures + 1))
}
done

echo "----------" 1>&2
Expand Down

0 comments on commit 37e69c0

Please sign in to comment.