Update the foreign document test to use all org-mode documents from the org-mode repository.
This commit is contained in:
parent
d90ff5891b
commit
b83a103c17
@ -40,9 +40,9 @@ RUN mkdir /foreign_documents
|
||||
|
||||
|
||||
FROM tester as foreign-document-test
|
||||
RUN apk add --no-cache bash
|
||||
RUN apk add --no-cache bash coreutils
|
||||
RUN mkdir /foreign_documents
|
||||
COPY --from=build-org-mode /root/org-mode/doc /foreign_documents/org-mode
|
||||
COPY --from=build-org-mode /root/org-mode /foreign_documents/org-mode
|
||||
COPY foreign_document_test_entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
@ -5,6 +5,8 @@ set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
REALPATH=$(command -v uu-realpath || command -v realpath)
|
||||
|
||||
function log {
|
||||
(>&2 echo "${@}")
|
||||
}
|
||||
@ -23,8 +25,56 @@ function main {
|
||||
fi
|
||||
PARSE="${CARGO_TARGET_DIR}/release-lto/parse"
|
||||
|
||||
run_compare "org-mode/org-guide.org" "/foreign_documents/org-mode/org-guide.org"
|
||||
run_compare "org-mode/org-manual.org" "/foreign_documents/org-mode/org-manual.org"
|
||||
run_compare_function "org-mode" compare_all_org_document "/foreign_documents/org-mode"
|
||||
}
|
||||
|
||||
function green_text {
|
||||
(IFS=' '; printf '\x1b[38;2;0;255;0m%s\x1b[0m' "${*}")
|
||||
}
|
||||
|
||||
function red_text {
|
||||
(IFS=' '; printf '\x1b[38;2;255;0;0m%s\x1b[0m' "${*}")
|
||||
}
|
||||
|
||||
function yellow_text {
|
||||
(IFS=' '; printf '\x1b[38;2;255;255;0m%s\x1b[0m' "${*}")
|
||||
}
|
||||
|
||||
function indent {
|
||||
local depth="$1"
|
||||
local scaled_depth=$((depth * 2))
|
||||
shift 1
|
||||
local prefix=$(printf -- "%${scaled_depth}s")
|
||||
while read l; do
|
||||
(IFS=' '; printf -- '%s%s\n' "$prefix" "$l")
|
||||
done
|
||||
}
|
||||
|
||||
function run_compare_function {
|
||||
local name="$1"
|
||||
local stdoutput
|
||||
shift 1
|
||||
set +e
|
||||
stdoutput=$("${@}")
|
||||
local status=$?
|
||||
set -e
|
||||
if [ "$status" -eq 0 ]; then
|
||||
echo "$(green_text "GOOD") $name"
|
||||
indent 1 <<<"$stdoutput"
|
||||
else
|
||||
echo "$(red_text "FAIL") $name"
|
||||
indent 1 <<<"$stdoutput"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function compare_all_org_document {
|
||||
local root_dir="$1"
|
||||
local target_document
|
||||
find "$root_dir" -type f -iname '*.org' | while read target_document; do
|
||||
local relative_path=$($REALPATH --relative-to "$root_dir" "$target_document")
|
||||
(run_compare "$relative_path" "$target_document")
|
||||
done
|
||||
}
|
||||
|
||||
function run_compare {
|
||||
@ -42,16 +92,4 @@ function run_compare {
|
||||
fi
|
||||
}
|
||||
|
||||
function green_text {
|
||||
(IFS=' '; printf '\x1b[38;2;0;255;0m%s\x1b[0m' "${*}")
|
||||
}
|
||||
|
||||
function red_text {
|
||||
(IFS=' '; printf '\x1b[38;2;255;0;0m%s\x1b[0m' "${*}")
|
||||
}
|
||||
|
||||
function yellow_text {
|
||||
(IFS=' '; printf '\x1b[38;2;255;255;0m%s\x1b[0m' "${*}")
|
||||
}
|
||||
|
||||
main "${@}"
|
||||
|
Loading…
Reference in New Issue
Block a user