Commit graph

11 commits

Author SHA1 Message Date
Dan Willemsen
6dd6868dec Support go1.18, drop support for <go1.8
Change-Id: I676aabbd7173e6ae523e6fcedfaafcd44ba85c3a
2021-12-14 15:58:35 -08:00
Colin Cross
ce447fc83e Support go 1.16 in gotestmain
go 1.16 adds a new method on the testDeps interface passed to
testing.MainStart.

Test: m nothing
Change-Id: I5c42a4294a775337696dc2d64791dee301eac390
2021-05-04 19:29:23 -07:00
Colin Cross
463eab7950 Support examples as tests
go test supports running examples as tests and verifying their
output, add support for running them to gotestmain.

Change-Id: If51abc64467d4701195cefc6db513f4d008794b5
2019-02-15 15:13:37 -08:00
Dan Willemsen
e6d45fe39f Support go1.10
Add stubs for the new testDeps interface functions. Also removes testing
for 1.8.

Change-Id: Ice58cca20658d905df9fb87e822d7861abf60976
2018-02-27 01:49:49 -08:00
Dan Willemsen
53d563facb Fix build on Go 1.9
Change-Id: Ie471f396b22cd88104b4f05dbcf3677c7ffd5f08
2017-07-25 10:45:51 -07:00
Colin Cross
5f303b9ee8 Fix tests with TestMain
If tests have a TestMain method the os import is unused and
breaks building the test.

Test: gotestmain/testmain_test.go
Change-Id: Ia46cdd0df71b0fc7a53d08644d220ecfd779b2ff
2017-07-13 11:10:39 -07:00
Colin Cross
83359c674e Support TestMain in tests
Use testing.MainStart to support test packages that implement
TestMain for initial setup and teardown.

Change-Id: I7330a8e922448063f291f7b5b2eed31d274248bd
2017-07-12 13:19:53 -07:00
Dan Willemsen
61caa240c8 Sort testcases to make build (more) reproducible
f.Scope.Objects is a map, so iteration order isn't defined. To fix this,
lets just sort the testcase list so that it's always consistent.

There are still some paths in the built go files, but this improves
repeatability using the same paths.

Test: Build twice, compare generated test.go files.
Change-Id: Ie3fc896f54314fee0e0e9ddc3a9e06ad2f72a78d
2017-01-31 10:45:08 -08:00
Dan Willemsen
10e4357dbb Fix -test.run test selection with gotestmain
matchString was implemented separately on older go versions since they
didn't want a build dependency on the regex package from the testing
package.

Starting in Go 1.8, this is implemented using a internal package to
break the dependency, but until we require that everywhere, just copy
the regex implementation like the old `go test` did. I'm not sure we'll
be able to use the internal package in the future anyways.

Change-Id: Ief37542640026f9d73a75fd802f2691af50e2511
2017-01-18 14:37:13 -08:00
Tim Kilbourn
a664b0a7d6 Fix package names for executables.
Go 1.6 fixed a bug where compiling with the -pack flag allowed non-main
packages to link.
https://github.com/golang/go/issues/13468

This change uses package main for choosestage and gotestmain.
2016-03-23 20:57:43 -07:00
Dan Willemsen
87ba294ceb Add option to build and run tests during bootstrap
Users that want to enable this option can use the '-t' option to
bootstrap.bash when passing '-r'. Builders that want to enable this can
set the RUN_TESTS environment variable in their bootstrap.bash.

The gotestmain tools is needed to write the main functions for the test
binaries, since 'go test' doesn't work well in this environment.

Change-Id: Iec5c2b5c9c3f5e3ba0ac8677fb88f5e963f9bd3f
2015-06-25 11:45:54 -07:00