return r;
}
+static int test_append(const struct test* t) {
+ int r = EXIT_FAILURE;
+
+ // Create a new parser
+ struct pakfire_parser* parser = pakfire_parser_create(t->pakfire, NULL, NULL, 0);
+
+ const char* str1 =
+ "a = 1\n"
+ "a += 2\n";
+
+ // Parse something
+ ASSERT_SUCCESS(pakfire_parser_parse(parser, str1, strlen(str1), NULL));
+
+ ASSERT_STRING_EQUALS(pakfire_parser_get(parser, NULL, "a"), "1 2");
+
+ const char* str2 =
+ "build\n"
+
+ // Append something to a variable that exists outside of this block
+ " a += 3\n"
+
+ // Check if we can inherit a local value correctly
+ " b = %{a}\n"
+
+ // Define a new variable in this block and append something
+ " c = 10\n"
+ " c += 20\n"
+ "end\n";
+
+ ASSERT_SUCCESS(pakfire_parser_parse(parser, str2, strlen(str2), NULL));
+
+ ASSERT_STRING_EQUALS(pakfire_parser_get(parser, "build", "a"), "1 2 3");
+ ASSERT_STRING_EQUALS(pakfire_parser_get(parser, "build", "b"), "1 2 3");
+ ASSERT_STRING_EQUALS(pakfire_parser_get(parser, "build", "c"), "10 20");
+
+ // Dump the parser
+ char* s = pakfire_parser_dump(parser);
+ printf("%s\n", s);
+
+ // Everything passed
+ r = EXIT_SUCCESS;
+
+FAIL:
+ if (parser)
+ pakfire_parser_unref(parser);
+
+ return r;
+}
#if 0
static int test_parser_command(const struct test* t) {
const char* command = "%(echo \"ABC\")";
int main(int argc, const char* argv[]) {
testsuite_add_test(test_parser);
testsuite_add_test(test_parser_files);
+ testsuite_add_test(test_append);
#if 0
testsuite_add_test(test_parser_command);
#endif