Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds back the JUnit testing system #4979

Merged
merged 48 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
248eb36
Add a proper JUnit testing system
TheLimeGlass Jul 27, 2022
f23fb68
Merge branch 'master' into feature/junit
TheLimeGlass Aug 3, 2022
0dce34c
Merge branch 'master' into feature/junit
TheLimeGlass Aug 16, 2022
1716046
Fix Java 8
TheLimeGlass Aug 17, 2022
9c362c6
Make test jar compile with different dependencies
TheLimeGlass Aug 17, 2022
f240e78
Remove un-needed force dependency
TheLimeGlass Aug 17, 2022
4203497
Merge branch 'master' into feature/junit
TheLimeGlass Aug 17, 2022
d09f316
Use JUnit 4
TheLimeGlass Aug 17, 2022
429e751
Merge branch 'feature/junit' of https://github.com/SkriptLang/Skript …
TheLimeGlass Aug 17, 2022
5d51736
Merge branch 'master' into feature/junit
TheLimeGlass Oct 15, 2022
b520d45
Merge branch 'master' into feature/junit
TheLimeGlass Dec 28, 2022
f033906
Finish JUnit
TheLimeGlass Dec 28, 2022
35297db
Add JUnit to Skript script support
TheLimeGlass Dec 28, 2022
fe5af2b
licenseFormat
TheLimeGlass Dec 28, 2022
109c113
Nullify expression in EffAssert
TheLimeGlass Dec 28, 2022
4beacb1
Remove debug message
TheLimeGlass Dec 28, 2022
4a22767
Not all versions have adventure api
TheLimeGlass Dec 28, 2022
9bd2fe4
Move test_runners into gradle build cache
TheLimeGlass Dec 28, 2022
fbd6b29
Add directory location info
TheLimeGlass Dec 28, 2022
85cd30f
Update the new test_runner directory in gitignore
TheLimeGlass Dec 30, 2022
ee07a59
Reduce the time of the simple junit test and add block utility method
TheLimeGlass Dec 30, 2022
0416315
Apply changes
TheLimeGlass Jan 11, 2023
02d9428
Version checking gamerules
TheLimeGlass Jan 11, 2023
ba24b4e
proper toString
TheLimeGlass Jan 11, 2023
c37e7f3
Remove un-used imports
TheLimeGlass Jan 11, 2023
4351d2d
Changes
TheLimeGlass Jan 11, 2023
c7c1123
Merge branch 'master' into feature/junit
TheLimeGlass Jan 14, 2023
1bb806c
Update .gitignore
TheLimeGlass Jan 26, 2023
b10a005
Update src/main/java/ch/njol/skript/test/runner/ExprJUnitTest.java
TheLimeGlass Jan 26, 2023
db954be
Address changes
TheLimeGlass Jan 26, 2023
49c694c
Add gradle task descriptions
TheLimeGlass Jan 26, 2023
7669875
Apply changes
TheLimeGlass Jan 27, 2023
8d2a36a
Update master
TheLimeGlass Jan 27, 2023
1367a0d
Apply changes
TheLimeGlass Feb 14, 2023
70787c6
Apply changes
TheLimeGlass Feb 14, 2023
024e3b7
Apply changes
TheLimeGlass Feb 14, 2023
eb9d68b
Apply changes
TheLimeGlass Feb 14, 2023
333bb03
Merge branch 'master' into feature/junit
TheLimeGlass Feb 14, 2023
9bcb42d
Fix Pikachu's method exists
Pikachu920 Feb 4, 2023
33da2cf
Merge branch 'master' into feature/junit
TheLimeGlass Feb 16, 2023
f603a73
Add package infos
TheLimeGlass Feb 23, 2023
8d3230d
Merge branch 'feature/junit' of https://github.com/SkriptLang/Skript …
TheLimeGlass Feb 23, 2023
f906ab6
Fix skript dev mode not working
TheLimeGlass Feb 23, 2023
e46a677
Merge branch 'master' into feature/junit
TheLimeGlass Feb 23, 2023
93e336e
license
TheLimeGlass Feb 23, 2023
269c39d
Merge branch 'master' of https://github.com/SkriptLang/Skript into fe…
TheLimeGlass Feb 23, 2023
eaa9433
Merge branch 'feature/junit' of https://github.com/SkriptLang/Skript …
TheLimeGlass Feb 23, 2023
3e80df1
Merge branch 'master' into feature/junit
TheLimeGlass Mar 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/junit-17-builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: JUnit (MC 1.17+)

on:
push:
branches:
- master
- 'dev/**'
pull_request:

jobs:
build:
if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build Skript and run JUnit
run: ./gradlew clean JUnitJava17
27 changes: 27 additions & 0 deletions .github/workflows/junit-8-builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: JUnit (MC 1.13-1.16)

on:
push:
branches:
- master
- 'dev/**'
pull_request:

jobs:
build:
if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build Skript and run JUnit
run: ./gradlew clean JUnitJava8
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,6 @@ gradle-app.setting

# End of https://www.toptal.com/developers/gitignore/api/intellij+all,gradle,java,eclipse,git

# Skript test runners
# TODO remove this in the future after some time since https://github.com/SkriptLang/Skript/pull/4979
# This ensures developers don't upload their old existing test_runners/ folder.
test_runners/
80 changes: 56 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ plugins {
id 'java'
}

configurations {
testImplementation.extendsFrom testShadow
}

allprojects {
repositories {
mavenCentral()
Expand All @@ -31,7 +35,11 @@ dependencies {
implementation group: 'net.milkbowl.vault', name: 'Vault', version: '1.7.1', {
exclude group: 'org.bstats', module: 'bstats-bukkit'
}

implementation fileTree(dir: 'lib', include: '*.jar')

testShadow group: 'junit', name: 'junit', version: '4.12'
testShadow group: 'org.easymock', name: 'easymock', version: '4.2'
}

compileJava.options.encoding = 'UTF-8'
Expand All @@ -47,6 +55,12 @@ task checkAliases {
}
}

task testJar(type: ShadowJar) {
dependsOn(compileTestJava, licenseTest)
archiveName 'Skript-JUnit.jar'
from sourceSets.test.output, sourceSets.main.output, project.configurations.testShadow
}

task jar(overwrite: true, type: ShadowJar) {
dependsOn checkAliases
archiveName jarName ? 'Skript.jar' : jarName
Expand All @@ -64,7 +78,7 @@ task relocateShadowJar(type: ConfigureShadowRelocation) {

task sourceJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = "sources"
archiveClassifier = 'sources'
}

tasks.withType(ShadowJar) {
Expand Down Expand Up @@ -106,8 +120,8 @@ processResources {
publishing {
publications {
maven(MavenPublication) {
groupId "com.github.SkriptLang"
artifactId "Skript"
groupId 'com.github.SkriptLang'
artifactId 'Skript'
version project.version
artifact sourceJar
artifact tasks.jar
Expand All @@ -116,11 +130,11 @@ publishing {

repositories {
maven {
name = "repo"
url = "https://repo.skriptlang.org/releases"
name = 'repo'
url = 'https://repo.skriptlang.org/releases'
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
username = System.getenv('MAVEN_USERNAME')
password = System.getenv('MAVEN_PASSWORD')
}
}
}
Expand Down Expand Up @@ -167,9 +181,15 @@ tasks.register('testNaming') {
}

// Create a test task with given name, environments dir/file, dev mode and java version.
void createTestTask(String name, String environments, boolean devMode, int javaVersion, boolean genDocs) {
void createTestTask(String name, String desc, String environment, boolean devMode, int javaVersion, boolean genDocs, boolean junit) {
tasks.register(name, JavaExec) {
dependsOn nightlyRelease, testNaming
description = desc;
dependsOn licenseTest
if (junit) {
dependsOn testJar
} else {
dependsOn nightlyRelease, testNaming
}
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(javaVersion)
}
Expand All @@ -178,18 +198,19 @@ void createTestTask(String name, String environments, boolean devMode, int javaV
}
group = 'execution'
classpath = files([
'build' + File.separator + 'libs' + File.separator + 'Skript-nightly.jar',
'build' + File.separator + 'libs' + File.separator + (junit ? 'Skript-JUnit.jar' : 'Skript-nightly.jar'),
TheLimeGlass marked this conversation as resolved.
Show resolved Hide resolved
project.configurations.runtimeClasspath.find { it.name.startsWith('gson') },
sourceSets.main.runtimeClasspath
])
main = 'ch.njol.skript.tests.platform.PlatformMain'
main = 'ch.njol.skript.test.platform.PlatformMain'
args = [
'test_runners',
'src/test/skript/tests',
'build/test_runners',
junit ? 'src/test/skript/tests/junit' : 'src/test/skript/tests',
'src/test/resources/runner_data',
environments,
environment,
devMode,
genDocs
genDocs,
junit
]
}
}
Expand All @@ -199,20 +220,31 @@ def latestJava = 17
def oldestJava = 8

tasks.withType(JavaCompile).configureEach {
options.compilerArgs += ["-source", "" + oldestJava, "-target", "" + oldestJava]
options.compilerArgs += ['-source', '' + oldestJava, '-target', '' + oldestJava]
}

createTestTask('JUnitQuick', 'Runs JUnit tests on one environment being the latest supported Java and Minecraft.', 'src/test/skript/environments/' + latestEnv, false, latestJava, false, true)
createTestTask('JUnitJava17', 'Runs JUnit tests on all Java 17 environments.', 'src/test/skript/environments/java17', false, latestJava, false, true)
TheLimeGlass marked this conversation as resolved.
Show resolved Hide resolved
createTestTask('JUnitJava8', 'Runs JUnit tests on all Java 8 environments.', 'src/test/skript/environments/java8', false, oldestJava, false, true)
tasks.register('JUnit') {
description = 'Runs JUnit tests on all environments.'
dependsOn JUnitJava8, JUnitJava17
}

// Register different Skript testing tasks
createTestTask('quickTest', 'src/test/skript/environments/' + latestEnv, false, latestJava, false)
createTestTask('skriptTestJava17', 'src/test/skript/environments/java17', false, latestJava, false)
createTestTask('skriptTestJava8', 'src/test/skript/environments/java8', false, oldestJava, false)
createTestTask('skriptTestDev', 'src/test/skript/environments/' + (project.property('testEnv') == null
createTestTask('quickTest', 'Runs tests on one environment being the latest supported Java and Minecraft.', 'src/test/skript/environments/' + latestEnv, false, latestJava, false, false)
createTestTask('skriptTestJava17', 'Runs tests on all Java 17 environments.', 'src/test/skript/environments/java17', false, latestJava, false, false)
createTestTask('skriptTestJava8', 'Runs tests on all Java 8 environments.', 'src/test/skript/environments/java8', false, oldestJava, false, false)
createTestTask('skriptTestDev', 'Runs testing server and uses \'system.in\' for command input, stop server to finish.', 'src/test/skript/environments/' + (project.property('testEnv') == null
? latestEnv : project.property('testEnv') + '.json'), true, Integer.parseInt(project.property('testEnvJavaVersion') == null
? latestJava : project.property('testEnvJavaVersion')), false)
tasks.register('skriptTest') {dependsOn skriptTestJava8, skriptTestJava17}
createTestTask('genDocs', 'src/test/skript/environments/' + (project.property('testEnv') == null
? latestJava : project.property('testEnvJavaVersion')), false, false)
tasks.register('skriptTest') {
description = 'Runs tests on all environments.'
dependsOn skriptTestJava8, skriptTestJava17
}
createTestTask('genDocs', 'Generates the Skript documentation website html files.', 'src/test/skript/environments/' + (project.property('testEnv') == null
? latestEnv : project.property('testEnv') + '.json'), false, Integer.parseInt(project.property('testEnvJavaVersion') == null
? latestJava : project.property('testEnvJavaVersion')), true)
? latestJava : project.property('testEnvJavaVersion')), true, false)

// Build flavor configurations
task githubResources(type: ProcessResources) {
Expand Down
Loading