diff --git a/Kotlin/README.md b/Kotlin/README.md new file mode 100644 index 00000000..deaecf00 --- /dev/null +++ b/Kotlin/README.md @@ -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). + diff --git a/Kotlin/build.gradle.kts b/Kotlin/build.gradle.kts index b89dcf96..4d392304 100644 --- a/Kotlin/build.gradle.kts +++ b/Kotlin/build.gradle.kts @@ -2,6 +2,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { kotlin("jvm") version "1.9.10" + application } group = "com.gildedrose" @@ -32,3 +33,7 @@ tasks.withType().configureEach { java { targetCompatibility = JavaVersion.VERSION_1_8 } + +application { + mainClass.set("com.gildedrose.TexttestFixtureKt") +} diff --git a/Kotlin/src/test/kotlin/com/gildedrose/TexttestFixture.kt b/Kotlin/src/main/kotlin/com/gildedrose/TexttestFixture.kt similarity index 88% rename from Kotlin/src/test/kotlin/com/gildedrose/TexttestFixture.kt rename to Kotlin/src/main/kotlin/com/gildedrose/TexttestFixture.kt index a87a0d13..72f27b9e 100644 --- a/Kotlin/src/test/kotlin/com/gildedrose/TexttestFixture.kt +++ b/Kotlin/src/main/kotlin/com/gildedrose/TexttestFixture.kt @@ -4,7 +4,8 @@ fun main(args: Array) { 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("Elixir of the Mongoose", 5, 7), // Item("Sulfuras, Hand of Ragnaros", 0, 80), // @@ -13,7 +14,8 @@ fun main(args: Array) { Item("Backstage passes to a TAFKAL80ETC concert", 10, 49), Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), // this conjured item does not work properly yet - Item("Conjured Mana Cake", 3, 6)) + Item("Conjured Mana Cake", 3, 6) + ) val app = GildedRose(items) diff --git a/Kotlin/texttest_rig.py b/Kotlin/texttest_rig.py new file mode 100644 index 00000000..b75e019d --- /dev/null +++ b/Kotlin/texttest_rig.py @@ -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) diff --git a/texttests/config.gr b/texttests/config.gr index 9e2caea5..9beda74b 100755 --- a/texttests/config.gr +++ b/texttests/config.gr @@ -20,6 +20,10 @@ diff_program:meld #interpreter:java # 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 #executable:${TEXTTEST_HOME}/ruby/texttest_fixture.rb #interpreter:ruby