Skip to content

Commit

Permalink
Add toml-test test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
TheElectronWill committed May 25, 2024
1 parent 54a6841 commit 1ef9fea
Show file tree
Hide file tree
Showing 7 changed files with 445 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@
*.jar binary
*.png binary

# Exclude toml-test submodule from Github language statistics.
# See https://github.com/github-linguist/linguist/blob/master/docs/overrides.md
test-multiple/src/test/resources/toml-test/* linguist-vendored
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "toml/src/test/resources/toml-test"]
path = test-multiple/src/test/resources/toml-test
url = [email protected]:toml-lang/toml-test.git
[submodule "test-multiple/src/test/resources/toml-test"]
path = test-multiple/src/test/resources/toml-test
url = [email protected]:toml-lang/toml-test.git
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,10 @@ Execution failed for task ':japicmp'.
See failure report at file:///home/guillaume/Documents/Projets/night-config/build/reports/japicmp.html
```

## Multi-module test suite

The Gradle module `test-multiple` implements tests that require multiple NightConfig modules.

In particular, it executes the tests of [the language agnostic TOML test suite](https://github.com/toml-lang/toml-test).
To avoid a test dependency on another programming language, we don't run the provided binary, but rather reimplement the tests using the same resources (valid and invalid TOML files).
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ include("toml")
include("yaml")

include("test-shared")
include("test-multiple")
36 changes: 36 additions & 0 deletions test-multiple/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
plugins {
`java-library`
}

repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}

dependencies {
api(project(":toml"))
api(project(":json"))
testImplementation(project(":test-shared"))
}

// Use Java 11.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}

// Get JUnit5 version from `libs.versions.toml`.
val versionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs")
val junitVersion = versionCatalog.findVersion("junit5")
.orElseThrow{ RuntimeException("missing version in libs.versions.toml: junit5") }
.getRequiredVersion()

// Use JUnit5.
testing {
suites {
val test by getting(JvmTestSuite::class) {
useJUnitJupiter(junitVersion)
}
}
}
Loading

0 comments on commit 1ef9fea

Please sign in to comment.