-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move more sources around and add back the tests that existed before r…
…estructuring
- Loading branch information
Showing
34 changed files
with
432 additions
and
87 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,5 @@ | ||
py_binary( | ||
name = "test_runner_executable", | ||
srcs = ["test_runner_executable.py"], | ||
visibility = ["//visibility:public"], | ||
) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,76 @@ | ||
package com.rules.android.lint.cli | ||
|
||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.junit.runners.JUnit4 | ||
import java.nio.file.Paths | ||
|
||
@RunWith(JUnit4::class) | ||
class AndroidLintActionArgsTest { | ||
|
||
@Test | ||
fun `does parse all arguments`() { | ||
val parseArgs = AndroidLintActionArgs.parseArgs( | ||
args = listOf( | ||
"--module-name", | ||
"test_module_name", | ||
"--label", | ||
"test", | ||
"--src", | ||
"path/to/Foo.kt", | ||
"--output", | ||
"output.jar", | ||
"--project-config-output", | ||
"project.xml", | ||
"--resource", | ||
"path/to/resource/strings.xml", | ||
"--android-manifest", | ||
"AndroidManifest.xml", | ||
"--baseline-file", | ||
"lib_lint_baseline.xml", | ||
"--config-file", | ||
"lint_config.xml", | ||
"--custom-rule", | ||
"custom_rule.jar", | ||
"--classpath", | ||
"classpath.jar", | ||
"--classpath", | ||
"classpath.aar", | ||
"--autofix", | ||
"--regenerate-baseline-files", | ||
"--warnings-as-errors", | ||
"--enable-check", | ||
"custom-check", | ||
"--disable-check", | ||
"custom-disabled-check", | ||
"--compile-sdk-version", | ||
"1.6", | ||
"--java-language-level", | ||
"1.7", | ||
"--kotlin-language-level", | ||
"1.8", | ||
), | ||
) | ||
|
||
assertThat(parseArgs.moduleName).isEqualTo("test_module_name") | ||
assertThat(parseArgs.label).isEqualTo("test") | ||
assertThat(parseArgs.srcs).containsExactly(Paths.get("path/to/Foo.kt")) | ||
assertThat(parseArgs.output).isEqualTo(Paths.get("output.jar")) | ||
assertThat(parseArgs.projectConfigOutput).isEqualTo(Paths.get("project.xml")) | ||
assertThat(parseArgs.resources).containsExactly(Paths.get("path/to/resource/strings.xml")) | ||
assertThat(parseArgs.baselineFile).isEqualTo(Paths.get("lib_lint_baseline.xml")) | ||
assertThat(parseArgs.config).isEqualTo(Paths.get("lint_config.xml")) | ||
assertThat(parseArgs.customChecks).containsExactly(Paths.get("custom_rule.jar")) | ||
assertThat(parseArgs.classpath) | ||
.containsExactly(Paths.get("classpath.jar"), Paths.get("classpath.aar")) | ||
assertThat(parseArgs.autofix).isTrue | ||
assertThat(parseArgs.regenerateBaselineFile).isTrue | ||
assertThat(parseArgs.warningsAsErrors).isTrue | ||
assertThat(parseArgs.enableChecks).containsExactly("custom-check") | ||
assertThat(parseArgs.disableChecks).containsExactly("custom-disabled-check") | ||
assertThat(parseArgs.compileSdkVersion).isEqualTo("1.6") | ||
assertThat(parseArgs.javaLanguageLevel).isEqualTo("1.7") | ||
assertThat(parseArgs.kotlinLanguageLevel).isEqualTo("1.8") | ||
} | ||
} |
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,13 @@ | ||
package com.rules.android.lint.cli | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.junit.runners.JUnit4 | ||
|
||
@RunWith(JUnit4::class) | ||
class AndroidLintActionTest { | ||
@Test | ||
fun `empty test case`() { | ||
// TODO(bencodes) Add some tests for AndroidLintAction | ||
} | ||
} |
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,56 @@ | ||
package com.rules.android.lint.cli | ||
|
||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.rules.TemporaryFolder | ||
import org.junit.runner.RunWith | ||
import org.junit.runners.JUnit4 | ||
import java.nio.file.Path | ||
|
||
@RunWith(JUnit4::class) | ||
class AndroidLintProjectTest { | ||
|
||
@Rule | ||
@JvmField | ||
var tmpDirectory = TemporaryFolder() | ||
|
||
private fun TemporaryFolder.newPath(name: String): Path = this.newFile(name).toPath() | ||
|
||
@Test | ||
fun `test asXMLString does produce correct project file content`() { | ||
assertThat( | ||
createProjectXMLString( | ||
moduleName = "test_module_name", | ||
srcs = listOf(tmpDirectory.newPath("Foo.kt")), | ||
resources = listOf(tmpDirectory.newPath("foo.xml")), | ||
androidManifest = tmpDirectory.newPath("AndroidManifest.xml"), | ||
classpathJars = listOf(tmpDirectory.newPath("Foo.jar")), | ||
classpathAars = listOf(tmpDirectory.newPath("Foo.aar")), | ||
classpathExtractedAarDirectories = listOf( | ||
Pair( | ||
tmpDirectory.newPath("Bar.aar"), | ||
tmpDirectory.newFolder("tmp/unpacked_aars/bar/").toPath(), | ||
), | ||
), | ||
customLintChecks = listOf(tmpDirectory.newPath("tmp/unpacked_aars/bar/lint.jar")), | ||
), | ||
).isEqualTo( | ||
""" | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<project> | ||
<module android="true" name="test_module_name"> | ||
<src file="{root}/Foo.kt"/> | ||
<resource file="{root}/foo.xml"/> | ||
<manifest file="{root}/AndroidManifest.xml"/> | ||
<classpath jar="{root}/Foo.jar"/> | ||
<aar file="{root}/Foo.aar"/> | ||
<aar extracted="{root}/tmp/unpacked_aars/bar" file="{root}/Bar.aar"/> | ||
</module> | ||
<lint-checks jar="{root}/tmp/unpacked_aars/bar/lint.jar"/> | ||
</project> | ||
""".trimIndent().replace("{root}", tmpDirectory.root.absolutePath), | ||
) | ||
} | ||
} |
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,58 @@ | ||
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_test") | ||
load("@rules_kotlin//kotlin:lint.bzl", "ktlint_fix", "ktlint_test") | ||
|
||
kt_jvm_test( | ||
name = "AndroidLintActionArgsTest", | ||
srcs = ["AndroidLintActionArgsTest.kt"], | ||
associates = ["//src/cli:lint"], | ||
test_class = "com.rules.android.lint.cli.AndroidLintActionArgsTest", | ||
deps = [ | ||
"@rules_android_lint_deps//:junit_junit", | ||
"@rules_android_lint_deps//:org_assertj_assertj_core", | ||
], | ||
) | ||
|
||
kt_jvm_test( | ||
name = "AndroidLintActionTest", | ||
srcs = ["AndroidLintActionTest.kt"], | ||
associates = ["//src/cli:lint"], | ||
test_class = "com.rules.android.lint.cli.AndroidLintActionTest", | ||
deps = [ | ||
"@rules_android_lint_deps//:junit_junit", | ||
"@rules_android_lint_deps//:org_assertj_assertj_core", | ||
], | ||
) | ||
|
||
kt_jvm_test( | ||
name = "AndroidLintProjectTest", | ||
srcs = ["AndroidLintProjectTest.kt"], | ||
associates = ["//src/cli:lint"], | ||
test_class = "com.rules.android.lint.cli.AndroidLintProjectTest", | ||
deps = [ | ||
"@rules_android_lint_deps//:junit_junit", | ||
"@rules_android_lint_deps//:org_assertj_assertj_core", | ||
], | ||
) | ||
|
||
ktlint_test( | ||
name = "lint_ktlint_test", | ||
srcs = glob(["*.kt"]), | ||
config = "//:editorconfig", | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
ktlint_fix( | ||
name = "lint_ktlint_fix", | ||
srcs = glob(["*.kt"]), | ||
config = "//:editorconfig", | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
test_suite( | ||
name = "tests", | ||
tests = [ | ||
":AndroidLintActionArgsTest", | ||
":AndroidLintActionTest", | ||
":AndroidLintProjectTest", | ||
], | ||
) |
Oops, something went wrong.