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

Kpg/test #192

Merged
merged 2 commits into from
Oct 31, 2021
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
50 changes: 50 additions & 0 deletions kermit-test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
.idea/modules.xml
.idea/*.iml
.idea/modules/
*.iml
*.ipr

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

# Generated files
bin/
gen/

# Gradle files
.gradle
.gradle/
build/

local.properties
47 changes: 47 additions & 0 deletions kermit-test/api/android/kermit-test.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
public final class co/touchlab/kermit/BuildConfig {
public static final field BUILD_TYPE Ljava/lang/String;
public static final field DEBUG Z
public static final field LIBRARY_PACKAGE_NAME Ljava/lang/String;
public fun <init> ()V
}

public final class co/touchlab/kermit/TestConfig : co/touchlab/kermit/LoggerConfig {
public fun <init> (Lco/touchlab/kermit/Severity;Ljava/util/List;)V
public final fun component1 ()Lco/touchlab/kermit/Severity;
public final fun component2 ()Ljava/util/List;
public final fun copy (Lco/touchlab/kermit/Severity;Ljava/util/List;)Lco/touchlab/kermit/TestConfig;
public static synthetic fun copy$default (Lco/touchlab/kermit/TestConfig;Lco/touchlab/kermit/Severity;Ljava/util/List;ILjava/lang/Object;)Lco/touchlab/kermit/TestConfig;
public fun equals (Ljava/lang/Object;)Z
public fun getLogWriterList ()Ljava/util/List;
public fun getMinSeverity ()Lco/touchlab/kermit/Severity;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class co/touchlab/kermit/TestLogWriter : co/touchlab/kermit/LogWriter {
public fun <init> (Lco/touchlab/kermit/Severity;)V
public final fun assertCount (I)V
public final fun assertLast (Lkotlin/jvm/functions/Function1;)V
public final fun getLogs ()Ljava/util/List;
public fun isLoggable (Lco/touchlab/kermit/Severity;)Z
public fun log (Lco/touchlab/kermit/Severity;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
public final fun reset ()V
}

public final class co/touchlab/kermit/TestLogWriter$LogEntry {
public fun <init> (Lco/touchlab/kermit/Severity;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
public final fun component1 ()Lco/touchlab/kermit/Severity;
public final fun component2 ()Ljava/lang/String;
public final fun component3 ()Ljava/lang/String;
public final fun component4 ()Ljava/lang/Throwable;
public final fun copy (Lco/touchlab/kermit/Severity;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)Lco/touchlab/kermit/TestLogWriter$LogEntry;
public static synthetic fun copy$default (Lco/touchlab/kermit/TestLogWriter$LogEntry;Lco/touchlab/kermit/Severity;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;ILjava/lang/Object;)Lco/touchlab/kermit/TestLogWriter$LogEntry;
public fun equals (Ljava/lang/Object;)Z
public final fun getMessage ()Ljava/lang/String;
public final fun getSeverity ()Lco/touchlab/kermit/Severity;
public final fun getTag ()Ljava/lang/String;
public final fun getThrowable ()Ljava/lang/Throwable;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

40 changes: 40 additions & 0 deletions kermit-test/api/jvm/kermit-test.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
public final class co/touchlab/kermit/TestConfig : co/touchlab/kermit/LoggerConfig {
public fun <init> (Lco/touchlab/kermit/Severity;Ljava/util/List;)V
public final fun component1 ()Lco/touchlab/kermit/Severity;
public final fun component2 ()Ljava/util/List;
public final fun copy (Lco/touchlab/kermit/Severity;Ljava/util/List;)Lco/touchlab/kermit/TestConfig;
public static synthetic fun copy$default (Lco/touchlab/kermit/TestConfig;Lco/touchlab/kermit/Severity;Ljava/util/List;ILjava/lang/Object;)Lco/touchlab/kermit/TestConfig;
public fun equals (Ljava/lang/Object;)Z
public fun getLogWriterList ()Ljava/util/List;
public fun getMinSeverity ()Lco/touchlab/kermit/Severity;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class co/touchlab/kermit/TestLogWriter : co/touchlab/kermit/LogWriter {
public fun <init> (Lco/touchlab/kermit/Severity;)V
public final fun assertCount (I)V
public final fun assertLast (Lkotlin/jvm/functions/Function1;)V
public final fun getLogs ()Ljava/util/List;
public fun isLoggable (Lco/touchlab/kermit/Severity;)Z
public fun log (Lco/touchlab/kermit/Severity;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
public final fun reset ()V
}

public final class co/touchlab/kermit/TestLogWriter$LogEntry {
public fun <init> (Lco/touchlab/kermit/Severity;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
public final fun component1 ()Lco/touchlab/kermit/Severity;
public final fun component2 ()Ljava/lang/String;
public final fun component3 ()Ljava/lang/String;
public final fun component4 ()Ljava/lang/Throwable;
public final fun copy (Lco/touchlab/kermit/Severity;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)Lco/touchlab/kermit/TestLogWriter$LogEntry;
public static synthetic fun copy$default (Lco/touchlab/kermit/TestLogWriter$LogEntry;Lco/touchlab/kermit/Severity;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;ILjava/lang/Object;)Lco/touchlab/kermit/TestLogWriter$LogEntry;
public fun equals (Ljava/lang/Object;)Z
public final fun getMessage ()Ljava/lang/String;
public final fun getSeverity ()Lco/touchlab/kermit/Severity;
public final fun getTag ()Ljava/lang/String;
public final fun getThrowable ()Ljava/lang/Throwable;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

116 changes: 116 additions & 0 deletions kermit-test/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/*
* Copyright (c) 2021 Touchlab
* 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.
*/

plugins {
id("com.android.library")
kotlin("multiplatform")
}

val STATELY_VERSION: String by project

kotlin {
android {
publishAllLibraryVariants()
}
jvm()
js(BOTH) {
browser()
nodejs()
}

macosX64()
macosArm64()
iosX64()
iosArm64()
iosArm32()
iosSimulatorArm64()
watchosArm32()
watchosArm64()
watchosSimulatorArm64()
watchosX86()
watchosX64()
tvosArm64()
tvosSimulatorArm64()
tvosX64()

mingwX64()
mingwX86()
linuxX64()
linuxArm32Hfp()
linuxMips32()

val commonMain by sourceSets.getting
val commonTest by sourceSets.getting

val jsMain by sourceSets.getting
val jsTest by sourceSets.getting

val jvmMain by sourceSets.getting {
dependsOn(commonMain)
}

val androidMain by sourceSets.getting {
dependsOn(commonMain)
}

commonMain.dependencies {
implementation(kotlin("test-common"))
implementation(project(":kermit"))
implementation("co.touchlab:stately-collections:$STATELY_VERSION")
}

jsMain.dependencies {
implementation(kotlin("stdlib-js"))
implementation(kotlin("test-js"))
}

jvmMain.dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
}

androidMain.dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
}
}

android {
compileSdkVersion(30)
defaultConfig {
minSdkVersion(15)
}

val main by sourceSets.getting {
manifest.srcFile("src/androidMain/AndroidManifest.xml")
}
}

tasks.register("publishWindows") {
if (tasks.findByName("publish") != null &&
tasks.findByName("publishMingwX64PublicationToMavenRepository") != null) {
dependsOn(
"publishMingwX64PublicationToMavenRepository",
"publishMingwX86PublicationToMavenRepository"
)
}
}

tasks.register("publishLinux") {
if (tasks.findByName("publish") != null &&
tasks.findByName("publishLinuxMips32PublicationToMavenRepository") != null) {
dependsOn("publishLinuxMips32PublicationToMavenRepository")
}
}

apply(from = "../gradle/gradle-mvn-mpp-push.gradle")
11 changes: 11 additions & 0 deletions kermit-test/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2021 Touchlab
~ 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.
-->
<manifest package="co.touchlab.kermit"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2021 Touchlab
* 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 co.touchlab.kermit

import co.touchlab.stately.collections.frozenLinkedList
import kotlin.test.assertEquals
import kotlin.test.assertTrue

data class TestConfig(
override val minSeverity: Severity,
override val logWriterList: List<LogWriter>,
) : LoggerConfig

class TestLogWriter(private val loggable: Severity) : LogWriter() {
data class LogEntry(
val severity: Severity,
val message: String,
val tag: String?,
val throwable: Throwable?
)

@Suppress("DEPRECATION")
private val _logs = frozenLinkedList<LogEntry>()
val logs: List<LogEntry>
get() = _logs.toList()

fun assertCount(count: Int) {
assertEquals(count, _logs.size)
}

fun assertLast(check: LogEntry.() -> Boolean) {
assertTrue(_logs.last().check())
}

fun reset() {
_logs.clear()
}

override fun isLoggable(severity: Severity): Boolean {
return severity.ordinal >= loggable.ordinal
}

override fun log(severity: Severity, message: String, tag: String, throwable: Throwable?) {
_logs.add(LogEntry(severity, message, tag, throwable))
}
}
1 change: 0 additions & 1 deletion kermit/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@
~
~ 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.
-->

<manifest package="co.touchlab.kermit"/>
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class TestLogWriter(private val loggable: Severity) : LogWriter() {
val throwable: Throwable?
)

@Suppress("DEPRECATION")
private val _logs = frozenLinkedList<LogEntry>()
val logs: List<LogEntry>
get() = _logs.toList()
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ include(":kermit-crashlytics")
include(":kermit-crashlytics-test")
include(":kermit-bugsnag")
include(":kermit-bugsnag-test")
include(":kermit-test")

include(":kermit-gradle-plugin")
include(":kermit-ir-plugin")
Expand Down