#!/bin/sh # Checks about-render.lua, the shipped about-filter. The unit checks drive # the script under every suitable standalone Lua through the harness in # extensions/, once as installed and once with lpeg forced away so the # plain text fallback is proven everywhere. A repository with a markdown # readme is then rendered through cgit itself, where the outcome depends on # whether the Lua inside the binary has lpeg, so a probe decides which of # the two right answers to expect. test_description='Check the shipped about-render extension' CGIT_TEST_NO_CREATE_REPOS=YesPlease . ./setup.sh . "$TEST_OUTPUT_DIRECTORY/extensions/lib.sh" interpreters=$(ext_lua_interpreters 4) test -z "$interpreters" && say 'no standalone lua on the path, unit checks skipped' for lua in $interpreters do test_expect_success "unit checks under $lua" " '$lua' '$EXT_TEST_DIRECTORY/test-about-render.lua' '$EXTENSIONS_DIRECTORY/about-render.lua' " test_expect_success "fallback checks without lpeg under $lua" " '$lua' '$EXT_TEST_DIRECTORY/test-about-render.lua' '$EXTENSIONS_DIRECTORY/about-render.lua' nolpeg " done test_expect_success 'create a repository with a markdown readme' ' test_create_repo repos/md && ( cd repos/md && cat >README.md <<-\EOF && # The Title A **bold** claim and a attempt. EOF git add README.md && git commit -m "add readme" ) ' test_expect_success 'point cgit at it through the about filter' ' cat >cgitrc <<-EOF virtual-root=/ cache-size=0 enable-filter-overrides=1 repo.url=md repo.path=$PWD/repos/md/.git repo.readme=master:README.md repo.about-filter=lua:$EXTENSIONS_DIRECTORY/about-render.lua EOF ' if test "$CGIT_HAS_LUA" -eq 1 then if cgit_lua_probe "$PWD/repos/md/.git" lpeg then test_set_prereq CGIT_LUA_LPEG else test_set_prereq CGIT_LUA_NOLPEG say 'cgit lua has no lpeg, expecting the plain text fallback' fi else say 'cgit built without lua, filter checks through cgit skipped' fi test_expect_success CGIT_LUA_LPEG 'the about page renders the markdown' ' cgit_url "md/about/" >tmp && grep "