Current goc e2e test is based on the bats-core framework, you should read its document first.
- bats-core
- install
goc
toPATH
- build
goc
withgoc
, generate the binarygocc
, installgocc
toPATH
First of all, you should start a goc server
in setup_file
function from the backend,
setup_file() {
goc server 3>&- &
GOC_PID=$!
sleep 2
goc init
}
According to this, you should turn off the file descriptor 3 for the long-running backend job. Then you can write any goc
subcommand. Remember to kill the $GOC_PID
in the teardown_file
function.
We also need to test with the covered gocc in order to get coverage reports.
Most gocc test cases share the same structure, here is the common flow diagram:
(1) (2)
(wait_profile_backend "xxx" &) --> wait ci-sync exist --> (goc profile -o filtered.cov)--
| |
| |
| (4) |
--(gocc --debugcisyncfile ci-sync) --> finish, write ci-sync --> sleep 5; exit |(5)
| | |
| (3) (6) | |
|------------------------>(goc server &) --------------------------------| |
| |
---------------------------------------------------------
- start the
wait_profile_backend
in the background. wait_profile_backend
will block until the fileci-sync.bak
exists.- the covered
gocc
subcommand start and register to thegoc server
. - the covered
gocc
subcommand run its own logic until finish, as we add the--debugcisyncfile ci-sync
flag, it will write a file calledci-sync
, and wait 5 seconds. wait_profile_backend
continue to run, and try to get the profile from thegoc server
.- the
goc server
finally call the http API to get thegocc
profile.