Move slow tests to "stress" clar module Create a new section of clar tests "stress" that will default to being off where we can put slow tests that push the library for performance testing purposes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c937ba9..53f568e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -361,7 +361,7 @@ IF (BUILD_CLAR)
ADD_CUSTOM_COMMAND(
OUTPUT ${CLAR_PATH}/clar.suite
- COMMAND ${PYTHON_EXECUTABLE} generate.py -f -xonline .
+ COMMAND ${PYTHON_EXECUTABLE} generate.py -f -xonline -xstress .
DEPENDS ${SRC_TEST}
WORKING_DIRECTORY ${CLAR_PATH}
)
diff --git a/tests-clar/diff/rename.c b/tests-clar/diff/rename.c
index 5555501..5a35495 100644
--- a/tests-clar/diff/rename.c
+++ b/tests-clar/diff/rename.c
@@ -1235,150 +1235,3 @@ void test_diff_rename__unmodified_can_be_renamed(void)
git_index_free(index);
git_tree_free(tree);
}
-
-#define ANOTHER_POEM \
-"OH, glorious are the guarded heights\nWhere guardian souls abide—\nSelf-exiled from our gross delights—\nAbove, beyond, outside:\nAn ampler arc their spirit swings—\nCommands a juster view—\nWe have their word for all these things,\nNo doubt their words are true.\n\nYet we, the bond slaves of our day,\nWhom dirt and danger press—\nCo-heirs of insolence, delay,\nAnd leagued unfaithfulness—\nSuch is our need must seek indeed\nAnd, having found, engage\nThe men who merely do the work\nFor which they draw the wage.\n\nFrom forge and farm and mine and bench,\nDeck, altar, outpost lone—\nMill, school, battalion, counter, trench,\nRail, senate, sheepfold, throne—\nCreation's cry goes up on high\nFrom age to cheated age:\n\"Send us the men who do the work\n\"For which they draw the wage!\"\n"
-
-static void test_with_many(size_t expected_new)
-{
- git_index *index;
- git_tree *tree, *new_tree;
- git_diff_list *diff = NULL;
- diff_expects exp;
- git_diff_options diffopts = GIT_DIFF_OPTIONS_INIT;
- git_diff_find_options opts = GIT_DIFF_FIND_OPTIONS_INIT;
-
- cl_git_pass(git_repository_index(&index, g_repo));
- cl_git_pass(
- git_revparse_single((git_object **)&tree, g_repo, "HEAD^{tree}"));
-
- cl_git_pass(p_rename("renames/ikeepsix.txt", "renames/ikeepsix2.txt"));
- cl_git_pass(git_index_remove_bypath(index, "ikeepsix.txt"));
- cl_git_pass(git_index_add_bypath(index, "ikeepsix2.txt"));
- cl_git_pass(git_index_write(index));
-
- cl_git_pass(git_diff_tree_to_index(&diff, g_repo, tree, index, &diffopts));
-
- memset(&exp, 0, sizeof(exp));
- cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, NULL, NULL, &exp));
- cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
- cl_assert_equal_i(expected_new + 1, exp.file_status[GIT_DELTA_ADDED]);
- cl_assert_equal_i(expected_new + 2, exp.files);
-
- opts.flags = GIT_DIFF_FIND_ALL;
- cl_git_pass(git_diff_find_similar(diff, &opts));
-
- memset(&exp, 0, sizeof(exp));
- cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, NULL, NULL, &exp));
- cl_assert_equal_i(1, exp.file_status[GIT_DELTA_RENAMED]);
- cl_assert_equal_i(expected_new, exp.file_status[GIT_DELTA_ADDED]);
- cl_assert_equal_i(expected_new + 1, exp.files);
-
- git_diff_list_free(diff);
-
- {
- git_object *parent;
- git_signature *sig;
- git_oid tree_id, commit_id;
- git_reference *ref;
-
- cl_git_pass(git_index_write_tree(&tree_id, index));
- cl_git_pass(git_tree_lookup(&new_tree, g_repo, &tree_id));
-
- cl_git_pass(git_revparse_ext(&parent, &ref, g_repo, "HEAD"));
- cl_git_pass(git_signature_new(
- &sig, "Sm Test", "sm@tester.test", 1372350000, 480));
-
- cl_git_pass(git_commit_create_v(
- &commit_id, g_repo, git_reference_name(ref), sig, sig,
- NULL, "yoyoyo", new_tree, 1, parent));
-
- git_object_free(parent);
- git_reference_free(ref);
- git_signature_free(sig);
- }
-
- cl_git_pass(git_diff_tree_to_tree(
- &diff, g_repo, tree, new_tree, &diffopts));
-
- memset(&exp, 0, sizeof(exp));
- cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, NULL, NULL, &exp));
- cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
- cl_assert_equal_i(expected_new + 1, exp.file_status[GIT_DELTA_ADDED]);
- cl_assert_equal_i(expected_new + 2, exp.files);
-
- opts.flags = GIT_DIFF_FIND_ALL;
- cl_git_pass(git_diff_find_similar(diff, &opts));
-
- memset(&exp, 0, sizeof(exp));
- cl_git_pass(git_diff_foreach(
- diff, diff_file_cb, NULL, NULL, &exp));
- cl_assert_equal_i(1, exp.file_status[GIT_DELTA_RENAMED]);
- cl_assert_equal_i(expected_new, exp.file_status[GIT_DELTA_ADDED]);
- cl_assert_equal_i(expected_new + 1, exp.files);
-
- git_diff_list_free(diff);
-
- git_tree_free(new_tree);
- git_tree_free(tree);
- git_index_free(index);
-}
-
-void test_diff_rename__many_files(void)
-{
- git_index *index;
- char tmp[64];
- int i, j;
- git_buf b = GIT_BUF_INIT;
-
- cl_git_pass(git_repository_index(&index, g_repo));
-
- for (i = 0; i < 100; i += 1) {
- snprintf(tmp, sizeof(tmp), "renames/newfile%03d", i);
- for (j = i * 256; j > 0; --j)
- git_buf_printf(&b, "more content %d\n", i);
- cl_git_mkfile(tmp, b.ptr);
- }
-
- for (i = 0; i < 100; i += 1) {
- snprintf(tmp, sizeof(tmp), "renames/newfile%03d", i);
- cl_git_pass(git_index_add_bypath(index, tmp + strlen("renames/")));
- }
-
- git_buf_free(&b);
- git_index_free(index);
-
- test_with_many(100);
-}
-
-void test_diff_rename__again_many_files(void)
-{
- git_index *index;
- char tmp[64];
- int i;
- git_buf b = GIT_BUF_INIT;
-
- cl_git_pass(git_repository_index(&index, g_repo));
-
- git_buf_printf(&b, "%08d\n" ANOTHER_POEM "%08d\n" ANOTHER_POEM ANOTHER_POEM, 0, 0);
-
- for (i = 0; i < 2500; i += 1) {
- snprintf(tmp, sizeof(tmp), "renames/newfile%03d", i);
- snprintf(b.ptr, 9, "%08d", i);
- b.ptr[8] = '\n';
- cl_git_mkfile(tmp, b.ptr);
- }
- git_buf_free(&b);
-
- for (i = 0; i < 2500; i += 1) {
- snprintf(tmp, sizeof(tmp), "renames/newfile%03d", i);
- cl_git_pass(git_index_add_bypath(index, tmp + strlen("renames/")));
- }
-
- git_index_free(index);
-
- test_with_many(2500);
-}
diff --git a/tests-clar/stress/diff.c b/tests-clar/stress/diff.c
new file mode 100644
index 0000000..62ccd5e
--- /dev/null
+++ b/tests-clar/stress/diff.c
@@ -0,0 +1,164 @@
+#include "clar_libgit2.h"
+#include "../diff/diff_helpers.h"
+
+static git_repository *g_repo = NULL;
+
+void test_stress_diff__initialize(void)
+{
+}
+
+void test_stress_diff__cleanup(void)
+{
+ cl_git_sandbox_cleanup();
+}
+
+#define ANOTHER_POEM \
+"OH, glorious are the guarded heights\nWhere guardian souls abide—\nSelf-exiled from our gross delights—\nAbove, beyond, outside:\nAn ampler arc their spirit swings—\nCommands a juster view—\nWe have their word for all these things,\nNo doubt their words are true.\n\nYet we, the bond slaves of our day,\nWhom dirt and danger press—\nCo-heirs of insolence, delay,\nAnd leagued unfaithfulness—\nSuch is our need must seek indeed\nAnd, having found, engage\nThe men who merely do the work\nFor which they draw the wage.\n\nFrom forge and farm and mine and bench,\nDeck, altar, outpost lone—\nMill, school, battalion, counter, trench,\nRail, senate, sheepfold, throne—\nCreation's cry goes up on high\nFrom age to cheated age:\n\"Send us the men who do the work\n\"For which they draw the wage!\"\n"
+
+static void test_with_many(size_t expected_new)
+{
+ git_index *index;
+ git_tree *tree, *new_tree;
+ git_diff_list *diff = NULL;
+ diff_expects exp;
+ git_diff_options diffopts = GIT_DIFF_OPTIONS_INIT;
+ git_diff_find_options opts = GIT_DIFF_FIND_OPTIONS_INIT;
+
+ cl_git_pass(git_repository_index(&index, g_repo));
+ cl_git_pass(
+ git_revparse_single((git_object **)&tree, g_repo, "HEAD^{tree}"));
+
+ cl_git_pass(p_rename("renames/ikeepsix.txt", "renames/ikeepsix2.txt"));
+ cl_git_pass(git_index_remove_bypath(index, "ikeepsix.txt"));
+ cl_git_pass(git_index_add_bypath(index, "ikeepsix2.txt"));
+ cl_git_pass(git_index_write(index));
+
+ cl_git_pass(git_diff_tree_to_index(&diff, g_repo, tree, index, &diffopts));
+
+ memset(&exp, 0, sizeof(exp));
+ cl_git_pass(git_diff_foreach(
+ diff, diff_file_cb, NULL, NULL, &exp));
+ cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
+ cl_assert_equal_i(expected_new + 1, exp.file_status[GIT_DELTA_ADDED]);
+ cl_assert_equal_i(expected_new + 2, exp.files);
+
+ opts.flags = GIT_DIFF_FIND_ALL;
+ cl_git_pass(git_diff_find_similar(diff, &opts));
+
+ memset(&exp, 0, sizeof(exp));
+ cl_git_pass(git_diff_foreach(
+ diff, diff_file_cb, NULL, NULL, &exp));
+ cl_assert_equal_i(1, exp.file_status[GIT_DELTA_RENAMED]);
+ cl_assert_equal_i(expected_new, exp.file_status[GIT_DELTA_ADDED]);
+ cl_assert_equal_i(expected_new + 1, exp.files);
+
+ git_diff_list_free(diff);
+
+ {
+ git_object *parent;
+ git_signature *sig;
+ git_oid tree_id, commit_id;
+ git_reference *ref;
+
+ cl_git_pass(git_index_write_tree(&tree_id, index));
+ cl_git_pass(git_tree_lookup(&new_tree, g_repo, &tree_id));
+
+ cl_git_pass(git_revparse_ext(&parent, &ref, g_repo, "HEAD"));
+ cl_git_pass(git_signature_new(
+ &sig, "Sm Test", "sm@tester.test", 1372350000, 480));
+
+ cl_git_pass(git_commit_create_v(
+ &commit_id, g_repo, git_reference_name(ref), sig, sig,
+ NULL, "yoyoyo", new_tree, 1, parent));
+
+ git_object_free(parent);
+ git_reference_free(ref);
+ git_signature_free(sig);
+ }
+
+ cl_git_pass(git_diff_tree_to_tree(
+ &diff, g_repo, tree, new_tree, &diffopts));
+
+ memset(&exp, 0, sizeof(exp));
+ cl_git_pass(git_diff_foreach(
+ diff, diff_file_cb, NULL, NULL, &exp));
+ cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
+ cl_assert_equal_i(expected_new + 1, exp.file_status[GIT_DELTA_ADDED]);
+ cl_assert_equal_i(expected_new + 2, exp.files);
+
+ opts.flags = GIT_DIFF_FIND_ALL;
+ cl_git_pass(git_diff_find_similar(diff, &opts));
+
+ memset(&exp, 0, sizeof(exp));
+ cl_git_pass(git_diff_foreach(
+ diff, diff_file_cb, NULL, NULL, &exp));
+ cl_assert_equal_i(1, exp.file_status[GIT_DELTA_RENAMED]);
+ cl_assert_equal_i(expected_new, exp.file_status[GIT_DELTA_ADDED]);
+ cl_assert_equal_i(expected_new + 1, exp.files);
+
+ git_diff_list_free(diff);
+
+ git_tree_free(new_tree);
+ git_tree_free(tree);
+ git_index_free(index);
+}
+
+void test_stress_diff__rename_big_files(void)
+{
+ git_index *index;
+ char tmp[64];
+ int i, j;
+ git_buf b = GIT_BUF_INIT;
+
+ g_repo = cl_git_sandbox_init("renames");
+
+ cl_git_pass(git_repository_index(&index, g_repo));
+
+ for (i = 0; i < 100; i += 1) {
+ snprintf(tmp, sizeof(tmp), "renames/newfile%03d", i);
+ for (j = i * 256; j > 0; --j)
+ git_buf_printf(&b, "more content %d\n", i);
+ cl_git_mkfile(tmp, b.ptr);
+ }
+
+ for (i = 0; i < 100; i += 1) {
+ snprintf(tmp, sizeof(tmp), "renames/newfile%03d", i);
+ cl_git_pass(git_index_add_bypath(index, tmp + strlen("renames/")));
+ }
+
+ git_buf_free(&b);
+ git_index_free(index);
+
+ test_with_many(100);
+}
+
+void test_stress_diff__rename_many_files(void)
+{
+ git_index *index;
+ char tmp[64];
+ int i;
+ git_buf b = GIT_BUF_INIT;
+
+ g_repo = cl_git_sandbox_init("renames");
+
+ cl_git_pass(git_repository_index(&index, g_repo));
+
+ git_buf_printf(&b, "%08d\n" ANOTHER_POEM "%08d\n" ANOTHER_POEM ANOTHER_POEM, 0, 0);
+
+ for (i = 0; i < 2500; i += 1) {
+ snprintf(tmp, sizeof(tmp), "renames/newfile%03d", i);
+ snprintf(b.ptr, 9, "%08d", i);
+ b.ptr[8] = '\n';
+ cl_git_mkfile(tmp, b.ptr);
+ }
+ git_buf_free(&b);
+
+ for (i = 0; i < 2500; i += 1) {
+ snprintf(tmp, sizeof(tmp), "renames/newfile%03d", i);
+ cl_git_pass(git_index_add_bypath(index, tmp + strlen("renames/")));
+ }
+
+ git_index_free(index);
+
+ test_with_many(2500);
+}