summaryrefslogtreecommitdiff
path: root/tests/attr/file.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2019-05-19 16:34:44 +0200
committerEdward Thomson <ethomson@edwardthomson.com>2019-05-24 16:16:43 +0200
commit4bcebe2c92d52739e2ea7a92abb26df32ffc2423 (patch)
tree00ae4ea8f1c9baf39b0c2fd2ea48fdb14b16acf3 /tests/attr/file.c
parent63adcc4e3436abb163426ee431a6f77c29415b10 (diff)
downloadlibgit2-4bcebe2c92d52739e2ea7a92abb26df32ffc2423.tar.gz
attr: ensure regular attr files can have whitespaceethomson/ignore_spaces
Unlike ignore files, gitattribute files can have flexible whitespace at the beginning of the line. Ensure that by adding new ignore rules that we have not impeded correct parsing of attribute files.
Diffstat (limited to 'tests/attr/file.c')
-rw-r--r--tests/attr/file.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/tests/attr/file.c b/tests/attr/file.c
index 1f4108c3c..ec67c279a 100644
--- a/tests/attr/file.c
+++ b/tests/attr/file.c
@@ -181,16 +181,11 @@ void test_attr_file__assign_variants(void)
git_attr_file__free(file);
}
-void test_attr_file__check_attr_examples(void)
+static void assert_examples(git_attr_file *file)
{
- git_attr_file *file;
git_attr_rule *rule;
git_attr_assignment *assign;
- cl_git_pass(git_attr_file__load_standalone(&file, cl_fixture("attr/attr3")));
- cl_assert_equal_s(cl_fixture("attr/attr3"), file->entry->path);
- cl_assert(file->rules.length == 3);
-
rule = get_rule(0);
cl_assert_equal_s("*.java", rule->match.pattern);
cl_assert(rule->assigns.length == 3);
@@ -219,6 +214,30 @@ void test_attr_file__check_attr_examples(void)
assign = get_assign(rule, 0);
cl_assert_equal_s("caveat", assign->name);
cl_assert_equal_s("unspecified", assign->value);
+}
+
+void test_attr_file__check_attr_examples(void)
+{
+ git_attr_file *file;
+
+ cl_git_pass(git_attr_file__load_standalone(&file, cl_fixture("attr/attr3")));
+ cl_assert_equal_s(cl_fixture("attr/attr3"), file->entry->path);
+ cl_assert(file->rules.length == 3);
+
+ assert_examples(file);
+
+ git_attr_file__free(file);
+}
+
+void test_attr_file__whitespace(void)
+{
+ git_attr_file *file;
+
+ cl_git_pass(git_attr_file__load_standalone(&file, cl_fixture("attr/attr4")));
+ cl_assert_equal_s(cl_fixture("attr/attr4"), file->entry->path);
+ cl_assert(file->rules.length == 3);
+
+ assert_examples(file);
git_attr_file__free(file);
}