Skip to content

Commit cf66d8c

Browse files
committed
Initial commit
0 parents  commit cf66d8c

File tree

17 files changed

+642
-0
lines changed

17 files changed

+642
-0
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
root = true
2+
3+
[*]
4+
indent_style = tab
5+
indent_size = 4
6+
tab_width = 4
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
10+
[*.{yml,yaml}]
11+
indent_style = space
12+
indent_size = 2
13+
tab_width = 2

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @slimefun/code-reviewers

.github/workflows/build.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Java CI
2+
3+
on: push
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
build:
10+
11+
name: Maven build
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v3
17+
18+
- name: Set up JDK 17
19+
uses: actions/[email protected]
20+
with:
21+
distribution: 'adopt'
22+
java-version: '17'
23+
java-package: jdk
24+
architecture: x64
25+
26+
- name: Cache Maven packages
27+
uses: actions/cache@v3
28+
with:
29+
path: ~/.m2
30+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
31+
restore-keys: ${{ runner.os }}-m2
32+
33+
- name: Build with Maven
34+
run: mvn package
35+
36+
- name: Upload
37+
if: ${{ github.repository_owner == 'Slimefun' && github.ref == 'refS/heads/main' }}
38+
run: |
39+
curl -v -X POST \
40+
-H 'Authorization: ${{ secrets.PUBLISH_TOKEN }}' \
41+
-H "X-Checksum: $(sha256sum target/e2e-test-plugin.jar | awk '{print $1}')" \
42+
--data-binary '@target/e2e-test-plugin.jar' \
43+
https://preview-builds.walshy.dev/upload/e2e-tester/main/latest

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
target/
2+
.vscode/
3+
depe

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Slimefun
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# e2e-tester
2+
3+
This repo holds the E2E tester plugin used in [Slimefun](https://github.com/Slimefun/Slimefun4).
4+
5+
This plugin is a work in progress and is still very early days. See [issues](https://github.com/Slimefun/e2e-tester/issues) for work still needing to be done. We would love contributions!

pom.xml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
6+
<modelVersion>4.0.0</modelVersion>
7+
<groupId>com.github.slimefun</groupId>
8+
<artifactId>e2e-test-plugin</artifactId>
9+
10+
<version>0.1.0</version>
11+
<packaging>jar</packaging>
12+
13+
<properties>
14+
<!-- UTF-8 is our standard encoding for source files -->
15+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16+
17+
<!-- Target Java 16 -->
18+
<maven.compiler.source>16</maven.compiler.source>
19+
<maven.compiler.target>16</maven.compiler.target>
20+
21+
<!-- Spigot properties -->
22+
<spigot.version>1.16.5</spigot.version>
23+
<spigot.javadocs>https://hub.spigotmc.org/javadocs/spigot/</spigot.javadocs>
24+
</properties>
25+
26+
<licenses>
27+
<license>
28+
<name>MIT</name>
29+
<url>https://github.com/Slimefun/e2e-test-plugin/blob/main/LICENSE</url>
30+
<distribution>repo</distribution>
31+
</license>
32+
</licenses>
33+
34+
<repositories>
35+
<repository>
36+
<!-- Spigot-API -->
37+
<id>spigot-repo</id>
38+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
39+
</repository>
40+
</repositories>
41+
42+
<dependencies>
43+
<!-- Hard dependencies -->
44+
<dependency>
45+
<groupId>org.spigotmc</groupId>
46+
<artifactId>spigot-api</artifactId>
47+
<version>${spigot.version}-R0.1-SNAPSHOT</version>
48+
<scope>provided</scope>
49+
</dependency>
50+
51+
<!-- Development dependencies -->
52+
<dependency>
53+
<groupId>com.google.code.findbugs</groupId>
54+
<artifactId>jsr305</artifactId>
55+
<version>3.0.2</version>
56+
<scope>provided</scope>
57+
</dependency>
58+
59+
<!-- SHaded dependencies -->
60+
<dependency>
61+
<groupId>org.reflections</groupId>
62+
<artifactId>reflections</artifactId>
63+
<version>0.10.2</version>
64+
</dependency>
65+
</dependencies>
66+
67+
<build>
68+
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
69+
<defaultGoal>clean package</defaultGoal>
70+
<finalName>${project.name}</finalName>
71+
72+
<plugins>
73+
<plugin>
74+
<groupId>org.apache.maven.plugins</groupId>
75+
<artifactId>maven-compiler-plugin</artifactId>
76+
<version>3.11.0</version>
77+
</plugin>
78+
79+
<plugin>
80+
<groupId>org.apache.maven.plugins</groupId>
81+
<artifactId>maven-shade-plugin</artifactId>
82+
<version>3.5.0</version>
83+
84+
<configuration>
85+
<createDependencyReducedPom>false</createDependencyReducedPom>
86+
<filters>
87+
<filter>
88+
<artifact>*:*</artifact>
89+
<excludes>
90+
<exclude>META-INF/*</exclude>
91+
</excludes>
92+
</filter>
93+
</filters>
94+
</configuration>
95+
96+
<executions>
97+
<execution>
98+
<phase>package</phase>
99+
<goals>
100+
<goal>shade</goal>
101+
</goals>
102+
</execution>
103+
</executions>
104+
</plugin>
105+
</plugins>
106+
107+
<resources>
108+
<resource>
109+
<directory>${basedir}/src/main/resources</directory>
110+
<filtering>true</filtering>
111+
</resource>
112+
113+
<resource>
114+
<directory>${basedir}</directory>
115+
<filtering>false</filtering>
116+
117+
<includes>
118+
<include>LICENSE</include>
119+
</includes>
120+
</resource>
121+
</resources>
122+
</build>
123+
</project>

src/main/java/io/github/.DS_Store

6 KB
Binary file not shown.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package io.github.slimefun.e2etester;
2+
3+
import org.bukkit.Bukkit;
4+
import org.bukkit.plugin.java.JavaPlugin;
5+
6+
import io.github.slimefun.e2etester.framework.TestFramework;
7+
8+
public class E2ETester extends JavaPlugin {
9+
10+
@Override
11+
public void onEnable() {
12+
final TestFramework framework = TestFramework.newTestRun();
13+
14+
// Wait a second for any startup stuff to be ran
15+
Bukkit.getScheduler().runTaskLater(this, () -> {
16+
framework.runTests("io.github.slimefun.e2etester.tests");
17+
}, 20);
18+
}
19+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package io.github.slimefun.e2etester.framework;
2+
3+
import java.util.function.Predicate;
4+
5+
import org.bukkit.Bukkit;
6+
import org.bukkit.command.CommandException;
7+
8+
import io.github.slimefun.e2etester.framework.exceptions.TestFailException;
9+
import io.github.slimefun.e2etester.framework.mock.MockConsoleSender;
10+
11+
public class Assert {
12+
13+
public static void isTrue(boolean expression) {
14+
if (!expression) {
15+
throw new TestFailException("isTrue expected true but got false");
16+
}
17+
}
18+
19+
public static void runConsoleCommand(String command, Predicate<String> output) {
20+
try {
21+
final MockConsoleSender sender = new MockConsoleSender();
22+
23+
final boolean commandExists = Bukkit.dispatchCommand(sender, command);
24+
if (!commandExists) {
25+
throw new TestFailException("Comamnd '" + command + "' does not exist!");
26+
}
27+
28+
final String commandOutput = String.join("\n", sender.getMessages());
29+
if (!output.test(commandOutput)) {
30+
throw new TestFailException("Output was not as expected! Output: " + commandOutput);
31+
}
32+
} catch(CommandException e) {
33+
throw new TestFailException("Command '" + command + "' threw an unexpected exception!", e);
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)