mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-12 21:10:54 +01:00
Two levels of pure taxonomy carrying no information, and a 2-directory
cap leaves no room for them. Categories now sit directly under
linux_configuration/: features, fixes, utils, misc, fresh-install,
installers, diagnostics, gaming, boot_recovery, periodic_background, lib,
meta, tests. A script's own lib/ and tests/ are exempt from the cap, so
those stay put.
Depth violations 248 -> 139; roughly 40 of the remainder are inside
digital_wellbeing and hosts, deferred until the guard-lib repoint.
The moves are the easy half. What breaks is every path that counted
levels, and three classes of it had to be found by resolving paths rather
than reading diffs:
- 52 relative `source` lines for lib/common.sh and lib/android.sh. The
correct prefix differs per file: 40 were ../../ and 12 were ../../../,
so a blanket replace would have fixed one set and broken the other.
- REPO_ROOT in 7 fixes/lib/tests harnesses and setup_syncyomi_guard.sh,
each walking up four levels from a directory now two levels shallower.
This caused a real regression -- the fixes suite went red with
"log_warn: command not found" -- caught by running it and comparing
against the pre-move baseline worktree.
- conftest.py's sys.path entries, which took the pytest gate down with
14 collection errors, and the `# shellcheck source=` directives, which
took shellcheck down with SC1091.
16 symlinks in $HOME broke, including the entire i3blocks bar. All
repointed, and cpu_monitor/memory/disk/time/volume were run to confirm
they emit real output rather than merely resolving.
Verified: 1798 tests pass at 100% coverage, 8 of 9 lib/tests suites pass
(the ninth needs the coverage jail, identically at baseline), pre-commit
is clean, and the two untracked secret configs are still ignored after
their gitignore paths changed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PJrqKERAo5QUeEHWS5Asgp
84 lines
4.5 KiB
Bash
Executable File
84 lines
4.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Tests for lib/study_doc_urls.sh — the Python, JS, TS and C/C++ doc-URL
|
|
# builders.
|
|
#
|
|
# Each builder is a case dispatch over term categories with a search-URL
|
|
# fallback, so every arm gets one assertion plus one for the fallback. The
|
|
# fallback matters more than it looks: it is what every unrecognised term hits,
|
|
# so a card for an unknown identifier still links somewhere useful instead of
|
|
# to an empty string.
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
# shellcheck source=study_harness.sh
|
|
. "${SCRIPT_DIR}/study_harness.sh"
|
|
# shellcheck source=../study_doc_urls.sh
|
|
. "${SCRIPT_DIR}/../study_doc_urls.sh"
|
|
|
|
echo "== python_doc_url =="
|
|
_t_eq "https://docs.python.org/3/reference/compound_stmts.html" \
|
|
"$(python_doc_url "def" keyword)" "a keyword links to the statements reference"
|
|
_t_eq "https://docs.python.org/3/library/functions.html#print" \
|
|
"$(python_doc_url "print" builtin)" "a builtin links to its anchor in functions.html"
|
|
_t_eq "https://docs.python.org/3/library/os.html" \
|
|
"$(python_doc_url "os" module)" "a stdlib module links to its own page"
|
|
_t_eq "https://docs.python.org/3/library/unittest.mock.html" \
|
|
"$(python_doc_url "MagicMock" module)" "a mock helper links to unittest.mock"
|
|
_t_eq "https://docs.python.org/3/search.html?q=frobnicate" \
|
|
"$(python_doc_url "frobnicate" keyword)" "an unknown term falls back to search"
|
|
|
|
echo "== js_doc_url =="
|
|
_t_has "$(js_doc_url "const" keyword)" "developer.mozilla.org" "a JS keyword links to MDN"
|
|
_t_has "$(js_doc_url "Array" builtin)" "Array" "a builtin object names itself in the URL"
|
|
_t_has "$(js_doc_url "frobnicate" keyword)" "frobnicate" "an unknown JS term still carries the term"
|
|
|
|
echo "== ts_doc_url =="
|
|
_t_has "$(ts_doc_url "interface" keyword)" "typescriptlang.org" "a TS term links to the TS handbook"
|
|
_t_has "$(ts_doc_url "Partial" keyword)" "utility-types" "a TS utility type links to the utility-types page"
|
|
# A term TypeScript does not define is a runtime feature, so it deliberately
|
|
# falls through to the JS builder rather than to a TS search page.
|
|
_t_has "$(ts_doc_url "frobnicate" keyword)" "developer.mozilla.org" "an unknown TS term falls through to MDN"
|
|
|
|
echo "== js_doc_url: every category of builtin =="
|
|
_t_has "$(js_doc_url "map" builtin)" "Global_Objects/Array" "an array method links under Array"
|
|
_t_has "$(js_doc_url "split" builtin)" "Global_Objects/String" "a string method links under String"
|
|
_t_has "$(js_doc_url "then" builtin)" "Global_Objects/Promise" "a promise method links under Promise"
|
|
_t_has "$(js_doc_url "fetch" builtin)" "docs/Web/API" "a browser API links under Web/API"
|
|
|
|
echo "== c_doc_url =="
|
|
_t_has "$(c_doc_url "printf" builtin)" "cppreference.com" "a C library function links to cppreference"
|
|
_t_has "$(c_doc_url "for" keyword)" "cppreference.com" "a C keyword links to cppreference"
|
|
_t_has "$(c_doc_url "frobnicate" keyword)" "cppreference.com" "an unknown C term stays on cppreference"
|
|
|
|
_t_has "$(c_doc_url "stdio" module)" "c/header/stdio.h" "a C header links to its header page"
|
|
_t_has "$(c_doc_url "malloc" builtin)" "c/memory" "an allocator links to the memory page"
|
|
_t_has "$(c_doc_url "strlen" builtin)" "c/string/byte" "a string function links to the byte-string page"
|
|
|
|
echo "== cpp_doc_url =="
|
|
_t_has "$(cpp_doc_url "vector" builtin)" "cppreference.com" "a C++ container links to cppreference"
|
|
_t_has "$(cpp_doc_url "class" keyword)" "cppreference.com" "a C++ keyword links to cppreference"
|
|
_t_has "$(cpp_doc_url "frobnicate" keyword)" "cppreference.com" "an unknown C++ term stays on cppreference"
|
|
|
|
_t_has "$(cpp_doc_url "sort" builtin)" "cpp/algorithm/sort" "an algorithm links under cpp/algorithm"
|
|
_t_has "$(cpp_doc_url "unique_ptr" builtin)" "cpp/memory/unique_ptr" "a smart pointer links under cpp/memory"
|
|
_t_has "$(cpp_doc_url "optional" builtin)" "cpp/utility" "a utility type links under cpp/utility"
|
|
|
|
echo "== every builder answers for every input =="
|
|
# The generation phases pipe whatever the analysis found straight into these,
|
|
# including punctuation and empty strings from a malformed grep line. A builder
|
|
# that returned nothing would silently produce a card with no link at all, so
|
|
# the invariant worth pinning is that output is never empty.
|
|
for fn in python_doc_url js_doc_url ts_doc_url c_doc_url cpp_doc_url; do
|
|
for term in "" "x" "std::vector" "__init__" "a-b" "3"; do
|
|
out="$("$fn" "$term" keyword)"
|
|
if [[ -n "$out" ]]; then
|
|
_t_pass "${fn} answers for '${term}'"
|
|
else
|
|
_t_fail "${fn} answers for '${term}' (returned nothing)"
|
|
fi
|
|
done
|
|
done
|
|
|
|
_t_summary
|