ccache icon indicating copy to clipboard operation
ccache copied to clipboard

Make the tests work under Windows

Open rvogg opened this issue 4 years ago • 5 comments

With these changes I made some adaptations that the tests run under Windows again. Tests that fail and cannot be fixed quickly have been deactivated for the moment. Additionally I added mingw-w64 builds under Windows, because the msvc builds contain other bugs.

In some places I had to give the shell scripts a '.sh' extension to make them run under Windows. It looks like this does not affect the other operating systems. ( CCACHE_DETECT_SHEBANG does not work correctly -> The tests produce a "could_not_find_compiler" error if the .sh extension is missing.)

I hope this change helps avoid breaking existing behavior on Windows and make ccache even better on Windows.

Note: The secondary_http test fails sporadically on Windows. (Perhaps it should also be disabled)

rvogg avatar Oct 06 '21 13:10 rvogg

This looks good to me. Actually, i had to implement some very small portions of it in order to implement and run on Windows the testcases for the new compiler I would like to add support for (https://github.com/ccache/ccache/pull/942).

If, by chance, your patch gets merged soon I would rebase my own patch. thanks

louiscaron avatar Oct 19 '21 06:10 louiscaron

With these changes I made some adaptations that the tests run under Windows again.

Note that the Windows tests are work in progress and have never worked before, so it's not the case that they have become broken.

jrosdahl avatar Nov 03 '21 20:11 jrosdahl

With these changes I made some adaptations that the tests run under Windows again.

Note that the Windows tests are work in progress and have never worked before, so it's not the case that they have become broken.

I thought that because there were many if ! $HOST_OS_WINDOWS are spread over the tests, it was less broken than now. Currently not a single test runs on Windows because they all fail on the expect_stat function.

My initial motivation for this change was: I started to fix the basedir functionality for Windows, because it doesn't really work with all the Windows path mess. After a few #ifdef __Win32 changes I realized that I broke a lot more but couldn't really check what. So I first tried to get to a state where I could verify my changes.

I didn't fix all tests, because in some cases ccache really doesn't work on Windows or the effort to get it running in the git-bash was too high. And I don't expect to fix all bugs for ccache under Windows, but only that no additional bugs get in by mistakes.

rvogg avatar Nov 03 '21 22:11 rvogg

I added the commit 'handle newlines on Windows properly' from #954. With this I was able to remove some hacks.

I did not add the commit 'handle properly also stdout in addition to stderr' because it breaks the correct ccache behavior. With export CCACHE_NOCPP2=1 the preprocessor output is written to stdout.

rvogg avatar Nov 09 '21 15:11 rvogg

@rvogg wrote:

I thought that because there were many if ! $HOST_OS_WINDOWS are spread over the tests

I understand. @nickhutchinson made several Windows-related improvements (#757, #780, #789, maybe more) of the test suite, but it was never enabled in CI so I don't think it worked fully.

My initial motivation for this change was: I started to fix the basedir functionality for Windows, because it doesn't really work with all the Windows path mess.

Regarding that, I think that the way to make basedir work in a reasonable cross-platform way is to start using std::filesystem::path internally instead of handling paths and normalization spread throughout the code. See also #866.

jrosdahl avatar Dec 14 '21 20:12 jrosdahl

@rvogg ping

orgads avatar Aug 14 '22 13:08 orgads

Rebased and created a new PR #1133

orgads avatar Aug 14 '22 20:08 orgads