diff options
Diffstat (limited to 'tests/blogc-make/check_exec.c')
-rw-r--r-- | tests/blogc-make/check_exec.c | 54 |
1 files changed, 48 insertions, 6 deletions
diff --git a/tests/blogc-make/check_exec.c b/tests/blogc-make/check_exec.c index 506c5f6..081aa25 100644 --- a/tests/blogc-make/check_exec.c +++ b/tests/blogc-make/check_exec.c @@ -81,20 +81,20 @@ test_build_blogc_cmd_with_settings(void **state) bc_trie_insert(variables, "LOL", bc_strdup("HEHE")); char *rv = bm_exec_build_blogc_cmd("blogc", settings, variables, true, - "main.tmpl", "foo.html", true); + "main.tmpl", "foo.html", false, true); assert_string_equal(rv, "LC_ALL='en_US.utf8' blogc -D FOO='BAR' -D BAR='BAZ' -D LOL='HEHE' -l " "-t 'main.tmpl' -o 'foo.html' -i"); free(rv); rv = bm_exec_build_blogc_cmd("blogc", settings, variables, false, NULL, NULL, - false); + false, false); assert_string_equal(rv, "LC_ALL='en_US.utf8' blogc -D FOO='BAR' -D BAR='BAZ' -D LOL='HEHE'"); free(rv); rv = bm_exec_build_blogc_cmd("blogc", settings, NULL, false, NULL, NULL, - false); + false, false); assert_string_equal(rv, "LC_ALL='en_US.utf8' blogc -D FOO='BAR' -D BAR='BAZ'"); free(rv); @@ -106,6 +106,46 @@ test_build_blogc_cmd_with_settings(void **state) } +static void +test_build_blogc_cmd_with_settings_and_production(void **state) +{ + bm_settings_t *settings = bc_malloc(sizeof(bm_settings_t)); + settings->settings = bc_trie_new(free); + bc_trie_insert(settings->settings, "locale", bc_strdup("en_US.utf8")); + settings->global = bc_trie_new(free); + bc_trie_insert(settings->global, "FOO", bc_strdup("BAR")); + bc_trie_insert(settings->global, "BAR", bc_strdup("BAZ")); + bc_trie_t *variables = bc_trie_new(free); + bc_trie_insert(variables, "LOL", bc_strdup("HEHE")); + + char *rv = bm_exec_build_blogc_cmd("blogc", settings, variables, true, + "main.tmpl", "foo.html", true, true); + assert_string_equal(rv, + "LC_ALL='en_US.utf8' blogc -D FOO='BAR' -D BAR='BAZ' -D LOL='HEHE' " + "-D MAKE_ENV_PRODUCTION=1 -D MAKE_ENV='production' -l -t 'main.tmpl' " + "-o 'foo.html' -i"); + free(rv); + + rv = bm_exec_build_blogc_cmd("blogc", settings, variables, false, NULL, NULL, + true, false); + assert_string_equal(rv, + "LC_ALL='en_US.utf8' blogc -D FOO='BAR' -D BAR='BAZ' -D LOL='HEHE' " + "-D MAKE_ENV_PRODUCTION=1 -D MAKE_ENV='production'"); + free(rv); + + rv = bm_exec_build_blogc_cmd("blogc", settings, NULL, false, NULL, NULL, + true, false); + assert_string_equal(rv, + "LC_ALL='en_US.utf8' blogc -D FOO='BAR' -D BAR='BAZ' " + "-D MAKE_ENV_PRODUCTION=1 -D MAKE_ENV='production'"); + free(rv); + + bc_trie_free(variables); + bc_trie_free(settings->settings); + bc_trie_free(settings->global); + free(settings); +} + static void test_build_blogc_cmd_without_settings(void **state) @@ -114,18 +154,19 @@ test_build_blogc_cmd_without_settings(void **state) bc_trie_insert(variables, "LOL", bc_strdup("HEHE")); char *rv = bm_exec_build_blogc_cmd("blogc", NULL, variables, true, - "main.tmpl", "foo.html", true); + "main.tmpl", "foo.html", false, true); assert_string_equal(rv, "blogc -D LOL='HEHE' -l -t 'main.tmpl' -o 'foo.html' -i"); free(rv); rv = bm_exec_build_blogc_cmd("blogc", NULL, variables, false, NULL, NULL, - false); + false, false); assert_string_equal(rv, "blogc -D LOL='HEHE'"); free(rv); - rv = bm_exec_build_blogc_cmd("blogc", NULL, NULL, false, NULL, NULL, false); + rv = bm_exec_build_blogc_cmd("blogc", NULL, NULL, false, NULL, NULL, + false, false); assert_string_equal(rv, "blogc"); free(rv); @@ -140,6 +181,7 @@ main(void) const UnitTest tests[] = { unit_test(test_find_binary), unit_test(test_build_blogc_cmd_with_settings), + unit_test(test_build_blogc_cmd_with_settings_and_production), unit_test(test_build_blogc_cmd_without_settings), }; return run_tests(tests); |