Diff options
| -rwxr-xr-x | tests/t0201-filters.sh | 28 |
1 file changed, 10 insertions, 18 deletions
diff --git a/tests/t0201-filters.sh b/tests/t0201-filters.sh index feacf31..51eeb52 100755 --- a/tests/t0201-filters.sh +++ b/tests/t0201-filters.sh @@ -56,14 +56,15 @@ test_expect_success 'the blame page goes through the source filter too' ' # A readme read at another branch links into the tree at that branch, which # the filter is told as the query to follow a path with. test_expect_success 'the about filter gets the tree url at the readme branch' ' - cgitrc_repo aboutargsrc filtered readme=:a+b "about-filter=exec:$FILTER_DIRECTORY/dump.sh" "root-readme=$PWD/root.txt" "repo.path=$PWD/repos/filter/.git" && + cgitrc_repo aboutargsrc filtered readme=:a+b "about-filter=exec:$FILTER_DIRECTORY/dump.sh" "repo.path=$PWD/repos/filter/.git" && cgit_rc aboutargsrc "url=filtered/about/&h=1%2b2" >tmp && grep "<div id=.about.>a+b /filtered/tree/ ?h=1%2B2 HELLO" tmp ' test_expect_success 'the site readme leaves the tree url empty' ' echo site >root.txt && - cgit_rc aboutargsrc "p=about" >tmp && + cgitrc_repo siterc foo "about-filter=exec:$FILTER_DIRECTORY/dump.sh" "root-readme=$PWD/root.txt" && + cgit_rc siterc "p=about" >tmp && grep "root.txt SITE" tmp ' @@ -72,7 +73,8 @@ test_expect_success 'only a repository page hands filters its variables' ' cat >/dev/null echo "repo url: $CGIT_REPO_URL." EOF - sed "s|^about-filter=.*|about-filter=exec:$PWD/env.sh|" aboutargsrc >envrc && + echo site >root.txt && + cgitrc_repo envrc filtered readme=:a+b "about-filter=exec:$PWD/env.sh" "root-readme=$PWD/root.txt" "repo.path=$PWD/repos/filter/.git" && cgit_rc envrc "url=filtered/about/" >tmp && grep "repo url: filtered\." tmp && cgit_rc envrc "p=about" >tmp && @@ -100,12 +102,7 @@ test_expect_success CGIT_LUA 'a failing lua filter still renders an error page' function filter_write(str) end function filter_close() return 0 end EOF - { - echo "cache-size=0" && - echo "repo.url=foo" && - echo "repo.path=$PWD/repos/foo/.git" && - echo "auth-filter=lua:$PWD/broken.lua" - } >brokenrc && + cgitrc_repo brokenrc foo "auth-filter=lua:$PWD/broken.lua" && cgit_rc brokenrc "url=foo/commit" >tmp 2>err && grep "Status: 500" tmp && grep "Lua error in" err @@ -118,7 +115,7 @@ test_expect_success CGIT_LUA 'a lua filter raising a table is named by type' ' function filter_write(str) end function filter_close() return 0 end EOF - sed "s|broken.lua|tabled.lua|" brokenrc >tabledrc && + cgitrc_repo tabledrc foo "auth-filter=lua:$PWD/tabled.lua" && cgit_rc tabledrc "url=foo/commit" >tmp 2>err && grep "Status: 500" tmp && grep "Lua error in .*tabled.lua: (error object is a table value)" err @@ -133,12 +130,7 @@ test_expect_success CGIT_LUA 'a lua filter that writes while loading still rende function filter_write(str) html(str) end function filter_close() return 0 end EOF - { - echo "cache-size=0" && - echo "repo.url=foo" && - echo "repo.path=$PWD/repos/foo/.git" && - echo "repo.commit-filter=lua:$PWD/loud.lua" - } >loudrc && + cgitrc_repo loudrc foo "repo.commit-filter=lua:$PWD/loud.lua" && cgit_rc loudrc "url=foo/commit" >tmp && grep "written while loading" tmp && grep "</html>" tmp @@ -165,7 +157,7 @@ test_expect_success CGIT_LUA 'a lua filter can encode an argument and include a end function filter_close() return 0 end EOF - sed "s|loud.lua|apis.lua|" loudrc >apisrc && + cgitrc_repo apisrc foo "repo.commit-filter=lua:$PWD/apis.lua" && cgit_rc apisrc "url=foo/commit" >tmp && grep "a+b%26c|included <b>bold</b>" tmp ' @@ -182,7 +174,7 @@ test_expect_success CGIT_LUA 'a lua filter prints where it runs' ' end function filter_close() return 0 end EOF - sed "s|loud.lua|print.lua|" loudrc >printrc && + cgitrc_repo printrc foo "repo.commit-filter=lua:$PWD/print.lua" && cgit_rc printrc "url=foo/commit" >tmp && tab=$(printf "\t") && grep "<div class=.commit-subject.>printed${tab}1${tab}nil${tab}true$" tmp && |
