Commit Graph

14 Commits

Author SHA1 Message Date
Joe Tsai
d1e65e6634 test.bash: unset GOROOT to fix Travis-CI
When Travis-CI runs the test.bash, it unnecessarily pollutes the environment
with a GOROOT environment variable, which confuses each of the custom invocations
of different Go toolchains. Rather than setting the GOROOT prior to each
invocation of the Go toolchain, just clear the variable once, and let each
toolchain figure out the root for themselves (which all recent versions of Go
know how to do so correctly).

Change-Id: I45ae9f9f98f5573ff42502b7244c90bf1569f66e
Reviewed-on: https://go-review.googlesource.com/128363
Reviewed-by: Herbie Ong <herbie@google.com>
2018-08-07 22:31:19 +00:00
Joe Tsai
ed2fbe0328 test.bash: download dependencies
Use module support in Go1.11 to download the exact version of dependencies
as specified in the go.mod file, this is contrary to "go get -u", which grabs
the latest version, making reproducible builds and tests difficult.

In order for Go1.9 and Go1.10 to work, we also emit a vendor directory for
pre-module support.

Lastly, check whether the go.mod or go.sum files changed
(by shelling to "git diff"). This provides protection in case
a new dependency was added and the go.mod file was not updated.

Change-Id: Iac4e9b224ca9188dc9e63be720f188bfb5ee56ef
Reviewed-on: https://go-review.googlesource.com/127916
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2018-08-07 21:43:44 +00:00
Joe Tsai
ce91da5f05 internal/pragma: package to statically enforce certain properties
Package pragma provides certain constructs that can be used to statically enforce
certain language properties.

Change-Id: I58a87bf7429f3be1b5aae418595fadda32f9d039
Reviewed-on: https://go-review.googlesource.com/127822
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Herbie Ong <herbie@google.com>
2018-08-06 21:47:01 +00:00
Joe Tsai
7828bb327b .travis.yml: add Travis-CI script
Add a simple .travis.yml file that shells out testing to the test.bash script.
Caching the toolchain directories (Go toolchain and protobuf toolchain) saves
around 14min on each run.

This script only runs after Gerrit changes have been pushed to GitHub and acts
as a form of post-submit tests.

Change-Id: Id7d73d2c5fdc0de259d93cceb341ce921f71951d
Reviewed-on: https://go-review.googlesource.com/127915
Reviewed-by: Herbie Ong <herbie@google.com>
2018-08-04 06:22:05 +00:00
Joe Tsai
1bed4543ed test.bash: add script for comprehensive testing
This script is not currently executed by Try-Bots since they do not have the
necessary infrastructure, yet. Instead, this script is intended to be ran as
a pre-commit hook on each contributor's workstation.

The test.bash script works on both Darwin and Linux and tests the repository
across a variety of Go toolchains. The toolchains are downloaded and built
into their own versioned directories and cached. Subsequent runs of the script
only need to run the tests.

Change-Id: Id87841ed42da422ab2e966ea073255ba866c80f7
Reviewed-on: https://go-review.googlesource.com/127826
Reviewed-by: Herbie Ong <herbie@google.com>
2018-08-04 06:21:23 +00:00
Joe Tsai
0e6baaa2cb internal/encoding/wire: switch to use internal errors package
Change-Id: Ibb01f8a5d4dea09c19262f807e305bbebe0e6ab8
Reviewed-on: https://go-review.googlesource.com/127825
Reviewed-by: Herbie Ong <herbie@google.com>
2018-08-04 01:02:24 +00:00
Joe Tsai
025d81dac6 internal/flags: add package to control specialized functionality
Package flags defines a set of constants to control support for certain features.

Other flags that may be added in the future may include:
	PureGo: to control whether protobuf code should avoid using the unsafe
		package and only use Go reflection.
	PureProto: to control whether the proto package ignores the protoiface
		package and only uses protobuf reflection. This is useful for testing.
	Proto2ValidateUTF8: whether to validate UTF-8 in proto2 strings.
	Proto3ValidateUTF8: whether to validate UTF-8 in proto3 strings.

Change-Id: Ibcb8dd8b3e977633b8a4e4a22a0617f2eebcc325
Reviewed-on: https://go-review.googlesource.com/127820
Reviewed-by: Damien Neil <dneil@google.com>
2018-08-03 22:59:53 +00:00
Joe Tsai
be60f99ca7 internal/encoding/wire: fix minor miscategorization in test
Some of the test cases in TestFixed64 actually belong in TestBytes.

Change-Id: I7f3efd77662881b64a96311161440fd220ae8074
Reviewed-on: https://go-review.googlesource.com/127456
Reviewed-by: Chris Manghane <cmang@golang.org>
2018-08-02 21:53:01 +00:00
Joe Tsai
9834a7df51 internal/errors: initial commit
This adds package errors, which provides error handling constructs that are
specific to the protobuf repo. In particular, it provides a NonFatal type
which is useful for capturing non-fatal errors like invalid UTF-8 and required
fields not set.

High-level API:
	type NonFatalErrors []error
		func (NonFatalErrors) Error() string
	type NonFatal struct{ ... }
		func (*NonFatal) Merge(err error) (ok bool)
		func (*NonFatal) AppendInvalidUTF8(field string)
		func (*NonFatal) AppendRequiredNotSet(field string)
	func New(string, ...interface{}) error

Change-Id: I9448c586008240e8987573fe79e0ffb024e7629d
Reviewed-on: https://go-review.googlesource.com/127338
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Herbie Ong <herbie@google.com>
2018-08-02 18:28:47 +00:00
Joe Tsai
22505a4929 internal/encoding/wire: initial commit
This adds package wire, which provides low-level functionality for
marshaling and unmarshaling the protobuf wire format.

High-level API:
	type Number int32
	    const MinValidNumber Number = 1 ...
	type Type int8
	    const VarintType Type = 0 ...
	func ParseError(n int) error

	func ConsumeField(b []byte) (Number, Type, int)
	func ConsumeFieldValue(num Number, typ Type, b []byte) (n int)
	func ConsumeTag(b []byte) (Number, Type, int)
	func ConsumeVarint(b []byte) (v uint64, n int)
	func ConsumeFixed32(b []byte) (v uint32, n int)
	func ConsumeFixed64(b []byte) (v uint64, n int)
	func ConsumeBytes(b []byte) (v []byte, n int)
	func ConsumeGroup(num Number, b []byte) (v []byte, n int)
	func AppendTag(b []byte, num Number, typ Type) []byte
	func AppendVarint(b []byte, v uint64) []byte
	func AppendFixed32(b []byte, v uint32) []byte
	func AppendFixed64(b []byte, v uint64) []byte
	func AppendBytes(b []byte, v []byte) []byte
	func AppendGroup(b []byte, num Number, v []byte) []byte
	func SizeTag(num Number) int
	func SizeVarint(v uint64) int
	func SizeFixed32() int
	func SizeFixed64() int
	func SizeBytes(n int) int
	func SizeGroup(num Number, n int) int

	func DecodeBool(x uint64) bool
	func DecodeTag(x uint64) (Number, Type)
	func DecodeZigZag(x uint64) int64
	func EncodeBool(x bool) uint64
	func EncodeTag(num Number, typ Type) uint64
	func EncodeZigZag(x int64) uint64

Change-Id: I052d8975414aeb182f6e9595c4736e716f1b7e9d
Reviewed-on: https://go-review.googlesource.com/127337
Reviewed-by: Chris Manghane <cmang@golang.org>
Run-TryBot: Chris Manghane <cmang@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-01 23:02:07 +00:00
Joe Tsai
3beba15d7f go.mod: initialize Go module
As a placeholder import path, use "google.golang.org/proto".
This is not a statement about the final import path for the repository.
Since we reserve the right to make breaking changes, we can change this import
path prior to release.

We simply need some import path (could be anything) so that the sub-packages
can import each other.

Change-Id: If80108438c7569c23326fd699dee3ffb582ef852
Reviewed-on: https://go-review.googlesource.com/127340
Reviewed-by: Damien Neil <dneil@google.com>
2018-08-01 20:49:34 +00:00
Joe Tsai
a19bc9bfc6 CONTRIBUTING.md: initial commit
Change-Id: Ic9a678d890e622628db4677cce93d4f8be39003f
Reviewed-on: https://go-review.googlesource.com/127336
Reviewed-by: Damien Neil <dneil@google.com>
2018-08-01 20:39:06 +00:00
Joe Tsai
ca80a50e7b README.md: initial commit
Change-Id: Ifa901a402a3d2c9e4c35d447b77224861cb2ffd4
Reviewed-on: https://go-review.googlesource.com/127335
Reviewed-by: Damien Neil <dneil@google.com>
2018-08-01 19:40:34 +00:00
Andrew Bonventre
fd0e426c3a Initial empty repository 2018-08-01 19:28:05 +00:00