Skip to content

Test suite fixes and improvements for Windows - #780

Merged
jrosdahl merged 5 commits into
ccache:masterfrom
nickhutchinson:work/win-test-fixes
Jan 19, 2021
Merged

jrosdahl merged 5 commits into
ccache:masterfrom
nickhutchinson:work/win-test-fixes

Conversation

@nickhutchinson

Copy link
Copy Markdown
Contributor

Small tweaks to get more tests passing on Windows: account for \r\n line endings in ccache --version test, and skip some tests that can never succeed on Windows.

I noticed that having more tests running on Windows would increase CI test run times by a few minutes. This seems to be due to git-bash's emulation of fork/exec being extremely slow -- on my machine it's roughly 30ms to spawn /usr/bin/true from a bash script compared to 2ms on my macOS machine. So I've also made some tweaks to improve performance on Windows by avoiding unneeded subshells.

Also fixes some other issues with the test suite:

  • having multiple arguments in CC wasn't handled properly in some cases
  • on test failure we'd pass the test name directly to printf, which caused some confusing errors when the test started with a -.

In some cases test names would be interpreted as invalid arguments to
`printf` instead of a string to be printed, and this resulted in
confusing output on test failure.
git-bash's `ln -s` defaults to making a copy instead of making a symlink
for compatibility, but it is possible to ask for native Windows symlink
support instead.

Creating symlinks on Windows requires suitable permissions, or that
"Developer Mode" is enabled. (This is true for the Github Actions
Windows runners.)
On Windows, git-bash's emulation of fork/exec is exteremely slow -- on
my machine it's typically around 30ms to spawn /usr/bin/true from a bash
script compared to 2ms on my macOS machine.

This is really noticeable when running ccache tests. This patch fixes
some of the hot code (i.e. code invoked for every test case) to avoid
spawning external commands or creating as many subshells.
- account for \r\n line endings in --version test
- skip tests that can never succeed on Windows
@jrosdahl jrosdahl added issue: improvement Enhancements that improve performance, usability or code quality, not a new feature area: tests Affects testing of Ccache itself os: windows Related to building or running on Windows labels Jan 19, 2021
@jrosdahl
jrosdahl merged commit 3ea726f into ccache:master Jan 19, 2021
@jrosdahl

Copy link
Copy Markdown
Member

Thanks.

@jrosdahl jrosdahl added this to the 4.2 milestone Jan 19, 2021
@nickhutchinson
nickhutchinson deleted the work/win-test-fixes branch January 30, 2021 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tests Affects testing of Ccache itself issue: improvement Enhancements that improve performance, usability or code quality, not a new feature os: windows Related to building or running on Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants