Commit eebc5e0d72c86634e6cd6fcc1306c309c02f87af

Edward Thomson 2018-01-03T15:15:16

Merge pull request #4257 from pks-t/pks/stale-test Execute stale tests

diff --git a/.travis.yml b/.travis.yml
index 569a6a7..5d687f1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -17,7 +17,7 @@ env:
   - secure: "YnhS+8n6B+uoyaYfaJ3Lei7cSJqHDPiKJCKFIF2c87YDfmCvAJke8QtE7IzjYDs7UFkTCM4ox+ph2bERUrxZbSCyEkHdjIZpKuMJfYWja/jgMqTMxdyOH9y8JLFbZsSXDIXDwqBlC6vVyl1fP90M35wuWcNTs6tctfVWVofEFbs="
   - GITTEST_INVASIVE_FS_SIZE=1
  matrix:
-  - OPTIONS="-DTHREADSAFE=ON -DCMAKE_BUILD_TYPE=Release -DENABLE_WERROR=ON"
+  - OPTIONS="-DTHREADSAFE=ON -DENABLE_TRACE=ON -DCMAKE_BUILD_TYPE=Release -DENABLE_WERROR=ON"
   - OPTIONS="-DTHREADSAFE=OFF -DBUILD_EXAMPLES=ON -DENABLE_WERROR=ON"
 
 dist: trusty
diff --git a/appveyor.yml b/appveyor.yml
index e0c7b9b..9b14a9c 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -48,13 +48,8 @@ test_script:
     # Run this early so we know it's ready by the time we need it
     $proxyJob = Start-Job { java -jar $Env:APPVEYOR_BUILD_FOLDER\build\poxyproxy.jar -d --port 8080 --credentials foo:bar }
     ctest -V -R libgit2_clar
-    $env:GITTEST_REMOTE_URL="https://github.com/libgit2/non-existent"
-    $env:GITTEST_REMOTE_USER="libgit2test"
-    ctest -V -R libgit2_clar-cred_callback
     Receive-Job -Job $proxyJob
-    $env:GITTEST_REMOTE_PROXY_URL = "http://foo:bar@localhost:8080"
-    ctest -V -R libgit2_clar-proxy_credentials_in_url
-    $env:GITTEST_REMOTE_PROXY_URL = "http://localhost:8080"
+    $env:GITTEST_REMOTE_PROXY_URL = "localhost:8080"
     $env:GITTEST_REMOTE_PROXY_USER = "foo"
     $env:GITTEST_REMOTE_PROXY_PASS = "bar"
-    ctest -V -R libgit2_clar-proxy_credentials_request
+    ctest -V -R libgit2_clar-proxy_credentials
diff --git a/script/cibuild.sh b/script/cibuild.sh
index 1c28baa..5d70e75 100755
--- a/script/cibuild.sh
+++ b/script/cibuild.sh
@@ -85,32 +85,18 @@ else
     export GITTEST_REMOTE_SSH_FINGERPRINT=$(ssh-keygen -F '[localhost]:2222' -l | tail -n 1 | cut -d ' ' -f 2 | tr -d ':')
 fi
 
+# Use the SSH server
 export GITTEST_REMOTE_URL="ssh://localhost:2222/$HOME/_temp/test.git"
 export GITTEST_REMOTE_USER=$USER
 export GITTEST_REMOTE_SSH_KEY="$HOME/.ssh/id_rsa"
 export GITTEST_REMOTE_SSH_PUBKEY="$HOME/.ssh/id_rsa.pub"
 export GITTEST_REMOTE_SSH_PASSPHRASE=""
+ctest -V -R libgit2_clar-ssh || exit $?
 
-
-if [ -e ./libgit2_clar ]; then
-    ./libgit2_clar -sonline::push -sonline::clone::ssh_cert &&
-    ./libgit2_clar -sonline::clone::ssh_with_paths || exit $?
-    if [ "$TRAVIS_OS_NAME" = "linux" ]; then
-        ./libgit2_clar -sonline::clone::cred_callback || exit $?
-    fi
-
-    # Use the proxy we started at the beginning
-    export GITTEST_REMOTE_PROXY_URL="http://foo:bar@localhost:8080/"
-    ./libgit2_clar -sonline::clone::proxy_credentials_in_url || exit $?
-    export GITTEST_REMOTE_PROXY_URL="http://localhost:8080/"
-    export GITTEST_REMOTE_PROXY_USER="foo"
-    export GITTEST_REMOTE_PROXY_PASS="bar"
-    ./libgit2_clar -sonline::clone::proxy_credentials_request || exit $?
-
-fi
+# Use the proxy we started at the beginning
+export GITTEST_REMOTE_PROXY_URL="localhost:8080"
+export GITTEST_REMOTE_PROXY_USER="foo"
+export GITTEST_REMOTE_PROXY_PASS="bar"
+ctest -V -R libgit2_clar-proxy_credentials || exit $?
 
 kill $(cat "$HOME/sshd/pid")
-
-export GITTEST_REMOTE_URL="https://github.com/libgit2/non-existent"
-export GITTEST_REMOTE_USER="libgit2test"
-ctest -V -R libgit2_clar-cred_callback
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 08ecb39..775f33f 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -20,7 +20,7 @@ ENDIF()
 
 ADD_CUSTOM_COMMAND(
 	OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clar.suite
-	COMMAND ${PYTHON_EXECUTABLE} generate.py -o "${CMAKE_CURRENT_BINARY_DIR}" -f -xonline -xstress .
+	COMMAND ${PYTHON_EXECUTABLE} generate.py -o "${CMAKE_CURRENT_BINARY_DIR}" -f -xonline -xstress -xperf .
 	DEPENDS ${SRC_TEST}
 	WORKING_DIRECTORY ${CLAR_PATH}
 )
@@ -58,8 +58,6 @@ ELSE ()
 	ADD_TEST(libgit2_clar "${libgit2_BINARY_DIR}/libgit2_clar" -v -xclone::local::git_style_unc_paths -xclone::local::standard_unc_paths_are_written_git_style)
 ENDIF ()
 
-# Add a test target which runs the cred callback tests, to be
-# called after setting the url and user
-ADD_TEST(libgit2_clar-cred_callback "${libgit2_BINARY_DIR}/libgit2_clar" -v -sonline::clone::cred_callback)
-ADD_TEST(libgit2_clar-proxy_credentials_in_url "${libgit2_BINARY_DIR}/libgit2_clar" -v -sonline::clone::proxy_credentials_in_url)
-ADD_TEST(libgit2_clar-proxy_credentials_request "${libgit2_BINARY_DIR}/libgit2_clar" -v	-sonline::clone::proxy_credentials_request)
+# Add additional test targets that require special setup
+ADD_TEST(libgit2_clar-proxy_credentials "${libgit2_BINARY_DIR}/libgit2_clar" -v -sonline::clone::proxy_credentials_in_url -sonline::clone::proxy_credentials_request)
+ADD_TEST(libgit2_clar-ssh "${libgit2_BINARY_DIR}/libgit2_clar" -v -sonline::push -sonline::clone::ssh_cert -sonline::clone::ssh_with_paths)
diff --git a/tests/checkout/tree.c b/tests/checkout/tree.c
index 56513ea..a7e29b3 100644
--- a/tests/checkout/tree.c
+++ b/tests/checkout/tree.c
@@ -1096,6 +1096,8 @@ void test_checkout_tree__filemode_preserved_in_workdir(void)
 	cl_assert(!GIT_PERMS_IS_EXEC(read_filemode("a/b.txt")));
 
 	git_commit_free(commit);
+#else
+	cl_skip();
 #endif
 }
 
diff --git a/tests/iterator/iterator_helpers.c b/tests/iterator/iterator_helpers.c
index ae48fcd..68d5741 100644
--- a/tests/iterator/iterator_helpers.c
+++ b/tests/iterator/iterator_helpers.c
@@ -51,8 +51,7 @@ void expect_iterator_items(
 				cl_assert(entry->mode != GIT_FILEMODE_TREE);
 		}
 
-		if (++count >= expected_flat)
-			break;
+		cl_assert(++count <= expected_flat);
 	}
 
 	assert_at_end(i, v);
diff --git a/tests/iterator/workdir.c b/tests/iterator/workdir.c
index f33fd98..198edc7 100644
--- a/tests/iterator/workdir.c
+++ b/tests/iterator/workdir.c
@@ -662,7 +662,7 @@ void test_iterator_workdir__filesystem_gunk(void)
 	/* should only have 13 items, since we're not asking for trees to be
 	 * returned.  the goal of this test is simply to not crash.
 	 */
-	expect_iterator_items(i, 13, NULL, 13, NULL);
+	expect_iterator_items(i, 15, NULL, 15, NULL);
 	git_iterator_free(i);
 	git_buf_free(&parent);
 }
@@ -741,6 +741,8 @@ void test_iterator_workdir__skips_fifos_and_special_files(void)
 	cl_assert_equal_i(GIT_ITEROVER, git_iterator_advance(&e, i));
 
 	git_iterator_free(i);
+#else
+	cl_skip();
 #endif
 }
 
diff --git a/tests/online/clone.c b/tests/online/clone.c
index 5eda73f..b9230ec 100644
--- a/tests/online/clone.c
+++ b/tests/online/clone.c
@@ -263,8 +263,8 @@ static int cred_failure_cb(
 
 void test_online_clone__cred_callback_failure_return_code_is_tunnelled(void)
 {
-	if (!_remote_url || !_remote_user)
-		clar__skip();
+	_remote_url = git__strdup("https://github.com/libgit2/non-existent");
+	_remote_user = git__strdup("libgit2test");
 
 	g_options.fetch_opts.callbacks.credentials = cred_failure_cb;
 
@@ -293,8 +293,8 @@ void test_online_clone__cred_callback_called_again_on_auth_failure(void)
 {
 	size_t counter = 0;
 
-	if (!_remote_url || !_remote_user)
-		clar__skip();
+	_remote_url = git__strdup("https://github.com/libgit2/non-existent");
+	_remote_user = git__strdup("libgit2test");
 
 	g_options.fetch_opts.callbacks.credentials = cred_count_calls_cb;
 	g_options.fetch_opts.callbacks.payload = &counter;
@@ -677,24 +677,34 @@ static int proxy_creds(git_cred **out, const char *url, const char *username, un
 
 void test_online_clone__proxy_credentials_request(void)
 {
+	git_buf url = GIT_BUF_INIT;
+
 	if (!_remote_proxy_url || !_remote_proxy_user || !_remote_proxy_pass)
 		cl_skip();
 
+	cl_git_pass(git_buf_printf(&url, "http://%s/", _remote_proxy_url));
+
 	g_options.fetch_opts.proxy_opts.type = GIT_PROXY_SPECIFIED;
-	g_options.fetch_opts.proxy_opts.url = _remote_proxy_url;
+	g_options.fetch_opts.proxy_opts.url = url.ptr;
 	g_options.fetch_opts.proxy_opts.credentials = proxy_creds;
 	called_proxy_creds = 0;
 	cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
 	cl_assert(called_proxy_creds);
+
+	git_buf_free(&url);
 }
 
 void test_online_clone__proxy_credentials_in_url(void)
 {
-	if (!_remote_proxy_url)
+	git_buf url = GIT_BUF_INIT;
+
+	if (!_remote_proxy_url || !_remote_proxy_user || !_remote_proxy_pass)
 		cl_skip();
 
+	cl_git_pass(git_buf_printf(&url, "http://%s:%s@%s/", _remote_proxy_user, _remote_proxy_pass, _remote_proxy_url));
+
 	g_options.fetch_opts.proxy_opts.type = GIT_PROXY_SPECIFIED;
-	g_options.fetch_opts.proxy_opts.url = _remote_proxy_url;
+	g_options.fetch_opts.proxy_opts.url = url.ptr;
 	called_proxy_creds = 0;
 	cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
 	cl_assert(called_proxy_creds == 0);
diff --git a/tests/perf/merge.c b/tests/perf/merge.c
index b2ef082..721902d 100644
--- a/tests/perf/merge.c
+++ b/tests/perf/merge.c
@@ -25,20 +25,7 @@
 #define ID_BRANCH_A "d853fb9f24e0fe63b3dce9fbc04fd9cfe17a030b"
 #define ID_BRANCH_B "1ce9ea3ba9b4fa666602d52a5281d41a482cc58b"
 
-
-void test_perf_merge__initialize(void)
-{
-}
-
-void test_perf_merge__cleanup(void)
-{
-}
-
 void test_perf_merge__m1(void)
 {
-#if 1
-	cl_skip();
-#else
 	perf__do_merge(SRC_REPO, "m1", ID_BRANCH_A, ID_BRANCH_B);
-#endif
 }
diff --git a/tests/repo/open.c b/tests/repo/open.c
index 3239b6f..ab36dd5 100644
--- a/tests/repo/open.c
+++ b/tests/repo/open.c
@@ -180,6 +180,8 @@ void test_repo_open__from_git_new_workdir(void)
 	cl_assert_(git__suffixcmp(git_repository_workdir(repo2), "alternate/") == 0, git_repository_workdir(repo2));
 
 	git_repository_free(repo2);
+#else
+	cl_skip();
 #endif
 }
 
diff --git a/tests/status/worktree.c b/tests/status/worktree.c
index 44ed324..c6b18c1 100644
--- a/tests/status/worktree.c
+++ b/tests/status/worktree.c
@@ -1072,6 +1072,8 @@ void test_status_worktree__unreadable(void)
 	cl_assert_equal_i(counts.expected_entry_count, counts.entry_count);
 	cl_assert_equal_i(0, counts.wrong_status_flags_count);
 	cl_assert_equal_i(0, counts.wrong_sorted_path);
+#else
+	cl_skip();
 #endif
 }
 
@@ -1106,6 +1108,8 @@ void test_status_worktree__unreadable_not_included(void)
 	cl_assert_equal_i(counts.expected_entry_count, counts.entry_count);
 	cl_assert_equal_i(0, counts.wrong_status_flags_count);
 	cl_assert_equal_i(0, counts.wrong_sorted_path);
+#else
+	cl_skip();
 #endif
 }