AgeCommit message (Collapse)AuthorLines
Share the rename fixture of the diff pagesBryce Kwon-0/+17
Each repository is built tree for tree as before. A helper that lost the caller's change would still fail t0107, where following no path shows file-1, but t0108 passed without its added line, so it now looks for that line.
Add a helper for configs of several repositoriesBryce Kwon-0/+10
The configs a run of t0101 writes are byte for byte what they were. The scan configs name no repository and descrc adds one to a copy of the shared config, so those keep their own form.
Keep cgit under Valgrind whichever way it is askedBryce Kwon-7/+23
The library runs a script again for --tee, --verbose-log and --stress with the arguments setup.sh left it, and --valgrind was no longer among them, so -V --valgrind ran cgit bare. --valgrind=<tool> reached the library instead, which then wrapped every Git command and left cgit alone. --valgrind-only is refused, as it would need the library's own per-test switching.
Let a test run require the tools it must not skipBryce Kwon-0/+7
Nothing could make a missing prerequisite fail. A host without pkg-config builds without Lua, and make test then passed with every Lua test skipped and the lua pass of t0201 never run. The whole-script skips become named prerequisites so the same list covers them, and the strace probe now traces the file class of calls the tests use, so an strace too old for it skips rather than fails.
Fail a test script that leaves a sanitizer reportBryce Kwon-0/+31
Without -v a report went to /dev/null with the rest of stderr, and one from a process whose status a pipeline or a background job loses failed nothing at all.
Put a time limit on each request in the testsBryce Kwon-1/+4
A regression that blocked, such as a lock never let go or a filter that never returns, hung make test rather than failing it. The alarm is set in Perl, which the test library already wants for its chain lint, since a pending alarm survives the exec into cgit.
Stop marking setup.sh as executableBryce Kwon-0/+0
It is only ever sourced, as extensions/lib.sh is.
Leave no stray variables or globs from setup.shBryce Kwon-4/+9
The arguments were split back apart with globbing on, so one that matched a file in tests/ reached the library as that file's name.
Correct the comments on the test plumbingBryce Kwon-1/+6
cgit_rc keeps its name, close as it is to cgitrc_repo and cgitrc_copy, since every script calls it, so a comment now says what it runs.
Keep the test results where the library puts themBryce Kwon-7/+0
Only the counts were re-pointed at results/. The --tee, --verbose-log and --stress logs, the leak logs and the counts of a script skipped through GIT_SKIP_TESTS still went to test-results/, which nothing ignored or cleaned, so a summary read from one place would miss them.
Pin what the test library reads from the shellBryce Kwon-2/+9
An exported TEST_OUTPUT_DIRECTORY made every script bail out, and an exported GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main failed t0102.
Add a request helper that checks the answerBryce Kwon-0/+47
cgit exits 0 whatever goes wrong, and a die after the headers leaves a page cut short behind a 200 status, so cgit_rc and its siblings pass any page that does not crash. Only 71 of the 337 tests that request a page checked a status line. cgit_ok also wants an empty stderr and, for HTML, the closing tag. cgit_ok_url renders afresh with the page cache off, since the shared config caches a page under its request alone.
Fail where a test fixture breaksBryce Kwon-24/+29
mkrepo had no && chain, so a failed add or commit went unnoticed and every mkrepo call in the tests passed on a broken repository. The shared fixtures were built the same way. They are still built when setup.sh is sourced, so --run can pick out any test, but a failure now stops the run where it broke.
Stop the run when cgit cannot report its buildBryce Kwon-4/+23
The Lua probe piped cgit --version into grep, so a crash there, or a change of wording, turned every Lua test into a skip and the run still passed. The answer is now also held against the flags the binary was built with in build/CGIT-CFLAGS.
Keep the developer's environment out of the testsBryce Kwon-0/+15
The test library clears only Git's variables, so a CGI variable or CGIT_SCINTILLUA_PATH exported in the shell reached every request, and NO_HTTP alone strips every header. LUA_INIT runs code in each standalone interpreter. The umask is pinned so files the tests create get the same modes everywhere.
Read the description file without repo.descBryce Kwon-1/+2
Only a scanned repository fell back to its description file, so one listed in cgitrc without repo.desc showed "[no description]" however its file read. repo.desc may follow repo.path, so the file is read where a page shows the description, which also spares every other request the reads.
Add the shared config writers and cgit_rcBryce Kwon-6/+55
The helpers are named by kind. cgitrc_repo and cgitrc_copy write the config file named first, and cgit_url, cgit_query and cgit_rc run cgit, each named after what it is handed first. A repository copies its defaults from the globals read before its repo.url, so cgitrc_repo places every setting itself, and a global can no longer land where it silently stops applying. The t00xx and t01xx files move to them here.
Put the valgrind comment above its loopBryce Kwon-3/+3
Drop two setup.sh lines that change nothingBryce Kwon-5/+3
The library has read TEST_RESULTS_SAN_DIR for the last time by the time it returns, and the trash directory it makes is empty, so there is no cache to remove.
Set the Lua prerequisite once for every testBryce Kwon-2/+3
setup.sh already asks the binary, so the seven scripts that each turned the answer into a prerequisite now share one. test-lib names the missing prerequisite beside every test it skips, so the notes that cgit lacks Lua go, while the ones announcing a fallback stay. Every script that listed the standalone interpreters asked for the same ceiling, so lib.sh now builds that list for all of them.
Test the hardening passBryce Kwon-11/+7
Gate scanned filters with trust-scan-filtersBryce Kwon-1/+0
Trim the comments and dead code across the treeBryce Kwon-18/+11
Collect test output under trash and resultsBryce Kwon-4/+21
Rewrite the snapshot test around one helperBryce Kwon-1/+1
Prefer POSIX forms throughout the test scriptsBryce Kwon-3/+5
Tidy the test comments and shell portabilityBryce Kwon-28/+30
Reorganise the tree into vendor/ and custom/Bryce Kwon-1/+1
Gate the cache listing behind enable-cache-listBryce Kwon-0/+1
The ls_cache page printed the cache directory path and the urls other visitors had requested, with no gate at all.
Reorganise into source, assets and librariesBryce Kwon-2/+2
Everything the build generates now lands in build/, so a clean is a single remove and the source tree stays free of build output.
tests: try with commit-graphChristian Hesse-4/+8
Git 2.24.0 enabled commit-graph by default and caused crashes without necessary update. Let's test to work with commit-graph. Signed-off-by: Christian Hesse <mail@eworm.de>
ui-snapshot: add support for zstd compressionChristian Hesse-1/+1
This patch adds support for zstd [0] compressed snapshots (*.tar.zst). We enable multiple working threads (-T0), but keep default compression level. The latter can be influenced by environment variable. [0] https://www.zstd.net/ Signed-off-by: Christian Hesse <mail@eworm.de>
tests: add tests for xz compressed snapshotsChristian Hesse-1/+1
Signed-off-by: Christian Hesse <mail@eworm.de>
ui-snapshot: add support for lzip compressionHanspeter Portner-1/+1
This patch adds support for lzip [1] compressed snapshots (*.tar.lz) [1] https://www.nongnu.org/lzip/ Signed-off-by: Hanspeter Portner <dev@open-music-kontrollers.ch> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
tests: only do lua tests if lua is compiled-inJason A. Donenfeld-1/+11
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
t0111: Additions and fixesLukas Fleischer-8/+8
* Rename the capitalize-* filters to dump.* since they also dump the arguments. * Add full argument validation to the email filters. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
t0111: Add basic tests for Lua filtersLukas Fleischer-2/+11
* Validate the email filter by manipulating stdin. Additional checks for all the arguments can be added in a later patch. * Add the exec prefix to all informational messages. * Rename the filter repository to filter-exec. The Git repository itself is not renamed since it can be shared amongst all filter types. * In the filter checks, check whether all arguments are passed properly instead of validating the buffer/stdin only. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
tests/: Add t0111-filter.shLukas Fleischer-0/+13
This adds basic tests for all types of exec filters. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
tests: add Valgrind supportJohn Keeping-1/+36
Now running tests with the "--valgrind" option will run cgit under Valgrind instead of all Git commands. Signed-off-by: John Keeping <john@keeping.me.uk>
tests: introduce strip_header() helper functionJohn Keeping-0/+8
This means that we can avoid hardcoding the number of headers we expect CGit to generate in test cases and simply remove whatever headers happen to by there when we are checking body content. Signed-off-by: John Keeping <john@keeping.me.uk>
tests: set TEST_OUTPUT_DIRECTORY to the CGit test directoryJohn Keeping-0/+1
By default, Git's test suite puts the trash directories and test-results directory into its own directory, not that containing the tests being run. This is less convenient for inspecting test failures, so set the output directory to CGit's tests/ directory instead. Note that there is currently a bug in Git whereby it will create the trash directories in our tests/ directory regardless of the value of TEST_OUTPUT_DIRECTORY, and then fail to remove them once the tests are done. This change does currently affect the location of the test-results/ directory though. Signed-off-by: John Keeping <john@keeping.me.uk>
tests: use Git's test frameworkJohn Keeping-89/+41
This allows tests to run in parallel as well as letting us use "prove" or another TAP harness to run the tests. Git's test framework requires Git to be fully built before letting any tests run, so add a new target to the top-level Makefile which builds all of Git instead of just libgit.a and make the "test" target depend on that. Signed-off-by: John Keeping <john@keeping.me.uk>
Merge branch 'stable'Lars Hjemli-2/+2
tests: properly quote arguments to printfFerry Huberts-1/+1
v2: incorporate remarks of Lukas Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
tests: handle paths with whitespaceFerry Huberts-1/+1
v2: incorporate remarks of Lukas Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
Merge branch 'stable'Lars Hjemli-0/+1
tests: fix failures when CDPATH is setFerry Huberts-0/+1
Some tests would otherwise fail because commands such as cd trash/repos/foo && git rev-list --reverse HEAD | head -1 would return 2 lines instead of 1: the 'cd' command also prints the path when CDPATH is set. Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
cgit.c: add 'clone-url' setting with support for macro expansionLars Hjemli-0/+1
The current 'clone-prefix' setting has some known issues: * All repos get the same 'clone-prefix' value since the setting is not adopted during repo registration (in cgitrc, or during scan-path traversal), but only when the setting is used. * The generated clone-urls for a repo is a combination of 'clone-prefix', a slash and the repo url. This doesn't work well with e.g. ssh-style urls like 'git@example.org:repo.git', since the inserted slash will make the repo relative to the filesystem root. * If 'remove-suffix' is enabled, the generated clone-urls will not work for cloning (except for http-urls to cgit itself) since they miss the '.git' suffix. The new 'clone-url' setting is designed to avoid the mentioned issues: * Each repo adopts the default 'clone-url' when the repo is defined. This allows different groups of repos to adopt different values. * The clone-urls for a repo is generated by expanding environment variables in a string template without inserting arbitrary characters, hence any kind of clone-url can be generated. * Macro expansion also eases the 'remove-suffix' pain since it's now possible to define e.g. 'clone-url=git://foo.org/$CGIT_REPO_URL.git' for a set of repos. A furter improvement would be to define e.g. $CGIT_REPO_SUFFIX to '.git' for all repos which had their url prettified, or to store the original $CGIT_REPO_URL in e.g. $CGIT_REPO_REAL_URL before suffix removal. Reviewed-by: Ferry Huberts <mailings@hupie.com> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
tests: add tests for links with space in path and/or argsLars Hjemli-3/+8
These tests tries to detect bad links in various pages. On the log page, there currently exists links which are not properly escaped due to the use of cgit_fileurl() when building the link. For now, this bug is simply tagged as such. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
tests/setup.sh: add support for known bugsLars Hjemli-1/+13
This patch makes it possible to add tests for known bugs without aborting the testrun. Signed-off-by: Lars Hjemli <hjemli@gmail.com>