-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### What's done: * Introduce primary logic and tests * Apply fix objects from SARIF to the target files (single line changes)
- Loading branch information
1 parent
5e2f0b4
commit 999c609
Showing
27 changed files
with
1,613 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...Src/src/main/kotlin/kotlin/org/jetbrains/kotlin/gradle/targets/jvm/tasks/KotlinJvmTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
@file:Suppress( | ||
"HEADER_MISSING_OR_WRONG_COPYRIGHT", | ||
"MISSING_KDOC_TOP_LEVEL", | ||
"MISSING_KDOC_CLASS_ELEMENTS", | ||
"PACKAGE_NAME_INCORRECT_PREFIX", | ||
"PACKAGE_NAME_INCORRECT_PATH", | ||
"FILE_INCORRECT_BLOCKS_ORDER", | ||
"WRONG_INDENTATION", | ||
"NO_BRACES_IN_CONDITIONALS_AND_LOOPS", | ||
) | ||
|
||
// Copied from https://github.com/JetBrains/kotlin/blob/master/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/jvm/tasks/KotlinJvmTest.kt | ||
// which needs to be recompiled with a newer Gradle API to address https://youtrack.jetbrains.com/issue/KT-54634 | ||
|
||
/* | ||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license | ||
* that can be found in the license/LICENSE.txt file. | ||
*/ | ||
|
||
package org.jetbrains.kotlin.gradle.targets.jvm.tasks | ||
|
||
import org.gradle.api.internal.tasks.testing.JvmTestExecutionSpec | ||
import org.gradle.api.internal.tasks.testing.TestDescriptorInternal | ||
import org.gradle.api.internal.tasks.testing.TestExecuter | ||
import org.gradle.api.internal.tasks.testing.TestResultProcessor | ||
import org.gradle.api.internal.tasks.testing.TestStartEvent | ||
import org.gradle.api.tasks.CacheableTask | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.Optional | ||
import org.gradle.api.tasks.testing.Test | ||
|
||
@CacheableTask | ||
open class KotlinJvmTest : Test() { | ||
@Input | ||
@Optional | ||
var targetName: String? = null | ||
|
||
override fun createTestExecuter(): TestExecuter<JvmTestExecutionSpec> = | ||
if (targetName != null) Executor( | ||
super.createTestExecuter(), | ||
targetName!! | ||
) | ||
else super.createTestExecuter() | ||
|
||
class Executor( | ||
private val delegate: TestExecuter<JvmTestExecutionSpec>, | ||
private val targetName: String | ||
) : TestExecuter<JvmTestExecutionSpec> by delegate { | ||
override fun execute(testExecutionSpec: JvmTestExecutionSpec, testResultProcessor: TestResultProcessor) { | ||
delegate.execute(testExecutionSpec, object : TestResultProcessor by testResultProcessor { | ||
override fun started(test: TestDescriptorInternal, event: TestStartEvent) { | ||
val myTest = object : TestDescriptorInternal by test { | ||
override fun getDisplayName(): String = "${test.displayName}[$targetName]" | ||
override fun getClassName(): String? = test.className?.replace('$', '.') | ||
override fun getClassDisplayName(): String? = test.classDisplayName?.replace('$', '.') | ||
} | ||
testResultProcessor.started(myTest, event) | ||
} | ||
}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,18 @@ | ||
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.getCurrentOperatingSystem | ||
import org.gradle.nativeplatform.platform.internal.DefaultOperatingSystem | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension | ||
|
||
plugins { | ||
application | ||
id("com.saveourtool.sarifutils.buildutils.kotlin-library") | ||
} | ||
|
||
application { | ||
mainClass.set("com.saveourtool.sarifutils.cli.MainKt") | ||
} | ||
|
||
kotlin { | ||
val os = getCurrentOperatingSystem() | ||
|
||
jvm() | ||
|
||
registerNativeBinaries(os, this) | ||
|
||
sourceSets { | ||
val commonMain by getting { | ||
dependencies { | ||
api(libs.okio) | ||
implementation(libs.kotlinx.serialization.json) | ||
implementation(libs.sarif4k) | ||
implementation(libs.multiplatform.diff) | ||
} | ||
} | ||
} | ||
|
||
linkProperExecutable(os) | ||
} | ||
|
||
/** | ||
* @param os | ||
* @param kotlin | ||
* @throws GradleException | ||
*/ | ||
fun registerNativeBinaries(os: DefaultOperatingSystem, kotlin: KotlinMultiplatformExtension) { | ||
val saveTarget = when { | ||
os.isWindows -> kotlin.mingwX64() | ||
os.isLinux -> kotlin.linuxX64() | ||
os.isMacOsX -> kotlin.macosX64() | ||
else -> throw GradleException("Unknown operating system $os") | ||
} | ||
|
||
configure(listOf(saveTarget)) { | ||
binaries { | ||
val name = "sarifutils-${project.version}-${this@configure.name}" | ||
executable { | ||
this.baseName = name | ||
entryPoint = "com.saveourtool.sarifutils.cli.main" | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @param os | ||
* @throws GradleException | ||
*/ | ||
fun linkProperExecutable(os: DefaultOperatingSystem) { | ||
val linkReleaseExecutableTaskProvider = when { | ||
os.isLinux -> tasks.getByName("linkReleaseExecutableLinuxX64") | ||
os.isWindows -> tasks.getByName("linkReleaseExecutableMingwX64") | ||
os.isMacOsX -> tasks.getByName("linkReleaseExecutableMacosX64") | ||
else -> throw GradleException("Unknown operating system $os") | ||
} | ||
project.tasks.register("linkReleaseExecutableMultiplatform") { | ||
dependsOn(linkReleaseExecutableTaskProvider) | ||
} | ||
|
||
// disable building of some binaries to speed up build | ||
// possible values: `all` - build all binaries, `debug` - build only debug binaries | ||
val enabledExecutables = if (hasProperty("enabledExecutables")) property("enabledExecutables") as String else null | ||
if (enabledExecutables != null && enabledExecutables != "all") { | ||
linkReleaseExecutableTaskProvider.enabled = false | ||
} | ||
} |
9 changes: 0 additions & 9 deletions
9
fixpatches/src/commonMain/kotlin/com/saveourtool/sarifutils/cli/Main.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.