Skip to content

Commit

Permalink
Add test script setup (#96)
Browse files Browse the repository at this point in the history
* Add test job

* Add ExprJavaCall.sk test

* Modify test job

* Add build dependency to test task

* Fix test script error

* Let's see how enabling vanilla tests goes

* Only run push action on 2.x branch

* Fix skript-reflect breaking the vanilla "fire visual effect comparison" test
  • Loading branch information
Pikachu920 authored Feb 7, 2024
1 parent 259b7f2 commit 7c3cbfd
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
36 changes: 27 additions & 9 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Build and test

name: Java CI with Gradle

on: [push]
on:
push:
branches:
- 2.x
pull_request:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Checkout repo
uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
Expand All @@ -20,6 +20,24 @@ jobs:
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- uses: actions/upload-artifact@master
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
path: build/libs/*.jar
test:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: extra-plugins/
merge-multiple: true
- name: Run tests
uses: SkriptLang/[email protected]
with:
test_script_directory: src/test/scripts
skript_repo_ref: 2.8.2
extra_plugins_directory: extra-plugins/
12 changes: 11 additions & 1 deletion src/main/java/com/btk5h/skriptmirror/SkriptMirror.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import ch.njol.skript.Skript;
import ch.njol.skript.SkriptAddon;
import ch.njol.skript.lang.parser.ParserInstance;
import ch.njol.skript.classes.ClassInfo;
import ch.njol.skript.registrations.Classes;
import ch.njol.skript.util.Version;
import org.skriptlang.reflect.syntax.condition.elements.StructCustomCondition;
import org.skriptlang.reflect.syntax.effect.elements.StructCustomEffect;
Expand All @@ -14,6 +15,8 @@
import com.btk5h.skriptmirror.util.SkriptReflection;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import org.skriptlang.skript.lang.comparator.Comparators;
import org.skriptlang.skript.lang.comparator.Relation;

import java.io.IOException;
import java.nio.file.Path;
Expand Down Expand Up @@ -64,6 +67,13 @@ public void onEnable() {
e.printStackTrace();
}

Comparators.registerComparator(ClassInfo.class, JavaType.class, (classInfo, javaType) -> {
ClassInfo<?> matchingClassInfo = Classes.getExactClassInfo(javaType.getJavaClass());
if (matchingClassInfo == null)
return Relation.NOT_EQUAL;
return Comparators.compare(classInfo, matchingClassInfo);
});

ParseOrderWorkarounds.reorderSyntax();

// Disable *all* and/or warnings
Expand Down
2 changes: 2 additions & 0 deletions src/test/scripts/ExprJavaCall.sk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test "ExprJavaCall":
assert "123".length() is 3 with "incorrect String##length return"

0 comments on commit 7c3cbfd

Please sign in to comment.