goc/tests
2020-08-05 20:14:40 +08:00
..
samples add unit test for merge 2020-08-05 20:14:40 +08:00
agent.bats Fix cover service listen port issue for #74 2020-08-05 14:42:00 +08:00
build.bats enhance "file lock sync" logic 2020-07-17 20:20:07 +08:00
clear.bats enhance "file lock sync" logic 2020-07-17 20:20:07 +08:00
cover.bats enhance "file lock sync" logic 2020-07-17 20:20:07 +08:00
diff.bats enhance "file lock sync" logic 2020-07-17 20:20:07 +08:00
init.bats enhance "file lock sync" logic 2020-07-17 20:20:07 +08:00
install.bats add unittes case & add e2e sample 2020-07-23 15:43:16 +08:00
list.bats enhance "file lock sync" logic 2020-07-17 20:20:07 +08:00
merge.bats add integration test 2020-08-05 20:14:23 +08:00
profile.bats enhance "file lock sync" logic 2020-07-17 20:20:07 +08:00
README.md add e2e test README 2020-07-20 10:07:08 +08:00
register.bats enhance "file lock sync" logic 2020-07-17 20:20:07 +08:00
run-ci-actions.sh add integration test 2020-08-05 20:14:23 +08:00
run-in-local.sh update run e2e test case 2020-07-17 14:27:00 +08:00
run.bats enhance "file lock sync" logic 2020-07-17 20:20:07 +08:00
server.bats add version test 2020-07-17 13:01:36 +08:00
util.sh enhance "file lock sync" logic 2020-07-17 20:20:07 +08:00
version.bats enhance "file lock sync" logic 2020-07-17 20:20:07 +08:00

How to write goc e2e test cases

Current goc e2e test is based on the bats-core framework, you should read its document first.

Local dev requirements

  • bats-core
  • install goc to PATH
  • build goc with goc, generate the binary gocc, install gocc to PATH

Test goc

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.

Test covered goc - gocc

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 &) --------------------------------|              |
                                  |                                                       |
                                  ---------------------------------------------------------
  1. start the wait_profile_backend in the background.
  2. wait_profile_backend will block until the file ci-sync.bak exists.
  3. the covered gocc subcommand start and register to the goc server.
  4. the covered gocc subcommand run its own logic until finish, as we add the --debugcisyncfile ci-sync flag, it will write a file called ci-sync, and wait 5 seconds.
  5. wait_profile_backend continue to run, and try to get the profile from the goc server.
  6. the goc server finally call the http API to get the gocc profile.