Skip to content

Commit 7c3cbfd

Browse files
authored
Add test script setup (#96)
* 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
1 parent 259b7f2 commit 7c3cbfd

File tree

3 files changed

+40
-10
lines changed

3 files changed

+40
-10
lines changed

.github/workflows/gradle.yml

+27-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
# This workflow will build a Java project with Gradle
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
1+
name: Build and test
32

4-
name: Java CI with Gradle
5-
6-
on: [push]
3+
on:
4+
push:
5+
branches:
6+
- 2.x
7+
pull_request:
78

89
jobs:
910
build:
10-
1111
runs-on: ubuntu-latest
12-
1312
steps:
14-
- uses: actions/checkout@v2
13+
- name: Checkout repo
14+
uses: actions/checkout@v2
1515
- name: Set up JDK 1.8
1616
uses: actions/setup-java@v1
1717
with:
@@ -20,6 +20,24 @@ jobs:
2020
run: chmod +x gradlew
2121
- name: Build with Gradle
2222
run: ./gradlew build
23-
- uses: actions/upload-artifact@master
23+
- name: Upload artifacts
24+
uses: actions/upload-artifact@master
2425
with:
2526
path: build/libs/*.jar
27+
test:
28+
runs-on: ubuntu-latest
29+
needs: [build]
30+
steps:
31+
- name: Checkout repo
32+
uses: actions/checkout@v2
33+
- name: Download artifacts
34+
uses: actions/download-artifact@v4
35+
with:
36+
path: extra-plugins/
37+
merge-multiple: true
38+
- name: Run tests
39+
uses: SkriptLang/[email protected]
40+
with:
41+
test_script_directory: src/test/scripts
42+
skript_repo_ref: 2.8.2
43+
extra_plugins_directory: extra-plugins/

src/main/java/com/btk5h/skriptmirror/SkriptMirror.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import ch.njol.skript.Skript;
44
import ch.njol.skript.SkriptAddon;
5-
import ch.njol.skript.lang.parser.ParserInstance;
5+
import ch.njol.skript.classes.ClassInfo;
6+
import ch.njol.skript.registrations.Classes;
67
import ch.njol.skript.util.Version;
78
import org.skriptlang.reflect.syntax.condition.elements.StructCustomCondition;
89
import org.skriptlang.reflect.syntax.effect.elements.StructCustomEffect;
@@ -14,6 +15,8 @@
1415
import com.btk5h.skriptmirror.util.SkriptReflection;
1516
import org.bukkit.Bukkit;
1617
import org.bukkit.plugin.java.JavaPlugin;
18+
import org.skriptlang.skript.lang.comparator.Comparators;
19+
import org.skriptlang.skript.lang.comparator.Relation;
1720

1821
import java.io.IOException;
1922
import java.nio.file.Path;
@@ -64,6 +67,13 @@ public void onEnable() {
6467
e.printStackTrace();
6568
}
6669

70+
Comparators.registerComparator(ClassInfo.class, JavaType.class, (classInfo, javaType) -> {
71+
ClassInfo<?> matchingClassInfo = Classes.getExactClassInfo(javaType.getJavaClass());
72+
if (matchingClassInfo == null)
73+
return Relation.NOT_EQUAL;
74+
return Comparators.compare(classInfo, matchingClassInfo);
75+
});
76+
6777
ParseOrderWorkarounds.reorderSyntax();
6878

6979
// Disable *all* and/or warnings

src/test/scripts/ExprJavaCall.sk

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
test "ExprJavaCall":
2+
assert "123".length() is 3 with "incorrect String##length return"

0 commit comments

Comments
 (0)