Commit ed8c03fb authored by Vojtěch Horký's avatar Vojtěch Horký
Browse files

13/makefile fixes

parent a65906ce
......@@ -43,6 +43,10 @@ prepare() {
cp -R 13/* "${NSWI177_TEMP}/13"
cd "${NSWI177_TEMP}"
if [ -n "${NSWI177_STUDENT_NUMBER}" ]; then
mkdir -p 13/public_html
fi
}
stat_modif() {
......@@ -53,7 +57,8 @@ run_make() {
launch timeout 1m make -C 13 "$@"
msg="Expecting make to terminate with success" assert_status 0 \
'stdout' "${output}" \
'stderr' "${erroroutput}"
'stderr' "${erroroutput}" \
'command' "make -C 13 $*"
}
fail_if_not_generated() {
......@@ -62,12 +67,53 @@ fail_if_not_generated() {
fi
}
fail_if_no_match_in_generated() {
local where="public_html/$1"
local text="$2"
local message="${msg:-}"
if [ -z "$message" ]; then
message="Text $text not found in $where."
fi
if ! grep -q -F "$text" "13/$where"; then
batslib_print_kv_single_or_multi 8 \
'file' "$where" \
'contents': "$( cat "13/$where" )" \
| batslib_decorate "$message" \
| fail
fi
}
assert_content() {
if [ $# -eq 0 ]; then
if grep -q 'https://is.cuni.cz/studium/eng/predmety/index.php' "13/public_html/index.html"; then
batslib_print_kv_single_or_multi 8 \
'file' "public_html/index.html" \
'contents': "$( cat "13/public_html/index.html" )" \
| batslib_decorate "public_html/index.html should not contain link to SIS course page" \
| fail
fi
fi
if [ $# -eq 0 ]; then
msg="Menu not found in index.html" fail_if_no_match_in_generated index.html '<li><a href="N'
fi
local course
for course in "$@"; do
msg="Menu not found in $course.html" fail_if_no_match_in_generated "$course.html" '<li><a href="N'
msg="SIS link missing in $course.html" fail_if_no_match_in_generated "$course.html" "<a href=\"https://is.cuni.cz/studium/eng/predmety/index.php?do=predmet&kod=${course}\">${course}</a>"
done
}
assert_incremental_build() {
local to_be_changed_src="$1"
local -a to_be_modified
local -a to_be_unchanged
shift
while [[ "${1}" != '--' ]]; do
to_be_modified+=("${1}")
shift
......@@ -85,7 +131,7 @@ assert_incremental_build() {
local -A original_timestamps
# Do a clean build
run_make clean "$@"
rm -f 13/public_html/* 13/_menu.md 13/_menu.html
run_make "$@"
local i
......@@ -176,6 +222,7 @@ assert_incremental_build() {
run_make
assert_file_has_mime_type "13/public_html/index.html" "text/html"
assert_content
}
@test "13/Makefile - Base build for COURSE.html (10)" {
......@@ -188,6 +235,7 @@ assert_incremental_build() {
for course in "${NSWI177_13_COURSES[@]}"; do
assert_file_has_mime_type "13/public_html/${course}.html" "text/html"
done
assert_content "${NSWI177_13_COURSES[@]}"
}
@test "13/Makefile - Base build for main.css (10)" {
......@@ -206,7 +254,7 @@ assert_incremental_build() {
prepare
assert_incremental_build "template.html" \
"public_html/index.html" "public_html/NSWI177.html" "public_html/main.css" "public_html/NSWI170.html" \
"public_html/index.html" "public_html/NSWI177.html" "public_html/NSWI170.html" \
-- main.css
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment