mirror of
https://github.com/ddworken/hishtory.git
synced 2025-02-18 03:20:53 +01:00
Include failed test goldens as artifacts for easier test fixing on github actions
This commit is contained in:
parent
8b50807c1d
commit
072fe2409a
8
.github/workflows/go-test.yml
vendored
8
.github/workflows/go-test.yml
vendored
@ -81,12 +81,18 @@ jobs:
|
||||
|
||||
# Add an extra short delay to allow datadog to flush metrics
|
||||
sleep 300 # 5 minutes
|
||||
- name: Archive test results
|
||||
- name: Upload test results json
|
||||
uses: actions/upload-artifact@v3
|
||||
if: success() || failure()
|
||||
with:
|
||||
name: test-results-{{ matrix.os }}.json
|
||||
path: /tmp/testrun.json
|
||||
- name: Upload failed test goldens
|
||||
uses: actions/upload-artifact@v3
|
||||
if: success() || failure()
|
||||
with:
|
||||
name: test-goldens-{{ matrix.os }}
|
||||
path: /tmp/test-goldens/
|
||||
|
||||
# - name: Setup tmate session
|
||||
# if: ${{ failure() }}
|
||||
|
@ -370,6 +370,10 @@ func CompareGoldens(t testing.TB, out, goldenName string) {
|
||||
}
|
||||
}
|
||||
if diff := cmp.Diff(string(expected), out); diff != "" {
|
||||
if err := os.Mkdir("/tmp/test-goldens", os.ModePerm); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
require.NoError(t, os.WriteFile(path.Join("/tmp/test-goldens", goldenName), []byte(out), 0644))
|
||||
if os.Getenv("HISHTORY_UPDATE_GOLDENS") == "" {
|
||||
_, filename, line, _ := runtime.Caller(1)
|
||||
t.Fatalf("hishtory golden mismatch for %s at %s:%d (-expected +got):\n%s\nactual=\n%s", goldenName, filename, line, diff, out)
|
||||
|
Loading…
Reference in New Issue
Block a user