Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
ogolberg committed Feb 25, 2024
1 parent 2154b0b commit 02cd668
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright (c) 2024 Toast Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.toasttab.expediter.cli

import com.github.ajalt.clikt.core.CliktCommand
Expand All @@ -7,8 +22,8 @@ import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.options.required
import com.toasttab.expediter.Expediter
import com.toasttab.expediter.ignore.Ignore
import com.toasttab.expediter.issue.IssueOrder
import com.toasttab.expediter.issue.IssueReport
import com.toasttab.expediter.issue.IssueSort
import com.toasttab.expediter.provider.ClasspathApplicationTypesProvider
import com.toasttab.expediter.provider.InMemoryPlatformTypeProvider
import com.toasttab.expediter.provider.JvmTypeProvider
Expand Down Expand Up @@ -40,16 +55,19 @@ class ExpediterCliCommand : CliktCommand() {
)

fun platform(): PlatformTypeProvider {
return if (jvmPlatform != null) {
JvmTypeProvider.forTarget(jvmPlatform!!.toInt())
} else if (platformDescriptors != null) {
val jvm = jvmPlatform?.let(String::toInt)
val platformFile = platformDescriptors?.let(::File)

return if (jvm != null) {
JvmTypeProvider.forTarget(jvm)
} else if (platformFile != null) {
InMemoryPlatformTypeProvider(
File(platformDescriptors!!).inputStream().use {
platformFile.inputStream().use {
TypeDescriptors.deserialize(it)
}.types
)
} else {
error("blerg")
error("Must specify either jvm version or platform descriptors")
}
}
override fun run() {
Expand All @@ -62,7 +80,7 @@ class ExpediterCliCommand : CliktCommand() {

val issueReport = IssueReport(
projectName,
issues.sortedWith(IssueSort.DEFAULT)
issues.sortedWith(IssueOrder.TYPE)
)

issueReport.issues.forEach {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,57 @@
/*
* Copyright (c) 2024 Toast Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.toasttab.expediter.cli

import com.toasttab.expediter.issue.Issue
import com.toasttab.expediter.issue.IssueReport
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.io.TempDir
import strikt.api.expectThat
import strikt.assertions.contains
import java.io.File
import java.nio.file.Path
import kotlin.io.path.inputStream

class ExpediterCliCommandIntegrationTest {
@TempDir
lateinit var dir: Path

@Test
fun test() {
fun `run on self`() {
val output = dir.resolve("expediter.json")

ExpediterCliCommand().main(
System.getProperty("libraries").split(File.pathSeparatorChar).flatMap {
listOf("--libraries", it)
} + listOf(
} + listOf(
"--project-classes", System.getProperty("classes"),
"--output", output.toString(),
"--jvm-platform", "11"
)
)

output.inputStream().use {
val report = output.inputStream().use {
IssueReport.fromJson(it)
}

expectThat(report.issues).contains(
Issue.MissingType(
caller = "com/github/ajalt/mordant/internal/nativeimage/WinKernel32Lib",
target = "org/graalvm/word/PointerBase"
)
)
}
}
}
32 changes: 32 additions & 0 deletions core/src/main/kotlin/com/toasttab/expediter/issue/IssueOrder.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2024 Toast Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.toasttab.expediter.issue

object IssueOrder {
val CALLER: Comparator<Issue> = compareBy({
it.caller
}, {
it.target
})

val TYPE: Comparator<Issue> = compareBy({
it::class.java.name
}, {
it.target
}, {
it.caller
})
}
11 changes: 0 additions & 11 deletions core/src/main/kotlin/com/toasttab/expediter/issue/IssueSort.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.toasttab.expediter.Expediter
import com.toasttab.expediter.gradle.config.RootType
import com.toasttab.expediter.gradle.service.ApplicationTypeCache
import com.toasttab.expediter.ignore.Ignore
import com.toasttab.expediter.issue.IssueOrder
import com.toasttab.expediter.issue.IssueReport
import com.toasttab.expediter.parser.TypeParsers
import com.toasttab.expediter.provider.InMemoryPlatformTypeProvider
Expand Down Expand Up @@ -173,16 +174,11 @@ abstract class ExpediterTask : DefaultTask() {
cache.get().resolve(typeSources),
PlatformTypeProviderChain(providers),
roots.selector,
).findIssues()
).findIssues().sortedWith(IssueOrder.CALLER)

val issueReport = IssueReport(
project.name,
issues.sortedWith(
compareBy(
{ it.caller },
{ it.target }
)
)
issues
)

for (issue in issueReport.issues) {
Expand Down

0 comments on commit 02cd668

Please sign in to comment.