vet

Mirror of Vet, an AI code review tool
git clone git://git.laack.co/vet.git
Log | Files | Refs | README | LICENSE

test.sh (1648B)


      1 #!/usr/bin/env bash
      2 set -euo pipefail
      3 
      4 # builds Arch package from working tree, installs it, runs a few non-llm vet commands, tests uninstall
      5 
      6 SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
      7 REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
      8 CONTAINER_NAME="vet-pkgbuild-test-$$"
      9 
     10 cleanup() {
     11     docker rm -f "$CONTAINER_NAME" >/dev/null 2>&1 || true
     12 }
     13 trap cleanup EXIT
     14 
     15 # arch container w/ read-only mounted code
     16 docker run --name "$CONTAINER_NAME" -d -v "$REPO_ROOT":/repo:ro archlinux:base-devel sleep 600
     17 
     18 run() {
     19     docker exec "$CONTAINER_NAME" bash -c "$1"
     20 }
     21 
     22 run "pacman -Syu --noconfirm python git"
     23 
     24 # prep build env
     25 run "
     26     useradd -m builder &&
     27     mkdir /build && cp /repo/pkg/arch/PKGBUILD /repo/pkg/arch/verify-everything.install /build/ &&
     28 
     29     tar -czf /build/vet-current.tar.gz -C /repo --transform='s,^\.,vet-current,' \
     30         --exclude='.git' --exclude='pkg/arch/test.sh' . &&
     31 
     32     sed -i 's|^source=.*|source=(\"vet-current.tar.gz\")|' /build/PKGBUILD &&
     33     sed -i 's|\$srcdir/vet-\$pkgver|\$srcdir/vet-current|' /build/PKGBUILD &&
     34 
     35     chown -R builder:builder /build
     36 "
     37 
     38 # build + install
     39 run "su - builder -c 'cd /build && makepkg -sf --noconfirm'"
     40 run "pacman -U --noconfirm /build/verify-everything-*-any.pkg.tar.zst"
     41 
     42 # basic non-llm commands
     43 run "command -v vet"
     44 run "vet --help"
     45 run "vet --version"
     46 run "vet --list-issue-codes"
     47 
     48 # uninstall
     49 run "pacman -R --noconfirm verify-everything"
     50 
     51 if run "command -v vet" 2>/dev/null; then
     52     echo "FAIL: vet still found after uninstall"
     53     exit 1
     54 fi
     55 
     56 if run "test -d /opt/verify-everything"; then
     57     echo "FAIL: /opt/verify-everything still exists after uninstall"
     58     exit 1
     59 fi