From 75db4a53931017457d0915ffaf52f85b189b5ba5 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 25 Jan 2024 17:39:16 -0800 Subject: [PATCH] Run test-llm-load-plugins.sh, refs #378 --- .github/workflows/test.yml | 4 ++++ tests/test-llm-load-plugins.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100755 tests/test-llm-load-plugins.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 51c5a3f5..7348a3fc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,3 +41,7 @@ jobs: - name: Run ruff run: | ruff . + - name: Run test-llm-load-plugins.sh + run: | + llm install llm-cluster llm-sentence-transformers + ./tests/test-llm-load-plugins.sh diff --git a/tests/test-llm-load-plugins.sh b/tests/test-llm-load-plugins.sh new file mode 100755 index 00000000..3bf0d239 --- /dev/null +++ b/tests/test-llm-load-plugins.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# This should only run in environemnts where both +# llm-cluster and llm-sentence-transformers are installed + +PLUGINS=$(llm plugins) +echo "$PLUGINS" | jq 'any(.[]; .name == "llm-sentence-transformers")' | \ + grep -q true || ( \ + echo "Test failed: llm-sentence-transformers not found" && \ + exit 1 \ + ) +# With the LLM_LOAD_PLUGINS we should not see that +PLUGINS2=$(LLM_LOAD_PLUGINS=llm-cluster llm plugins) +echo "$PLUGINS2" | jq 'any(.[]; .name == "llm-sentence-transformers")' | \ + grep -q false || ( \ + echo "Test failed: llm-sentence-transformers should not have been loaded" && \ + exit 1 \ + ) +echo "$PLUGINS2" | jq 'any(.[]; .name == "llm-cluster")' | \ + grep -q true || ( \ + echo "Test llm-cluster should have been loaded" && \ + exit 1 \ + ) +# With LLM_LOAD_PLUGINS='' we should see no plugins +PLUGINS3=$(LLM_LOAD_PLUGINS='' llm plugins) +echo "$PLUGINS3"| \ + grep -q '\[\]' || ( \ + echo "Test failed: plugins should have returned []" && \ + exit 1 \ + )