Commit 496017d
committed
fix(test/releases-github): use mkdtemp to avoid cache-hit races
Two TOCTOU-protection tests in `downloadGitHubRelease` named their
scratch dir `test-github-dl-${Date.now()}`. Millisecond precision isn't
enough isolation: a prior run's cached `.version` + binary left behind
in `/tmp/test-github-dl-<prev>` could, under parallel worker scheduling
or same-ms retry, land at the same path as the next run's
`testDownloadDir`. The first `downloadGitHubRelease()` call then hit
the cache-hit branch (`existsSync(versionPath) && existsSync(binary)`)
instead of invoking `httpDownload`, causing the
`toHaveBeenCalledTimes(1)` assertion to fail with 0. Switches both
tests to `fs.mkdtemp`, which gives OS-guaranteed unique paths.1 parent fd973e8 commit 496017d
1 file changed
Lines changed: 13 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
842 | 842 | | |
843 | 843 | | |
844 | 844 | | |
845 | | - | |
846 | | - | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
847 | 854 | | |
848 | 855 | | |
849 | 856 | | |
| |||
940 | 947 | | |
941 | 948 | | |
942 | 949 | | |
943 | | - | |
944 | | - | |
945 | | - | |
946 | | - | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
947 | 954 | | |
948 | 955 | | |
949 | 956 | | |
| |||
0 commit comments