interplane.Get Omega
Read in your language

interplane-forge

INTERPLANE Forge

Brought by drakestapleton

branch main Branches Tags History

interplane-forge / social / tests / units.sh

34 lines · 1870 bytes Raw Blame History
1# The unit list of the social test binary, sourced by lib.sh and units-check.sh (run from the root).
2# The list is never typed here: `./run.sh seams` gives the build's units in the build's order with
3# every slice as its seam, and social_units puts the byte-sorted SRC/*.om in place of the one
4# server/nosocial.om line. A change to the order in run.sh reaches the social tests with no edit here.
5
6# social_units SRC: print the list, one path per line. Exit 1 with the reason on stderr when run.sh
7# fails, the seam is not listed exactly once, SRC holds no .om file, or a listed file does not exist.
8social_units() {
9 su_seams=$(./run.sh seams) || { echo "units.sh: ./run.sh seams failed" >&2; return 1; }
10 su_n=$(printf '%s\n' "$su_seams" | grep -cx 'server/nosocial.om' || true)
11 if [ "$su_n" != 1 ]; then
12 echo "units.sh: ./run.sh seams lists server/nosocial.om $su_n times, not once" >&2
13 return 1
14 fi
15 su_src=$(printf '%s\n' "$1"/*.om | LC_ALL=C sort)
16 case $su_src in *'*.om'*) echo "units.sh: no .om file in $1" >&2; return 1 ;; esac
17 su_list=$(printf '%s\n' "$su_seams" | while IFS= read -r u; do
18 if [ "$u" = server/nosocial.om ]; then printf '%s\n' "$su_src"; else printf '%s\n' "$u"; fi
19 done)
20 su_missing=$(printf '%s\n' "$su_list" | while IFS= read -r u; do [ -f "$u" ] || printf '%s\n' "$u"; done)
21 if [ -n "$su_missing" ]; then
22 echo "units.sh: listed unit $(printf '%s\n' "$su_missing" | head -1) does not exist" >&2
23 return 1
24 fi
25 printf '%s\n' "$su_list"
26}
27
28# typed_units FILE: print each code line (not a # comment) of FILE that names a unit path (any
29# <dir>/<name>.om, with ./, $VAR/, {a,b} or $var inside the name) other than the seam units.sh
30# replaces; nothing when FILE types no unit list
31typed_units() {
32 grep -n '' "$1" | grep -vE '^[0-9]+:[[:space:]]*#' | sed 's|server/nosocial\.om||g' \
33 | grep -E '[a-z]+/[A-Za-z0-9_.{},$-]*\.om'
34}