Cache: gzip tests fail on Windows
Open
Nobody has claimed this yet.
bug
- Dominant language
- TypeScript
- Stars
- 5.9k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
On Windows the tests for the cache package currently don't all pass. The tar/gzip related tests have a number of errors.
The errors are due to the following Windows-specific changes:
- exec is used to check the GNU tar version (extra call to the stub)
- GNU tar gets an extra option
--force-local - tar is called without the full absolute path
To Reproduce
On a Windows machine:
- Clone actions/toolkit
- On main branch, run the following commands:
npm i npm run bootstrap npm run build npm run test -- packages/cache
Expected behavior
All tests pass on Windows
Actual behavior
FAIL packages/cache/__tests__/tar.test.ts
V zstd extract tar (5ms)
× gzip extract tar (3ms)
V gzip extract GNU tar on windows (1ms)
V zstd create tar (5ms)
× gzip create tar (7ms)
V zstd list tar (2ms)
V zstdWithoutLong list tar
× gzip list tar (2ms)
? gzip extract tar
expect(jest.fn()).toHaveBeenCalledTimes(1)
Expected mock function to have been called one time, but it was called two times.
78 | ? `${process.env['windir']}\\System32\\tar.exe`
79 | : defaultTarPath
> 80 | expect(execMock).toHaveBeenCalledTimes(1)
| ^
81 | expect(execMock).toHaveBeenCalledWith(
82 | `"${tarPath}"`,
83 | [
at packages/cache/__tests__/tar.test.ts:80:20
at fulfilled (packages/cache/__tests__/tar.test.ts:24:58)
? gzip create tar
expect(jest.fn()).toHaveBeenCalledWith(expected)
Expected mock function to have been called with:
"\"C:\\Windows\\System32\\tar.exe\""
as argument 1, but it was called with
"\"tar\"".
["--posix", "-z", "-cf", "cache.tgz", "-P", "-C", "[...]/toolkit", "--files-from", "manifest.txt"]
as argument 2, but it was called with
["--posix", "-z", "-cf", "cache.tgz", "-P", "-C", "[...]/toolkit", "--files-from", "manifest.txt", "--force-local"].
Difference:
- Expected
+ Received
Array [
"--posix",
"-z",
"-cf",
"cache.tgz",
"-P",
"-C",
"[...]/toolkit",
"--files-from",
"manifest.txt",
+ "--force-local",
]
174 |
175 | expect(execMock).toHaveBeenCalledTimes(1)
> 176 | expect(execMock).toHaveBeenCalledWith(
| ^
177 | `"${tarPath}"`,
178 | [
179 | '--posix',
at packages/cache/__tests__/tar.test.ts:176:20
at fulfilled (packages/cache/__tests__/tar.test.ts:24:58)
? gzip list tar
expect(jest.fn()).toHaveBeenCalledWith(expected)
Expected mock function to have been called with:
"\"C:\\Windows\\System32\\tar.exe\""
as argument 1, but it was called with
"\"tar\"".
["-z", "-tf", "C:/Windows/fakepath/cache.tar", "-P"]
as argument 2, but it was called with
["-z", "-tf", "C:/Windows/fakepath/cache.tar", "-P", "--force-local"].
Difference:
- Expected
+ Received
Array [
"-z",
"-tf",
"C:/Windows/fakepath/cache.tar",
"-P",
+ "--force-local",
]
255 | : defaultTarPath
256 | expect(execMock).toHaveBeenCalledTimes(1)
> 257 | expect(execMock).toHaveBeenCalledWith(
| ^
258 | `"${tarPath}"`,
259 | [
260 | '-z',
at packages/cache/__tests__/tar.test.ts:257:20
at fulfilled (packages/cache/__tests__/tar.test.ts:24:58)
Desktop:
- OS: Windows
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run npm run test -- packages/cache on Windows after installing, bootstrapping, and building. Start with packages/cache/tests/tar.test.ts and the cache package's tar implementation; done means the gzip extract, create, and list tests pass with the expected tar path, options, and exec call count.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100