Fixed texttests for Kotlin

This commit is contained in:
emily 2023-11-03 16:11:26 +01:00
parent c50c330c78
commit 8588b6fcc4
5 changed files with 50 additions and 2 deletions

23
Kotlin/README.md Normal file
View File

@ -0,0 +1,23 @@
# Gilded Rose starting position in Kotlin
## Run the Text Fixture from Command-Line
```
./gradlew -q text
```
### Specify Number of Days
For e.g. 10 days:
```
./gradlew run --args 10
```
You should make sure the gradle commands shown above work when you execute them in a terminal before trying to use TextTest (see below).
## Run the TextTest approval test that comes with this project
There are instructions in the [TextTest Readme](../texttests/README.md) for setting up TextTest. What's unusual for the Java version is there are two executables listed in [config.gr](../texttests/config.gr) for Java. One uses Gradle wrapped in a python script, the other relies on your CLASSPATH being set correctly in [environment.gr](../texttests/environment.gr).

View File

@ -2,6 +2,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins { plugins {
kotlin("jvm") version "1.9.10" kotlin("jvm") version "1.9.10"
application
} }
group = "com.gildedrose" group = "com.gildedrose"
@ -32,3 +33,7 @@ tasks.withType<KotlinCompile>().configureEach {
java { java {
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
} }
application {
mainClass.set("com.gildedrose.TexttestFixtureKt")
}

View File

@ -4,7 +4,8 @@ fun main(args: Array<String>) {
println("OMGHAI!") println("OMGHAI!")
val items = listOf(Item("+5 Dexterity Vest", 10, 20), // val items = listOf(
Item("+5 Dexterity Vest", 10, 20), //
Item("Aged Brie", 2, 0), // Item("Aged Brie", 2, 0), //
Item("Elixir of the Mongoose", 5, 7), // Item("Elixir of the Mongoose", 5, 7), //
Item("Sulfuras, Hand of Ragnaros", 0, 80), // Item("Sulfuras, Hand of Ragnaros", 0, 80), //
@ -13,7 +14,8 @@ fun main(args: Array<String>) {
Item("Backstage passes to a TAFKAL80ETC concert", 10, 49), Item("Backstage passes to a TAFKAL80ETC concert", 10, 49),
Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), Item("Backstage passes to a TAFKAL80ETC concert", 5, 49),
// this conjured item does not work properly yet // this conjured item does not work properly yet
Item("Conjured Mana Cake", 3, 6)) Item("Conjured Mana Cake", 3, 6)
)
val app = GildedRose(items) val app = GildedRose(items)

14
Kotlin/texttest_rig.py Normal file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env python
"""
This script uses Gradle to execute the TexttestFixture.
It is designed to be used by TextTest and specified in the file 'texttests/config.gr' in this repo.
It is more convenient for TextTest to use since Gradle needs
several arguments in addition to the one the TextTest fixture needs.
"""
import os
import subprocess
import sys
args = " ".join(sys.argv[1:])
TEXTTEST_HOME = os.environ.get("TEXTTEST_HOME", os.getcwd())
subprocess.run(f"{TEXTTEST_HOME}/Kotlin/gradlew -p {TEXTTEST_HOME}/Kotlin -q run --args {args}", shell=True)

View File

@ -20,6 +20,10 @@ diff_program:meld
#interpreter:java #interpreter:java
# note you'll also need to update the file environment.gr with your classpath if you keep your classfiles somewhere unusual # note you'll also need to update the file environment.gr with your classpath if you keep your classfiles somewhere unusual
# Settings for the Kotlin version using Gradle wrapped in a python script
#executable:${TEXTTEST_HOME}/Kotlin/texttest_rig.py
#interpreter:python
# Settings for the Ruby version # Settings for the Ruby version
#executable:${TEXTTEST_HOME}/ruby/texttest_fixture.rb #executable:${TEXTTEST_HOME}/ruby/texttest_fixture.rb
#interpreter:ruby #interpreter:ruby