Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Skylark test rules to emit test/benchmark details for summary #250

Closed
schroederc opened this issue Jun 16, 2015 · 8 comments
Closed

Comments

@schroederc
Copy link
Contributor

It'd be nice if Skylark test rules could emit details about the tests it ran and have them appear in Bazel's test summary.

For instance, a Skylark test rule for Go could parse the test binary's output for which exact tests passed/failed, how long each took, and any log output. It could then be relayed back to Bazel through a special file (possibly JSON) which can be used to populate each TestResultData proto and be displayed to the user.

Likewise, I think Bazel should support benchmarks in a similar way (perhaps through bazel benchmark instead of bazel test).

@hanwen
Copy link
Contributor

hanwen commented Jun 16, 2015

Most of this already exists. Your test should emit a .xml file in a schema that

https://github.com/google/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/test/TestXmlOutputParser.java

understands.

@schroederc
Copy link
Contributor Author

Neat. Is this documented/stable? How does a Skylark rule mark a file to be parsed by Bazel?

@hanwen
Copy link
Contributor

hanwen commented Jun 17, 2015

AFAICR, the test framework should just emit the .XML file, and it should work automatically. The support has been there for years, so it shoul dbe pretty stable.

@schroederc
Copy link
Contributor Author

Where should the file be emitted and what should it be named? Tests are run in their respective runfiles directory so I'm assuming the file should be relative to that.

Can sh_tests do the same thing?

@hanwen
Copy link
Contributor

hanwen commented Jun 18, 2015

https://github.com/google/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java#L178

it should have the same name as the test log file, but with xml as an extension. Come to think of it, the file name should probably be passed as an environment variable somewhere; I will have a look at the internal variant.

@damienmg
Copy link
Contributor

in sh_test the good variable is XML_OUTPUT_FILE (see https://github.com/google/bazel/blob/master/src/test/shell/unittest.bash#L450)

It should be the same for other test runner I believe.

@schroederc
Copy link
Contributor Author

XML_OUTPUT_FILE is not set in a sh_test. These are the only variables set at the beginning of a sh_test:

BASH
BASHOPTS
BASH_ALIASES
BASH_ARGC
BASH_ARGV
BASH_CMDS
BASH_LINENO
BASH_SOURCE
BASH_VERSINFO
BASH_VERSION
DIRSTACK
EUID
GROUPS
HOSTNAME
HOSTTYPE
IFS
MACHTYPE
OPTERR
OPTIND
OSTYPE
PATH
PIPESTATUS
PPID
PS4
PWD
SHELL
SHELLOPTS
SHLVL
TERM
TEST_SIZE
TEST_SRCDIR
TEST_TIMEOUT
TEST_TMPDIR
TMPDIR
TZ
UID
_

@hanwen
Copy link
Contributor

hanwen commented Jun 26, 2015

b6f557b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants