From 8120b8c194cfb735d478611a6afae295e2931580 Mon Sep 17 00:00:00 2001 From: sabeeh Date: Fri, 8 Dec 2023 07:50:09 +0500 Subject: [PATCH 1/8] ignore handlesDeepStack test for ios --- .../kotlin/com/fleeksoft/ksoup/parser/ParserIT.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ksoup/src/commonTest/kotlin/com/fleeksoft/ksoup/parser/ParserIT.kt b/ksoup/src/commonTest/kotlin/com/fleeksoft/ksoup/parser/ParserIT.kt index da3b2410..3d6d6ce0 100644 --- a/ksoup/src/commonTest/kotlin/com/fleeksoft/ksoup/parser/ParserIT.kt +++ b/ksoup/src/commonTest/kotlin/com/fleeksoft/ksoup/parser/ParserIT.kt @@ -1,5 +1,7 @@ package com.fleeksoft.ksoup.parser +import com.fleeksoft.ksoup.Platform +import com.fleeksoft.ksoup.PlatformType import com.fleeksoft.ksoup.ported.System import kotlin.test.Ignore import kotlin.test.Test @@ -27,6 +29,10 @@ class ParserIT { @Test fun handlesDeepStack() { + if (Platform.current == PlatformType.IOS) { +// The GitHub action is taking too much time. + return + } // inspired by http://sv.stargate.wikia.com/wiki/M2J and https://github.com/jhy/jsoup/issues/955 // I didn't put it in the integration tests, because explorer and intellij kept dieing trying to preview/index it From b1c757dcd82ac0194dfe3d6b878a334f1deaab97 Mon Sep 17 00:00:00 2001 From: sabeeh Date: Fri, 8 Dec 2023 08:54:20 +0500 Subject: [PATCH 2/8] Update documentation. --- CONTRIBUTING.md | 37 +++++++++++++++++++++++++++++++++++++ README.md | 6 ++++-- 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..a922571e --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,37 @@ +# Contributing Guidelines + +You can contribute to this project by reporting issues or submitting changes via a pull request. + +## Reporting issues + +For filing feature requests and bug reports, please use our [GitHub issues](https://github.com/fleeksoft/ksoup/issues). + +For questions about usage and general inquiries, consider asking on StackOverflow or participating in +our [GitHub Discussions](https://github.com/fleeksoft/ksoup/discussions). + +## Submitting changes + +To submit pull requests, please visit [this page](https://github.com/fleeksoft/ksoup/pulls). +Keep in mind that maintainers will have to support the code resulting from your contribution. Therefore, please +familiarize yourself with the following guidelines: + +* All development (both new features and bug fixes) should be performed in the `develop` branch. + * The `master` branch hosts the sources of the most recently released version. + * Base your pull requests against the `develop` branch. + * The `develop` branch is merged into the `master` branch during releases. + * Ensure to [Build the project](#building) to verify that everything works and passes the tests. +* If you are fixing a bug: + * Write the test that reproduces the bug. + * Fixes without tests are accepted only under exceptional circumstances, such as when writing a corresponding test + is too hard or impractical. + * Follow the project's style for writing tests: name test functions as testXxx. Avoid using backticks in test names. +* If you wish to work on an existing issue, comment on it first. Ensure that the issue clearly describes a problem and a + solution that has received positive feedback. Propose a solution if none is suggested. + +## Building + +This library is built with Gradle. + +* Run `./gradlew build` to build the entire project.. +* Run `./gradlew :check` to test only the module you are working on. +* Run `./gradlew :jvmTest` to perform only the fast JVM tests of a multiplatform module. \ No newline at end of file diff --git a/README.md b/README.md index 31ba89d0..97c054df 100644 --- a/README.md +++ b/README.md @@ -71,9 +71,11 @@ Ksoup is an open source project, a Kotlin Multiplatform port of jsoup, distribut ## Development and Support -For questions, ideas, or contributions regarding Ksoup, please contact us via [email](mailto:fleeksoft@gmail.com) or create new pull requests. +For questions about usage and general inquiries, please refer to [GitHub Discussions](https://github.com/fleeksoft/ksoup/discussions). -Report any issues on [our GitHub page](https://github.com/fleeksoft/ksoup/issues), ensuring to check for duplicates beforehand. +If you wish to contribute, please read the [Contributing Guidelines](CONTRIBUTING.md). + +To report any issues, visit our [GitHub issues](https://github.com/fleeksoft/ksoup/issues), Please ensure to check for duplicates before submitting a new issue. ## Library Status From c2efc89bbe71ea40b7fc66710c3976d26d0112e0 Mon Sep 17 00:00:00 2001 From: sabeeh Date: Fri, 8 Dec 2023 09:22:05 +0500 Subject: [PATCH 3/8] refactor test function names --- .../kotlin/com/fleeksoft/ksoup/DataUtilTestJvm.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ksoup/src/jvmAndroidCommonTest/kotlin/com/fleeksoft/ksoup/DataUtilTestJvm.kt b/ksoup/src/jvmAndroidCommonTest/kotlin/com/fleeksoft/ksoup/DataUtilTestJvm.kt index 3bd1114b..68bb6b3e 100644 --- a/ksoup/src/jvmAndroidCommonTest/kotlin/com/fleeksoft/ksoup/DataUtilTestJvm.kt +++ b/ksoup/src/jvmAndroidCommonTest/kotlin/com/fleeksoft/ksoup/DataUtilTestJvm.kt @@ -20,7 +20,7 @@ class DataUtilTestJvm { } @Test - fun parseSequenceBufferReader() { + fun testParseSequenceBufferReader() { // https://github.com/jhy/jsoup/pull/1671 val bufferReader: BufferReader = TestHelper.resourceFilePathToBufferReader("htmltests/medium.html") val fileContent = String(bufferReader.readByteArray()) @@ -52,7 +52,7 @@ class DataUtilTestJvm { } @Test - fun handlesChunkedInputStream() { + fun testHandlesChunkedInputStream() { val file = File(TestHelper.getResourceAbsolutePath("htmltests/large.html")) val input = getFileAsString(file) val expected = @@ -80,7 +80,7 @@ class DataUtilTestJvm { } @Test - fun handlesUnlimitedRead() { + fun testHandlesUnlimitedRead() { val file = File(TestHelper.getResourceAbsolutePath("htmltests/large.html")) val input: String = getFileAsString(file) From 862bc6eb4b2492d058a0aa9d635a1cd55a675d06 Mon Sep 17 00:00:00 2001 From: sabeeh Date: Fri, 8 Dec 2023 12:39:15 +0500 Subject: [PATCH 4/8] CONTRIBUTING.md updated --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a922571e..1e6c9a0d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,6 +32,6 @@ familiarize yourself with the following guidelines: This library is built with Gradle. -* Run `./gradlew build` to build the entire project.. +* Run `./gradlew build` to build the entire project. It also runs all the tests. * Run `./gradlew :check` to test only the module you are working on. * Run `./gradlew :jvmTest` to perform only the fast JVM tests of a multiplatform module. \ No newline at end of file From ef9ffbd3f641a611cad59a989be73fe5fa6e99af Mon Sep 17 00:00:00 2001 From: sabeeh Date: Fri, 8 Dec 2023 12:45:28 +0500 Subject: [PATCH 5/8] use root path from gradle for test resources --- ksoup-network/build.gradle.kts | 1 + ksoup/build.gradle.kts | 32 ++++++++++++++++--- .../kotlin/com/fleeksoft/ksoup/TestHelper.kt | 23 ++++++++----- 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/ksoup-network/build.gradle.kts b/ksoup-network/build.gradle.kts index 20089638..d78b6135 100644 --- a/ksoup-network/build.gradle.kts +++ b/ksoup-network/build.gradle.kts @@ -149,6 +149,7 @@ publishing { developer { name.set("Sabeeh Ul Hussnain") email.set("fleeksoft@gmail.com") + organization.set("Fleek Soft") } } } diff --git a/ksoup/build.gradle.kts b/ksoup/build.gradle.kts index 64dfe43b..bac6d0fa 100644 --- a/ksoup/build.gradle.kts +++ b/ksoup/build.gradle.kts @@ -11,6 +11,8 @@ plugins { group = "com.fleeksoft.ksoup" version = libs.versions.libraryVersion.get() +val rootPath = "generated/kotlin" + kotlin { explicitApi() @@ -51,10 +53,13 @@ kotlin { implementation(libs.codepoints) api(libs.okio) } - commonTest.dependencies { - implementation(libs.kotlin.test) - implementation(libs.gson) - implementation(projects.ksoupNetwork) + commonTest { + this.kotlin.srcDir(layout.buildDirectory.file(rootPath)) + dependencies { + implementation(libs.kotlin.test) + implementation(libs.gson) + implementation(projects.ksoupNetwork) + } } jvmMain.dependencies { @@ -153,6 +158,7 @@ publishing { developer { name.set("Sabeeh Ul Hussnain") email.set("fleeksoft@gmail.com") + organization.set("Fleek Soft") } } } @@ -173,3 +179,21 @@ signing { project.tasks.withType(AbstractPublishToMaven::class.java).configureEach { dependsOn(project.tasks.withType(Sign::class.java)) } + +val generateRootPathSource: Task by tasks.creating { + group = "build setup" + val file = layout.buildDirectory.file("$rootPath/BuildConfig.kt") + outputs.file(file) + + doLast { + val content = + """ + package com.fleeksoft.ksoup + + object BuildConfig { + const val PROJECT_ROOT: String = "${rootProject.rootDir.absolutePath.replace("\\", "\\\\")}" + } + """.trimIndent() + file.get().asFile.writeText(content) + } +} diff --git a/ksoup/src/commonTest/kotlin/com/fleeksoft/ksoup/TestHelper.kt b/ksoup/src/commonTest/kotlin/com/fleeksoft/ksoup/TestHelper.kt index 8a3c9906..a06b72ff 100644 --- a/ksoup/src/commonTest/kotlin/com/fleeksoft/ksoup/TestHelper.kt +++ b/ksoup/src/commonTest/kotlin/com/fleeksoft/ksoup/TestHelper.kt @@ -6,15 +6,22 @@ import okio.Path.Companion.toPath object TestHelper { fun getResourceAbsolutePath(resourceName: String): String { -// return "/Users/sabeeh/AndroidStudioProjects/ksoup/ksoup/src/commonTest/resources/$resourceName" - val rootPath = - if (Platform.current == PlatformType.IOS) { - "/Users/runner/work/ksoup/ksoup/ksoup" - } else { - "/home/runner/work/ksoup/ksoup/ksoup" + return "${BuildConfig.PROJECT_ROOT}/ksoup/src/commonTest/resources/$resourceName" + /*return when (Platform.current) { + PlatformType.JVM, PlatformType.ANDROID -> { + "src/commonTest/resources/$resourceName" + } + + PlatformType.JS -> { + "../../../../ksoup/src/commonTest/resources/$resourceName" } - return "$rootPath/src/commonTest/resources/$resourceName" -// return "../ksoup/src/commonTest/resources/$resourceName" + + PlatformType.IOS -> { + "/Users/runner/work/ksoup/ksoup/ksoup/src/commonTest/resources/$resourceName" + } + + else -> "src/commonTest/resources/$resourceName" + }*/ } fun getFileAsString(file: Path): String { From 333b619968109979fb69543481ded832b130eb43 Mon Sep 17 00:00:00 2001 From: sabeeh Date: Fri, 8 Dec 2023 12:52:31 +0500 Subject: [PATCH 6/8] code reformat --- ksoup/src/commonTest/kotlin/com/fleeksoft/ksoup/GzipTest.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ksoup/src/commonTest/kotlin/com/fleeksoft/ksoup/GzipTest.kt b/ksoup/src/commonTest/kotlin/com/fleeksoft/ksoup/GzipTest.kt index 322321b0..e6cfed63 100644 --- a/ksoup/src/commonTest/kotlin/com/fleeksoft/ksoup/GzipTest.kt +++ b/ksoup/src/commonTest/kotlin/com/fleeksoft/ksoup/GzipTest.kt @@ -8,7 +8,8 @@ class GzipTest { @Test fun testReadGzipFile() { val gzipFileStr = - readGzipFile(TestHelper.getResourceAbsolutePath("htmltests/gzip.html.gz").toPath()).readByteString().utf8() + readGzipFile(TestHelper.getResourceAbsolutePath("htmltests/gzip.html.gz").toPath()) + .readByteString().utf8() val expected = """Gzip test

This is a gzipped HTML file.

From cc40c6c187209d65718d846d9b9ae894164d11b8 Mon Sep 17 00:00:00 2001 From: sabeeh Date: Fri, 8 Dec 2023 12:52:42 +0500 Subject: [PATCH 7/8] bump library version to 0.1.0 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 76cebd48..c40e0ab1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,7 @@ agp = "8.1.3" kotlin = "1.9.21" compileSdk = "34" minSdk = "21" -libraryVersion = "0.0.9" +libraryVersion = "0.1.0" junitJupiter = "5.10.0" compose = "1.5.4" compose-compiler = "1.5.4" From 3c0c9775716f40a48678034f2c4997b7c4c640d2 Mon Sep 17 00:00:00 2001 From: sabeeh Date: Fri, 8 Dec 2023 13:03:28 +0500 Subject: [PATCH 8/8] generateRootPathSource depend on all tasks --- ksoup/build.gradle.kts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ksoup/build.gradle.kts b/ksoup/build.gradle.kts index bac6d0fa..91b50af6 100644 --- a/ksoup/build.gradle.kts +++ b/ksoup/build.gradle.kts @@ -197,3 +197,9 @@ val generateRootPathSource: Task by tasks.creating { file.get().asFile.writeText(content) } } + +tasks.all { + if (name != "generateRootPathSource") { + dependsOn("generateRootPathSource") + } +}