diff options
| author | Ben Straub <bs@github.com> | 2012-08-20 20:24:20 -0700 |
|---|---|---|
| committer | Ben Straub <bs@github.com> | 2012-08-20 20:24:20 -0700 |
| commit | c35881420d063c4393fef430720704f8004481a4 (patch) | |
| tree | 06ce1964a64698473fdf4796ef606a95c576d245 /tests-clar | |
| parent | 5c27da1f4844eef2b4dfbabce526b6c5f2cd310b (diff) | |
| download | libgit2-c35881420d063c4393fef430720704f8004481a4.tar.gz | |
Tests: close file handles before asserting
Avoids getting ERROR_SHARING_VIOLATION on win32
and killing the entire clar run.
Diffstat (limited to 'tests-clar')
| -rw-r--r-- | tests-clar/checkout/checkout.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/tests-clar/checkout/checkout.c b/tests-clar/checkout/checkout.c index 80e30bbc3..35894d427 100644 --- a/tests-clar/checkout/checkout.c +++ b/tests-clar/checkout/checkout.c @@ -24,13 +24,17 @@ static void test_file_contents(const char *path, const char *expectedcontents) { int fd; char buffer[1024] = {0}; + size_t expectedlen, actuallen; fd = p_open(path, O_RDONLY); cl_assert(fd >= 0); - cl_assert_equal_i(p_read(fd, buffer, 1024), strlen(expectedcontents)); - cl_assert_equal_s(expectedcontents, buffer); + expectedlen = strlen(expectedcontents); + actuallen = p_read(fd, buffer, 1024); cl_git_pass(p_close(fd)); + + cl_assert_equal_i(actuallen, expectedlen); + cl_assert_equal_s(buffer, expectedcontents); } @@ -63,9 +67,9 @@ void test_checkout_checkout__crlf(void) #endif cl_git_mkfile("./testrepo/.gitattributes", attributes); cl_git_pass(git_checkout_head(g_repo, NULL, NULL)); - test_file_contents("./testrepo/README", expected_readme_text); - test_file_contents("./testrepo/new.txt", "my new file\n"); - test_file_contents("./testrepo/branch_file.txt", "hi\r\nbye!\r\n"); + test_file_contents("./testrepo/README", expected_readme_text); + test_file_contents("./testrepo/new.txt", "my new file\n"); + test_file_contents("./testrepo/branch_file.txt", "hi\r\nbye!\r\n"); } static void enable_symlinks(bool enable) |
