diff --git a/.github/workflows/publish-wiki.yml b/.github/workflows/publish-wiki.yml index 90e5d5a..a6d142b 100644 --- a/.github/workflows/publish-wiki.yml +++ b/.github/workflows/publish-wiki.yml @@ -1,7 +1,7 @@ name: Publish wiki on: push: - branches: [main] + branches: [stable] paths: - docs/** - .github/workflows/publish-wiki.yml diff --git a/.github/workflows/test-skripts.yml b/.github/workflows/test-skripts.yml new file mode 100644 index 0000000..a682003 --- /dev/null +++ b/.github/workflows/test-skripts.yml @@ -0,0 +1,82 @@ +name: Run tests + +on: + workflow_dispatch: + push: + branches: + - stable + - dev + paths: + - tests/** + - scripts/** + - .github/workflows/test-skripts.yml + pull_request: + branches: + - stable + - dev + paths: + - tests/** + - scripts/** + - .github/workflows/test-skripts.yml + +concurrency: + group: run-tests + cancel-in-progress: true + +permissions: + contents: write + +jobs: + run-tests: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Pre-create plugin directory + run: | + mkdir -p build/libs + mkdir -p build/libs/skript-reflect + + - name: Download Skript-Reflect + run: | + mkdir -p build/libs + curl -L -o build/libs/skript-reflect.jar \ + https://github.com/SkriptLang/skript-reflect/releases/download/v2.6.1/skript-reflect-2.6.1.jar + + - name: Download Routines from JitPack + run: | + mkdir -p build/libs + + curl -L --fail -o build/libs/skript-reflect/routines-core.jar \ + https://jitpack.io/com/github/devdinc/routines/routines-core/v2.2.1/routines-core-v2.2.1.jar + + curl -L --fail -o build/libs/skript-reflect/routines-paper.jar \ + https://jitpack.io/com/github/devdinc/routines/routines-paper/v2.2.1/routines-paper-v2.2.1.jar + # Disable pdc for now, i want to remove skbee req + # Disable config reload + - name: Prepare scripts + run: | + mkdir -p tests/scripts + rsync -av scripts/ tests/scripts/ + mv tests/scripts/libs/singlelinesection.sk tests/scripts/libs/0_singlelinesection.sk + rm -f tests/scripts/utils/testframework.sk + rm -f tests/scripts/libs/pdc.sk + rm -f tests/scripts/utils/configreloadv2.sk + + + - name: Run tests + uses: devdinc/skript-test-action@v1.3 + with: + skript_repo_url: https://github.com/devdinc/Skript.git + # directory where your test scripts are located (relative to repo root) + test_script_directory: tests + + # Skript version or ref (tag, branch, or commit) + skript_repo_ref: copy-dir-resources # 2.13.2 + + # directory containing addon/plugin jars (relative to repo root) + extra_plugins_directory: build/libs + + run_vanilla_tests: false diff --git a/docs/testframework.md b/docs/testframework.md index f7c3c4e..f87560d 100644 --- a/docs/testframework.md +++ b/docs/testframework.md @@ -1,28 +1,60 @@ -# Skript Testing Framework +Below is a **single, unified Markdown document** that combines both inputs, removes duplication, and reconciles terminology while preserving all technical detail. Structure has been normalized so it reads as one authoritative specification rather than two overlapping documents. -## Purpose +--- + +# Skript Runtime Testing Framework + +## Overview + +This document describes a **self-contained runtime testing framework for Skript**. The framework replicates much of Skript’s internal development test suite while extending it with runtime-safe execution, reflection-based inspection, and deterministic event-driven control. + +Unlike Skript’s native internal tests, this framework: + +* Runs entirely at runtime +* Is safe for production servers +* Supports both **automatic (autorun)** and **manual** execution +* Tracks failures centrally with optional console suppression + +All framework state is stored under the `-test.sk::*` namespace. + +--- + +## Design Goals + +The framework is intentionally minimal and predictable, prioritizing correctness and isolation over flexibility. + +It is designed to: + +* Allow tests to be written directly in `.sk` files +* Achieve functional parity with Skript’s internal test actions where feasible +* Enable meta-testing of Skript syntax and parser behavior +* Support fail-fast behavior with optional non-halting assertions +* Prevent state leakage between tests -This module implements a lightweight, self-contained **testing framework for Skript**. It allows scripts to define tests, automatically discover them, execute them deterministically, and report failures with precise diagnostics. +--- -The framework is designed to: +## Feature Parity with Skript’s Native Test Suite -* Run entirely inside Skript -* Avoid external dependencies -* Support both manual and automatic test execution -* Fail fast while still allowing optional non-halting assertions +| Feature | Status | Description | +| ------------------------- | ------------ | ----------------------------------------------------- | +| **Test structure** | Achieved | `test %string%` mirrors native test declarations | +| **Conditional execution** | Achieved | `when ` skips tests dynamically | +| **Assertions** | Achieved | `assert ` and `assert to fail` | +| **Explicit failure** | Achieved | `fail test` effect | +| **Parser inspection** | Experimental | Parse sections and log capture | --- ## High-Level Architecture -The framework is built around four core ideas: +The framework is built around four core principles: -1. **Tests are custom events** identified by name -2. **Tests are registered implicitly** during script parsing -3. **Execution is event-driven**, not inline -4. **Failures are tracked centrally** and reported after execution +1. **Tests are custom events** +2. **Tests are registered implicitly at parse time** +3. **Execution is event-driven, not inline** +4. **Failures are tracked centrally per test** -All internal state is stored under the `-test.sk::*` variable namespace. +Each test executes inside a dedicated `skriptTest` event context. --- @@ -31,73 +63,75 @@ All internal state is stored under the `-test.sk::*` variable namespace. ### Syntax ```skript -test "": +test "" [when ]: ``` -* `` must be unique **within the script**. -* The test body runs inside the `skriptTest` custom event. -* The event provides two event-values: +* `` must be unique **within the script** +* Tests are registered automatically when the script is parsed +* The optional `when` condition is evaluated immediately before execution - * `string` – the fully-qualified test identifier - * `boolean` – whether the test is running in autorun mode +### Event Context -### Example +Inside a test, the framework provides: -```skript -test "basic arithmetic": - assert true: 2 + 2 = 4 -``` +* **`event-string` / `event-test`** + Fully-qualified test identifier: + + ``` +