test(11.2): cover site_url and site_label and gate the framework, app and site stages
- TestCheckSiteURL (21 accepted and rejected values), TestSiteLabel and TestSiteURLPrecedence (option over site.yaml, label-without-URL and invalid option errors); new TestParseSite rows for blank and two-line labels - TestSiteLink: escaped label, section page and 404 page, exact unset header bytes - TestDocsSiteFlagsInHelp and the --site-label-without-URL error - check-phase11.2.sh --framework, --app and --site
This commit is contained in:
@@ -20,13 +20,18 @@ ROOT="${PHASE11_2_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
|
||||
APP="${PHASE11_2_APP:-$ROOT/../sm-summercmsio-app}"
|
||||
PLUG="$APP/plugins/golem15/summercms"
|
||||
SITE="$APP/vue-summercmsio-app"
|
||||
APP_PKG="git.golem15.com/golem15/sm-summercmsio-app"
|
||||
# Statement coverage floors (SC5).
|
||||
PLUGIN_COVERAGE_MIN=90.0
|
||||
DOCSITE_COVERAGE_MIN=85.0
|
||||
|
||||
usage() {
|
||||
cat >&2 <<'EOF'
|
||||
usage:
|
||||
check-phase11.2.sh --framework
|
||||
check-phase11.2.sh --plugin
|
||||
check-phase11.2.sh --app
|
||||
check-phase11.2.sh --site
|
||||
EOF
|
||||
exit 2
|
||||
}
|
||||
@@ -125,6 +130,20 @@ coverage_at_least() {
|
||||
awk -v t="$total" -v m="$min" 'BEGIN { exit !(t + 0 >= m + 0) }' || refuse "coverage $total% is below $min% in $dir"
|
||||
}
|
||||
|
||||
# Framework tests of the D-41/D-46 site link, plus the docs checker.
|
||||
DOCSITE_TESTS=(TestParseSite TestCheckSiteURL TestSiteLabel TestSiteURLPrecedence TestSiteLink)
|
||||
SUMMER_TESTS=(TestDocsTree TestDocsBuildRealTree TestDocsBuildSiteFlags TestDocsSiteFlagsInHelp)
|
||||
|
||||
run_framework() {
|
||||
(cd "$ROOT" && go vet ./...)
|
||||
named_tests "$ROOT" ./internal/docsite "${DOCSITE_TESTS[@]}" || refuse "framework: internal/docsite named tests"
|
||||
named_tests "$ROOT" ./cmd/summer "${SUMMER_TESTS[@]}" || refuse "framework: cmd/summer named tests"
|
||||
coverage_at_least "$ROOT" "$DOCSITE_COVERAGE_MIN" ./internal/docsite
|
||||
"$ROOT/scripts/check-phase11.1.sh" --docs
|
||||
"$ROOT/scripts/check-phase11.1.sh" --forbidden
|
||||
echo "phase11.2 framework passed"
|
||||
}
|
||||
|
||||
PLUGIN_TESTS=(TestStaticSmoke TestStaticSite TestStaticDocs TestStaticConditionalAndRange TestStaticNoBlockingHeaders
|
||||
TestStaticRedirectLocations TestStaticMissing404Page TestNewHandlersMissingIndex TestContentType TestSiteImmutable
|
||||
TestRoutesAssemble TestRoutesFailClosed TestRoutesCoexistWithAdminPatterns TestPluginIdentity TestPluginEmbeddedTree
|
||||
@@ -138,7 +157,46 @@ run_plugin() {
|
||||
echo "phase11.2 plugin passed"
|
||||
}
|
||||
|
||||
# The D-40 terminal-check helpers (the gated TestTerminalCommands runs in
|
||||
# the terminal stage).
|
||||
APP_TESTS=(TestLoadTerminal TestTerminalScript TestTerminalEnv)
|
||||
|
||||
run_app() {
|
||||
local pkgs
|
||||
need_dir "$APP"
|
||||
go -C "$APP" vet ./...
|
||||
pkgs="$(go -C "$APP" list ./...)"
|
||||
[ "$pkgs" = "$APP_PKG" ] || refuse "app: go list ./... printed '$pkgs', want only $APP_PKG"
|
||||
(unset SUMMERCMS_TERMINAL_CHECK && named_tests "$APP" . "${APP_TESTS[@]}") || refuse "app: named tests"
|
||||
echo "phase11.2 app passed"
|
||||
}
|
||||
|
||||
# run_site installs from the lockfile, generates the static site and runs
|
||||
# the node:test suites (output, terminal and scroll-spy tests).
|
||||
run_site() {
|
||||
local log
|
||||
need_dir "$SITE"
|
||||
command -v pnpm >/dev/null || refuse "site: pnpm not found"
|
||||
pnpm -C "$SITE" install --frozen-lockfile
|
||||
pnpm -C "$SITE" run generate
|
||||
log="$(mktemp)"
|
||||
SCRATCH+=("$log")
|
||||
pnpm -C "$SITE" test >"$log" 2>&1 || {
|
||||
cat "$log" >&2
|
||||
refuse "site: pnpm test failed"
|
||||
}
|
||||
grep -E '^# (tests|pass|fail|skipped|todo|cancelled) ' "$log"
|
||||
grep -qx '# fail 0' "$log" || refuse "site: no '# fail 0' line"
|
||||
grep -qE '^# pass [1-9][0-9]*$' "$log" || refuse "site: no passing tests"
|
||||
grep -qx '# skipped 0' "$log" || refuse "site: skipped tests"
|
||||
grep -qx '# todo 0' "$log" || refuse "site: todo tests"
|
||||
echo "phase11.2 site passed"
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
--framework) run_framework ;;
|
||||
--plugin) run_plugin ;;
|
||||
--app) run_app ;;
|
||||
--site) run_site ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user