summaryrefslogtreecommitdiff
path: root/tests-clar
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2012-08-21 14:32:09 -0700
committerVicent Martí <vicent@github.com>2012-08-21 14:32:09 -0700
commit697665c0c13e45a5d24af85c133ffaa0a0e0f8cc (patch)
tree9e32cfadd2e1ffaa05f72dd5871551180ee0afb9 /tests-clar
parentb2be351aaddc6ba0b3a0f2cf4e09536a3b27e598 (diff)
parent9d7ac675d06dab2e000ad32f9248631af0191f85 (diff)
downloadlibgit2-697665c0c13e45a5d24af85c133ffaa0a0e0f8cc.tar.gz
Merge pull request #889 from nulltoken/filemode-enum
Filemode enum
Diffstat (limited to 'tests-clar')
-rw-r--r--tests-clar/index/filemodes.c40
-rw-r--r--tests-clar/object/tree/attributes.c31
-rw-r--r--tests-clar/object/tree/write.c53
3 files changed, 64 insertions, 60 deletions
diff --git a/tests-clar/index/filemodes.c b/tests-clar/index/filemodes.c
index 8bd35ddab..75c94e8e7 100644
--- a/tests-clar/index/filemodes.c
+++ b/tests-clar/index/filemodes.c
@@ -100,40 +100,40 @@ void test_index_filemodes__untrusted(void)
/* 1 - add 0644 over existing 0644 -> expect 0644 */
replace_file_with_mode("exec_off", "filemodes/exec_off.0", 0644);
- add_and_check_mode(index, "exec_off", 0100644);
+ add_and_check_mode(index, "exec_off", GIT_FILEMODE_BLOB);
/* 2 - add 0644 over existing 0755 -> expect 0755 */
replace_file_with_mode("exec_on", "filemodes/exec_on.0", 0644);
- add_and_check_mode(index, "exec_on", 0100755);
+ add_and_check_mode(index, "exec_on", GIT_FILEMODE_BLOB_EXECUTABLE);
/* 3 - add 0755 over existing 0644 -> expect 0644 */
replace_file_with_mode("exec_off", "filemodes/exec_off.1", 0755);
- add_and_check_mode(index, "exec_off", 0100644);
+ add_and_check_mode(index, "exec_off", GIT_FILEMODE_BLOB);
/* 4 - add 0755 over existing 0755 -> expect 0755 */
replace_file_with_mode("exec_on", "filemodes/exec_on.1", 0755);
- add_and_check_mode(index, "exec_on", 0100755);
+ add_and_check_mode(index, "exec_on", GIT_FILEMODE_BLOB_EXECUTABLE);
/* 5 - append 0644 over existing 0644 -> expect 0644 */
replace_file_with_mode("exec_off", "filemodes/exec_off.2", 0644);
- append_and_check_mode(index, "exec_off", 0100644);
+ append_and_check_mode(index, "exec_off", GIT_FILEMODE_BLOB);
/* 6 - append 0644 over existing 0755 -> expect 0755 */
replace_file_with_mode("exec_on", "filemodes/exec_on.2", 0644);
- append_and_check_mode(index, "exec_on", 0100755);
+ append_and_check_mode(index, "exec_on", GIT_FILEMODE_BLOB_EXECUTABLE);
/* 7 - append 0755 over existing 0644 -> expect 0644 */
replace_file_with_mode("exec_off", "filemodes/exec_off.3", 0755);
- append_and_check_mode(index, "exec_off", 0100644);
+ append_and_check_mode(index, "exec_off", GIT_FILEMODE_BLOB);
/* 8 - append 0755 over existing 0755 -> expect 0755 */
replace_file_with_mode("exec_on", "filemodes/exec_on.3", 0755);
- append_and_check_mode(index, "exec_on", 0100755);
+ append_and_check_mode(index, "exec_on", GIT_FILEMODE_BLOB_EXECUTABLE);
/* 9 - add new 0644 -> expect 0644 */
cl_git_write2file("filemodes/new_off", "blah",
O_WRONLY | O_CREAT | O_TRUNC, 0644);
- add_and_check_mode(index, "new_off", 0100644);
+ add_and_check_mode(index, "new_off", GIT_FILEMODE_BLOB);
/* this test won't give predictable results on a platform
* that doesn't support filemodes correctly, so skip it.
@@ -142,7 +142,7 @@ void test_index_filemodes__untrusted(void)
/* 10 - add 0755 -> expect 0755 */
cl_git_write2file("filemodes/new_on", "blah",
O_WRONLY | O_CREAT | O_TRUNC, 0755);
- add_and_check_mode(index, "new_on", 0100755);
+ add_and_check_mode(index, "new_on", GIT_FILEMODE_BLOB_EXECUTABLE);
}
git_index_free(index);
@@ -168,45 +168,45 @@ void test_index_filemodes__trusted(void)
/* 1 - add 0644 over existing 0644 -> expect 0644 */
replace_file_with_mode("exec_off", "filemodes/exec_off.0", 0644);
- add_and_check_mode(index, "exec_off", 0100644);
+ add_and_check_mode(index, "exec_off", GIT_FILEMODE_BLOB);
/* 2 - add 0644 over existing 0755 -> expect 0644 */
replace_file_with_mode("exec_on", "filemodes/exec_on.0", 0644);
- add_and_check_mode(index, "exec_on", 0100644);
+ add_and_check_mode(index, "exec_on", GIT_FILEMODE_BLOB);
/* 3 - add 0755 over existing 0644 -> expect 0755 */
replace_file_with_mode("exec_off", "filemodes/exec_off.1", 0755);
- add_and_check_mode(index, "exec_off", 0100755);
+ add_and_check_mode(index, "exec_off", GIT_FILEMODE_BLOB_EXECUTABLE);
/* 4 - add 0755 over existing 0755 -> expect 0755 */
replace_file_with_mode("exec_on", "filemodes/exec_on.1", 0755);
- add_and_check_mode(index, "exec_on", 0100755);
+ add_and_check_mode(index, "exec_on", GIT_FILEMODE_BLOB_EXECUTABLE);
/* 5 - append 0644 over existing 0644 -> expect 0644 */
replace_file_with_mode("exec_off", "filemodes/exec_off.2", 0644);
- append_and_check_mode(index, "exec_off", 0100644);
+ append_and_check_mode(index, "exec_off", GIT_FILEMODE_BLOB);
/* 6 - append 0644 over existing 0755 -> expect 0644 */
replace_file_with_mode("exec_on", "filemodes/exec_on.2", 0644);
- append_and_check_mode(index, "exec_on", 0100644);
+ append_and_check_mode(index, "exec_on", GIT_FILEMODE_BLOB);
/* 7 - append 0755 over existing 0644 -> expect 0755 */
replace_file_with_mode("exec_off", "filemodes/exec_off.3", 0755);
- append_and_check_mode(index, "exec_off", 0100755);
+ append_and_check_mode(index, "exec_off", GIT_FILEMODE_BLOB_EXECUTABLE);
/* 8 - append 0755 over existing 0755 -> expect 0755 */
replace_file_with_mode("exec_on", "filemodes/exec_on.3", 0755);
- append_and_check_mode(index, "exec_on", 0100755);
+ append_and_check_mode(index, "exec_on", GIT_FILEMODE_BLOB_EXECUTABLE);
/* 9 - add new 0644 -> expect 0644 */
cl_git_write2file("filemodes/new_off", "blah",
O_WRONLY | O_CREAT | O_TRUNC, 0644);
- add_and_check_mode(index, "new_off", 0100644);
+ add_and_check_mode(index, "new_off", GIT_FILEMODE_BLOB);
/* 10 - add 0755 -> expect 0755 */
cl_git_write2file("filemodes/new_on", "blah",
O_WRONLY | O_CREAT | O_TRUNC, 0755);
- add_and_check_mode(index, "new_on", 0100755);
+ add_and_check_mode(index, "new_on", GIT_FILEMODE_BLOB_EXECUTABLE);
git_index_free(index);
}
diff --git a/tests-clar/object/tree/attributes.c b/tests-clar/object/tree/attributes.c
index ed88e7486..054f67137 100644
--- a/tests-clar/object/tree/attributes.c
+++ b/tests-clar/object/tree/attributes.c
@@ -4,9 +4,6 @@
static const char *blob_oid = "3d0970ec547fc41ef8a5882dde99c6adce65b021";
static const char *tree_oid = "1b05fdaa881ee45b48cbaa5e9b037d667a47745e";
-#define GROUP_WRITABLE_FILE 0100664
-#define REGULAR_FILE 0100644
-
void test_object_tree_attributes__ensure_correctness_of_attributes_on_insertion(void)
{
git_treebuilder *builder;
@@ -16,9 +13,9 @@ void test_object_tree_attributes__ensure_correctness_of_attributes_on_insertion(
cl_git_pass(git_treebuilder_create(&builder, NULL));
- cl_git_fail(git_treebuilder_insert(NULL, builder, "one.txt", &oid, 0777777));
- cl_git_fail(git_treebuilder_insert(NULL, builder, "one.txt", &oid, 0100666));
- cl_git_fail(git_treebuilder_insert(NULL, builder, "one.txt", &oid, 0000001));
+ cl_git_fail(git_treebuilder_insert(NULL, builder, "one.txt", &oid, (git_filemode_t)0777777));
+ cl_git_fail(git_treebuilder_insert(NULL, builder, "one.txt", &oid, (git_filemode_t)0100666));
+ cl_git_fail(git_treebuilder_insert(NULL, builder, "one.txt", &oid, (git_filemode_t)0000001));
git_treebuilder_free(builder);
}
@@ -37,8 +34,8 @@ void test_object_tree_attributes__group_writable_tree_entries_created_with_an_an
entry = git_tree_entry_byname(tree, "old_mode.txt");
cl_assert_equal_i(
- GROUP_WRITABLE_FILE,
- git_tree_entry_attributes(entry));
+ GIT_FILEMODE_BLOB_GROUP_WRITABLE,
+ git_tree_entry_filemode(entry));
git_tree_free(tree);
git_repository_free(repo);
@@ -63,11 +60,11 @@ void test_object_tree_attributes__normalize_attributes_when_inserting_in_a_new_t
builder,
"normalized.txt",
&bid,
- GROUP_WRITABLE_FILE));
+ GIT_FILEMODE_BLOB_GROUP_WRITABLE));
cl_assert_equal_i(
- REGULAR_FILE,
- git_tree_entry_attributes(entry));
+ GIT_FILEMODE_BLOB,
+ git_tree_entry_filemode(entry));
cl_git_pass(git_treebuilder_write(&tid, repo, builder));
git_treebuilder_free(builder);
@@ -76,8 +73,8 @@ void test_object_tree_attributes__normalize_attributes_when_inserting_in_a_new_t
entry = git_tree_entry_byname(tree, "normalized.txt");
cl_assert_equal_i(
- REGULAR_FILE,
- git_tree_entry_attributes(entry));
+ GIT_FILEMODE_BLOB,
+ git_tree_entry_filemode(entry));
git_tree_free(tree);
cl_git_sandbox_cleanup();
@@ -100,8 +97,8 @@ void test_object_tree_attributes__normalize_attributes_when_creating_a_tree_from
entry = git_treebuilder_get(builder, "old_mode.txt");
cl_assert_equal_i(
- REGULAR_FILE,
- git_tree_entry_attributes(entry));
+ GIT_FILEMODE_BLOB,
+ git_tree_entry_filemode(entry));
cl_git_pass(git_treebuilder_write(&tid2, repo, builder));
git_treebuilder_free(builder);
@@ -110,8 +107,8 @@ void test_object_tree_attributes__normalize_attributes_when_creating_a_tree_from
cl_git_pass(git_tree_lookup(&tree, repo, &tid2));
entry = git_tree_entry_byname(tree, "old_mode.txt");
cl_assert_equal_i(
- REGULAR_FILE,
- git_tree_entry_attributes(entry));
+ GIT_FILEMODE_BLOB,
+ git_tree_entry_filemode(entry));
git_tree_free(tree);
cl_git_sandbox_cleanup();
diff --git a/tests-clar/object/tree/write.c b/tests-clar/object/tree/write.c
index 8b0f3417f..657bed289 100644
--- a/tests-clar/object/tree/write.c
+++ b/tests-clar/object/tree/write.c
@@ -35,11 +35,16 @@ void test_object_tree_write__from_memory(void)
cl_git_pass(git_tree_lookup(&tree, g_repo, &id));
cl_git_pass(git_treebuilder_create(&builder, tree));
- cl_git_fail(git_treebuilder_insert(NULL, builder, "", &bid, 0100644));
- cl_git_fail(git_treebuilder_insert(NULL, builder, "/", &bid, 0100644));
- cl_git_fail(git_treebuilder_insert(NULL, builder, "folder/new.txt", &bid, 0100644));
+ cl_git_fail(git_treebuilder_insert(NULL, builder, "",
+ &bid, GIT_FILEMODE_BLOB));
+ cl_git_fail(git_treebuilder_insert(NULL, builder, "/",
+ &bid, GIT_FILEMODE_BLOB));
+ cl_git_fail(git_treebuilder_insert(NULL, builder, "folder/new.txt",
+ &bid, GIT_FILEMODE_BLOB));
+
+ cl_git_pass(git_treebuilder_insert(
+ NULL, builder, "new.txt", &bid, GIT_FILEMODE_BLOB));
- cl_git_pass(git_treebuilder_insert(NULL,builder,"new.txt",&bid,0100644));
cl_git_pass(git_treebuilder_write(&rid, g_repo, builder));
cl_assert(git_oid_cmp(&rid, &id2) == 0);
@@ -63,14 +68,16 @@ void test_object_tree_write__subtree(void)
//create subtree
cl_git_pass(git_treebuilder_create(&builder, NULL));
- cl_git_pass(git_treebuilder_insert(NULL,builder,"new.txt",&bid,0100644)); //-V536
+ cl_git_pass(git_treebuilder_insert(
+ NULL, builder, "new.txt", &bid, GIT_FILEMODE_BLOB)); //-V536
cl_git_pass(git_treebuilder_write(&subtree_id, g_repo, builder));
git_treebuilder_free(builder);
// create parent tree
cl_git_pass(git_tree_lookup(&tree, g_repo, &id));
cl_git_pass(git_treebuilder_create(&builder, tree));
- cl_git_pass(git_treebuilder_insert(NULL,builder,"new",&subtree_id,040000)); //-V536
+ cl_git_pass(git_treebuilder_insert(
+ NULL, builder, "new", &subtree_id, GIT_FILEMODE_TREE)); //-V536
cl_git_pass(git_treebuilder_write(&id_hiearar, g_repo, builder));
git_treebuilder_free(builder);
git_tree_free(tree);
@@ -96,23 +103,23 @@ void test_object_tree_write__sorted_subtrees(void)
unsigned int attr;
const char *filename;
} entries[] = {
- { 0100644, ".gitattributes" },
- { 0100644, ".gitignore" },
- { 0100644, ".htaccess" },
- { 0100644, "Capfile" },
- { 0100644, "Makefile"},
- { 0100644, "README"},
- { 0040000, "app"},
- { 0040000, "cake"},
- { 0040000, "config"},
- { 0100644, "c"},
- { 0100644, "git_test.txt"},
- { 0100644, "htaccess.htaccess"},
- { 0100644, "index.php"},
- { 0040000, "plugins"},
- { 0040000, "schemas"},
- { 0040000, "ssl-certs"},
- { 0040000, "vendors"}
+ { GIT_FILEMODE_BLOB, ".gitattributes" },
+ { GIT_FILEMODE_BLOB, ".gitignore" },
+ { GIT_FILEMODE_BLOB, ".htaccess" },
+ { GIT_FILEMODE_BLOB, "Capfile" },
+ { GIT_FILEMODE_BLOB, "Makefile"},
+ { GIT_FILEMODE_BLOB, "README"},
+ { GIT_FILEMODE_TREE, "app"},
+ { GIT_FILEMODE_TREE, "cake"},
+ { GIT_FILEMODE_TREE, "config"},
+ { GIT_FILEMODE_BLOB, "c"},
+ { GIT_FILEMODE_BLOB, "git_test.txt"},
+ { GIT_FILEMODE_BLOB, "htaccess.htaccess"},
+ { GIT_FILEMODE_BLOB, "index.php"},
+ { GIT_FILEMODE_TREE, "plugins"},
+ { GIT_FILEMODE_TREE, "schemas"},
+ { GIT_FILEMODE_TREE, "ssl-certs"},
+ { GIT_FILEMODE_TREE, "vendors"}
};
git_oid blank_oid, tree_oid;