New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make tests portable to Windows #332

merged 3 commits into from Jul 26, 2014


None yet
2 participants

living180 commented Jul 25, 2014

This PR makes the full test suite run on Windows, with the exception of one test that must be skipped because it uses *nix-specific functionality.

living180 added some commits Jul 25, 2014

test.helper: shutil.rmtree workaround for Windows
On Windows, shutil.rmtree() raises an exception if it tries to remove a
file marked as read-only.  The files that git creates in the
.git/objects directory are read-only, so the GitRepositoryTestCase hits
this problem when shutil.rmtree() is called during tearDown.  Work
around the issue by passing a an onerror handler to shutil.rmtree()
which detects the case of trying to remove a read-only file, changes the
file to be writeable, and tries again to remove it.

Signed-off-by: Daniel Harding <>
test: make tests portable to Windows
Using os.system() to shell out to perform various test setup functions
does not work well on Windows because it uses different shell syntax.
To address this, remove the shell() method from TmpPathTestCase, along
with the shell() and pipe() functions from the test.helper module.  To
facilitate replacing usages of the shell() method, add three static
methods to TmpPathTestCase:

 * touch(): creates one or more empty files if they do not already
 * write_file(): sets the content of file at the specified path
 * append_file(): appends content to the file at the specified path

In addition, add a git() method to GitRepositoryTestCase, which uses
subprocess to invoke git with the specified arguments and returns any
output generated by git.

Re-implement all the uses of the shell() method or the pipe() function
using these helper methods or built-in Python functions.

Signed-off-by: Daniel Harding <>
test.git_test: skip test not supported on Windows
test_it_handles_interrupted_syscalls uses signal.SIGALRM, which is not
supported on Windows, so skip this test case on Windows.

Signed-off-by: Daniel Harding <>

davvid added a commit that referenced this pull request Jul 26, 2014

Merge pull request #332 from living180/test_portability
Make tests portable to Windows

Signed-off-by: David Aguilar <>

@davvid davvid merged commit 0c3e8ab into git-cola:master Jul 26, 2014

@living180 living180 deleted the living180:test_portability branch Jul 28, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment