Skip to content

Commit

Permalink
test: fix picker error NodeName issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Jan 4, 2024
1 parent abc0c96 commit 15fe844
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class RustTestCodeService(val job: JobContext) : UnitTestService {

val result = testCode.map { codeFunction ->
codeFunction.FunctionCalls.mapNotNull { codeCall ->
val canonicalName = buildCanonicalName(codeCall.NodeName, codeCall.FunctionName)
val canonicalName = buildCanonicalName(codeCall.Package, codeCall.FunctionName)
val underTestFunction = functionMap.firstNotNullOfOrNull { it[canonicalName] }
if (underTestFunction == null) {
null
Expand Down Expand Up @@ -65,9 +65,9 @@ class RustTestCodeService(val job: JobContext) : UnitTestService {
return buildCanonicalName(function.Package, function.Name)
}

private fun buildCanonicalName(nodeName: String, funcName: String): String {
val node = nodeName.ifEmpty { "main" }
return "$node::$funcName"
private fun buildCanonicalName(pkgName: String, funcName: String): String {
val pkg = pkgName.ifEmpty { "main" }
return "$pkg::$funcName"
}

override fun build(dataStruct: CodeDataStruct): List<TypedTestIns> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class RustTestCodeServiceTest {
assert_eq!(embedding.len(), 128);
}
}
""".trimIndent()
""".trimIndent()

val container = RustAnalyser().analysis(testCode, "lib.rs")
container.buildSourceCode(testCode.lines())
Expand All @@ -70,7 +70,8 @@ class RustTestCodeServiceTest {
val build: List<BasicTestIns> = rustTestCodeService.build(container) as List<BasicTestIns>

assertEquals(1, build.size)
assertEquals("""fn init_semantic(model: Vec<u8>, tokenizer_data: Vec<u8>) -> Result<Arc<Semantic>, SemanticError> {
assertEquals(
"""fn init_semantic(model: Vec<u8>, tokenizer_data: Vec<u8>) -> Result<Arc<Semantic>, SemanticError> {
let result = Semantic::init_semantic(model, tokenizer_data)?;
Ok(Arc::new(result))
}""", build[0].underTestCode)
Expand Down

0 comments on commit 15fe844

Please sign in to comment.