-
Notifications
You must be signed in to change notification settings - Fork 4
/
check.sh
executable file
·128 lines (87 loc) · 3.67 KB
/
check.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#! /usr/bin/env bash
# ============================================================================ #
#
# Runs subtests in a top-level harness.
#
# ---------------------------------------------------------------------------- #
set -eu;
set -o pipefail
# ---------------------------------------------------------------------------- #
_as_me='check.sh';
# ---------------------------------------------------------------------------- #
_es=0;
_ec=0;
count=0;
run_test() {
local name;
name="$1";
shift;
echo "Running Check: $name" >&2;
if eval "$*" >&2; then
echo "PASS: $name"
else
echo "FAIL: $name"
_ec=$(( _ec + 1 ));
fi
echo '' >&2;
count=$(( count + 1 ));
}
# ---------------------------------------------------------------------------- #
trap '
_es="$?";
echo "$_as_me: Run Cancelled" >&2;
exit "$_es";
' HUP TERM INT QUIT;
# ---------------------------------------------------------------------------- #
: "${NIX:=nix}";
: "${REALPATH:=realpath}"
: "${SHELLCHECK:=$NIX run 'nixpkgs#shellcheck' --}";
: "${MKTEMP:=mktemp}"
SPATH="$( $REALPATH "${BASH_SOURCE[0]}"; )";
SDIR="${SPATH%/*}";
# ---------------------------------------------------------------------------- #
run_test "Packages Module" "$SDIR/tests/modules/packages/check.sh";
run_test "Packages Module (dist)" "$SDIR/tests/modules/packages/dist/check.sh";
run_test "Set Node Version" "$SDIR/tests/modules/packages/nodePackage/check.sh";
run_test "Library Extensions" "$SDIR/tests/lib/check.sh";
run_test "pdef (deserialized)" \
"$NIX" eval --show-trace -f "$SDIR/tests/modules/pdef/deserial/noFetch";
run_test "pdef lodash registry" \
"$NIX" eval --json -f "$SDIR/tests/modules/pdef/from-registry.nix";
run_test "install-module lodash" \
"$NIX" build --no-link --show-trace \
-f "$SDIR/tests/setup/lodash-install.nix";
run_test "run-script trivial" \
"$NIX" build --no-link --show-trace -f "$SDIR/tests/setup/run-script.nix";
run_test "updaters: from-registry pacote" \
"$SDIR/tests/updaters/from-registry/proj1.sh";
run_test "updaters: npm-plock proj1" "$SDIR/tests/updaters/npm-plock/proj1.sh";
run_test "floco translate: npm-plock local1" \
"$SDIR/tests/cli/translate/local1.sh";
run_test "floco translate: npm-plock local-mod1" \
"$SDIR/tests/cli/translate/local-mod1/check.sh";
run_test "floco translate: from-registry remote1" \
"$SDIR/tests/cli/translate/remote1.sh";
run_test "treeInfo from pins" \
test "$( $NIX eval -f "$SDIR/tests/modules/pdefs/pinned" ok; )" = 'true';
run_test "linkedLocks" \
"$NIX" eval --json -f "$SDIR/tests/modules/plock/linked-locks" \
linkedLocks;
run_test "target override/extras" \
"$NIX" build -L --no-link -f "$SDIR/tests/modules/packages/overrides";
run_test "shellcheck" \
"$SHELLCHECK" -x "$SDIR/"{updaters/*.sh,pkgs/cli/src/**/*.sh};
run_test "floco show with extra config" "$SDIR/tests/cli/show-extra.sh";
run_test "nix flake check" "$NIX" flake check "$SDIR";
# ---------------------------------------------------------------------------- #
if [[ "$_ec" -gt 0 ]]; then
echo "FAILED: $_ec/$count checks.";
else
echo "PASSED: $count/$count checks.";
fi
exit "$_ec";
# ---------------------------------------------------------------------------- #
#
#
#
# ============================================================================ #