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

[js] Fix JS tests #209

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apache-commons = "4.0-beta1"
aws = "1.12.761"
kmath = "0.3.1"
kotlin-atomicfu = "0.23.2"
kotlin-coroutines = "1.8.0-RC"
kotlin-coroutines = "1.9.0"
multik = "0.2.2"
okio = "3.6.0"
onnxruntime = "1.17.0.patched-1"
Expand Down Expand Up @@ -40,3 +40,5 @@ slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j" }
wire-runtime = { module = "com.squareup.wire:wire-runtime", version.ref = "wire" }
fastutil-core = { module = "it.unimi.dsi:fastutil-core", version.ref = "fastutil" }

kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlin-coroutines" }
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sealed class Squeeze(name: String, info: OperatorInfo, attributes: Map<String, A

operator fun invoke(name: String, version: Int?, attributes: Map<String, Attribute<Any>>, inputs: List<String>, outputs: List<String>) = when (version ?: DEFAULT_VERSION.sinceVersion) {
in SqueezeVer1.VERSION.asRange() -> SqueezeVer1(name, attributes, inputs, outputs)
else -> error("Unsupported version of Constant operator: $version")
else -> error("Unsupported version of Squeeze operator: $version")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ class SqueezeTest {
private fun getTargetPath(dirName: String) = "squeeze/$dirName/"

@Test
fun test_squeeze() = TestRunner.runTest {
TFJSAccuracyRunner.runFromResources(getTargetPath("test_squeeze"))
fun test_v1_squeeze() = TestRunner.runTest {
TFJSAccuracyRunner.runFromResources(getTargetPath("v1/test_squeeze"))
}

@Test
fun test_squeeze_with_negative_axes() = TestRunner.runTest {
TFJSAccuracyRunner.runFromResources(getTargetPath("test_squeeze_negative_axes"))
fun test_v1_squeeze_with_negative_axes() = TestRunner.runTest {
TFJSAccuracyRunner.runFromResources(getTargetPath("v1/test_squeeze_negative_axes"))
}
}
1 change: 1 addition & 0 deletions utils/utils-testing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ kotlin {
api(kotlin("test-annotations-common"))

api(libs.kinference.primitives.annotations)
api(libs.kotlinx.coroutines.test)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
package io.kinference.utils

import kotlinx.coroutines.CoroutineScope
import io.kinference.utils.time.Timer
import kotlinx.coroutines.*
import kotlinx.coroutines.test.TestResult
import kotlin.time.Duration
import kotlin.time.Duration.Companion.minutes

expect object TestRunner {
fun runTest(platform: Platform? = null, block: suspend CoroutineScope.() -> Unit)
object TestRunner {
private val logger = LoggerFactory.create("io.kinference.utils.TestRunner")

fun runTest(platform: Platform? = null, timeout: Duration = 5.minutes, block: suspend CoroutineScope.() -> Unit): TestResult {
if (platform != null && platform != PlatformUtils.platform) return kotlinx.coroutines.test.runTest {}

val mark = Timer.start()
val res = kotlinx.coroutines.test.runTest(timeout = timeout, testBody = block)
logger.info { "[${PlatformUtils.platform}] Test took ${mark.elapsed().millis}ms" }
return res
}
}

This file was deleted.

This file was deleted.

Loading