From 4907dcdc4f90f0e81fa585a9334093e9e3cb470f Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Tue, 1 Feb 2022 10:45:25 -0700 Subject: [PATCH] test more contained, gitlab partially tested --- app/crawler/gitlab.sh | 5 +++-- app/crawler/gitlab_test.sh | 29 +++++++++++++++++++++++++++++ app/crawler/test.sh | 18 ++++++++++++------ 3 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 app/crawler/gitlab_test.sh diff --git a/app/crawler/gitlab.sh b/app/crawler/gitlab.sh index 854da59..1f1b095 100644 --- a/app/crawler/gitlab.sh +++ b/app/crawler/gitlab.sh @@ -2,7 +2,7 @@ gitlab() ( is() { - echo "$*" | grep -q gitlab.app && ! echo "$*" | grep -q '/wiki/' + echo "$*" | grep -q gitlab.app && ! echo "$*" | grep -q '/wikis/' } get() { @@ -33,7 +33,8 @@ gitlab() ( local url="$1" local url_path="${url#http*://gitlab*.net/}" local project="${url_path%%/-/*}" - local root="${url_path#*/-/}" + local root="${url_path#*$project}" + local root="${root#*/-/}" local root="${root#tree/}" local root="${root#blob/}" local root="${root#*/}" diff --git a/app/crawler/gitlab_test.sh b/app/crawler/gitlab_test.sh new file mode 100644 index 0000000..1f7db81 --- /dev/null +++ b/app/crawler/gitlab_test.sh @@ -0,0 +1,29 @@ +#! /bin/bash + +test_get() { + gitlab eval "$(cat <&2 local f="$1" local ret=0 for t in $(grep ^test_ "$f" | sed 's/(.*//'); do - echo testing $f:$t >&2 - each - source "${f%_test.sh}.sh" - source "$f" - if ! eval "$t"; then + if ! one_test "$f" "$t"; then echo failed $f:$t >&2 ret=$((ret+1)) fi @@ -31,9 +26,20 @@ one_main() ( return $ret ) +one_test() ( + local f="$1" + local t="$2" + each + source "${f%_test.sh}.sh" + source "$f" + eval "$t" +) + each() { export CACHE=$(mktemp -d) source ./cache.sh + set -e + set -o pipefail } if [ "$0" == "$BASH_SOURCE" ]; then