Skip to content

Commit

Permalink
feat(rust): try handle for Rust test
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Jan 2, 2024
1 parent bc0e73f commit 3bec910
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ clikt = "4.2.1"

chocolate-factory = "0.4.5"

chapi = "2.1.5"
chapi = "2.2.0"
archguard = "2.1.2"
codedb = "0.1.3"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,24 @@ class RustTestCodeService(val job: JobContext) : UnitTestService {
override fun isApplicable(container: CodeContainer): Boolean = job.project.language == SupportedLang.RUST

override fun build(container: CodeContainer): List<TypedTestIns> {
val testCode = container.DataStructures.filter { it.Module == "tests" }
val testDataStruct = container.DataStructures.filter {
it.Module == "tests"
}
if (testDataStruct.isEmpty()) return emptyList()

val testCode = testDataStruct.map { dataStruct ->
dataStruct.Functions.filter { function -> function.Annotations.any { it.Name == "test" } }
}.flatten()

if (testCode.isEmpty()) return emptyList()

println(testCode)
testCode.forEach {
it.FunctionCalls.forEach { functionCall ->
// todo: lookup method call in Chapi
}
}

return emptyList()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class RustWorker(override val context: WorkerContext) : LangWorker {
override fun prepareJob(job: InstructionFileJob) {
this.jobs.add(job)
try {
println("RustWorker prepareJob: ${job.fileSummary.location}")
val container = RustAnalyser().analysis(job.code, job.fileSummary.location)
job.codeLines = job.code.lines()
container.DataStructures.map { ds ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class SingleProjectCodePickerTest {
val picker = SingleProjectCodePicker(
InsPickerOption(
language = "rust",
url = "https://github.com/feakin/fklang",
url = "https://github.com/unit-mesh/edge-infer",
maxTokenLength = 8192,
codeStrategyTypes = listOf(CodeStrategyType.RELATED_CODE),
completionTypes = listOf(
Expand Down

0 comments on commit 3bec910

Please sign in to comment.