exercism / go-test-runner

GNU Affero General Public License v3.0
15 stars 17 forks source link

Add smoke tests #106

Closed ErikSchierboom closed 1 year ago

ErikSchierboom commented 1 year ago

This PR adds smoke tests for some common scenarios.

The goal of the smoke tests is to increase confidence that the Docker image that is produced works as intended. The repo contains other tests, which are great, but what this PR adds is that it runs an integration test using the following setup:

  1. Build the Docker image
  2. Run the Docker image with the tests directory mapped into the container
  3. Run the Docker image's normal entrypoint (bin/run.sh) on each of the test cases defined in the tests directory
  4. Verify that the output of those test runs matches the expected output (which is stored inside the tests directories

If successful, we then know that:

  1. The Docker image can be built successfully
  2. The bin/run.sh entrypoint inside the Docker image is setup correctly
  3. The test runner generates the correct output
github-actions[bot] commented 1 year ago

Pull Request Test Coverage Report for Build 5813213734


Files with Coverage Reduction New Missed Lines %
testrunner/ast.go 16 74.11%
<!-- Total: 16 -->
Totals Coverage Status
Change from base Build 5467785147: -0.9%
Covered Lines: 404
Relevant Lines: 622

💛 - Coveralls
iHiD commented 1 year ago

For context, nearly all test runners have this setup. A few older ones (the OGs!) don't have the exact same setup, so this is an aim to standardise.

ErikSchierboom commented 1 year ago

Addendum: I know that the Go code also has golden tests, but AFAICT it doesn't build and use the Docker image to verify it.

ErikSchierboom commented 1 year ago

This doesn't yet work due to some permissions issue. If anyone has an idea how to solve that, I'd be interested to hear :)

ErikSchierboom commented 1 year ago

Fixed the issue!

ErikSchierboom commented 1 year ago

As nobody seems around to review this, I'm gonna go ahead and merge this.

junedev commented 1 year ago

@ErikSchierboom I was on vacation but I'm sure this is fine, thanks! Just as a heads up, when we update the Go version, there are sometimes minor changes in the test result output, mostly something like whitespace changes. I think the test still helps to increase confidence regarding the docker the file etc as you wrote, just limiting the expectations a bit that we won't need to touch them at all.

ErikSchierboom commented 1 year ago

Just as a heads up, when we update the Go version, there are sometimes minor changes in the test result output, mostly something like whitespace changes.

That's perfectly fine, it happens to many test runners. One easy thing to do is:

bin/run-tests-in-docker.sh
find tests -name results.json -execdir cp results.json expected_results.json \;

This will create a results.json and then copy it to the expected_results.json, which allows you to quickly update the expected_results.json files with the latest version.