Skip to content
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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ repos:
rev: v6.0.0
hooks:
- id: end-of-file-fixer
exclude: ^tests/integration/(?:[^/]+/)*fixtures/
exclude: ^tests/fixtures/(?:[^/]+/)*expected/
- id: trailing-whitespace
exclude: ^tests/integration/(?:[^/]+/)*fixtures/
exclude: ^tests/fixtures/(?:[^/]+/)*expected/
- id: check-yaml
- id: check-added-large-files

Expand Down
18 changes: 11 additions & 7 deletions tests/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
test_suite(
name = "tests",
tests = [
"//tests/integration:tests",
"//tests/rules:tests",
],
)
load(":dokka_tests.bzl", "dokka_test_suite")
load(":generated_docs_tests.bzl", "generated_docs_test_suite")
load(":multi_module_tests.bzl", "multi_module_test_suite")

dokka_test_suite(name = "dokka")

generated_docs_test_suite(name = "generated_docs")

multi_module_test_suite(name = "multi_module")

test_suite(name = "all_tests")
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set -e
# --- end runfiles.bash initialization v3 ---

docs="$(rlocation "$1")"
module_path="tests/integration/derived"
module_path="tests/fixtures/derived_defaults"

test -f "${docs}/index.html" || {
echo "Missing aggregate index under ${docs}" >&2
Expand All @@ -31,7 +31,7 @@ grep -Fq "Derived Module Defaults" "${docs}/index.html" || {
echo "Aggregate index does not contain its title" >&2
exit 1
}
grep -Fq "derived_docs" "${docs}/index.html" || {
grep -Fq ">docs</a>" "${docs}/index.html" || {
echo "Aggregate index does not contain the label-derived module name" >&2
exit 1
}
Expand Down
59 changes: 29 additions & 30 deletions tests/rules/dokka_analysis_test.bzl → tests/dokka_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def _dokka_configuration_test_impl(ctx):
info = target[DokkaInfo]
asserts.equals(env, "gfm", info.format)
asserts.equals(env, "fixture-module", info.module_name)
asserts.equals(env, "tests/rules", info.module_path)
asserts.equals(env, "tests/fixtures/analysis", info.module_path)
asserts.equals(env, None, info.partial_documentation)

documentation_files = target[DefaultInfo].files.to_list()
Expand Down Expand Up @@ -177,7 +177,7 @@ def _dokka_defaults_test_impl(ctx):

asserts.equals(env, "html", info.format)
asserts.equals(env, "defaults_fixture", info.module_name)
asserts.equals(env, "tests/rules", info.module_path)
asserts.equals(env, "tests/fixtures/analysis", info.module_path)
asserts.true(env, info.partial_documentation.is_directory)
asserts.equals(
env,
Expand Down Expand Up @@ -313,7 +313,7 @@ def _dokka_multi_module_test_impl(ctx):
asserts.equals(env, "docs", modules[1]["name"])
asserts.equals(
env,
"tests/rules/nested",
"tests/fixtures/analysis/nested",
modules[1]["relativePathToOutputDirectory"],
)
asserts.equals(env, [], modules[1]["includes"])
Expand Down Expand Up @@ -468,74 +468,73 @@ _non_html_module_test = analysistest.make(
expect_failure = True,
)

def dokka_analysis_test_suite(name):
def dokka_test_suite(name):
"""Defines the Dokka analysis test suite.

Args:
name: Name of the generated test suite.
"""
_dokka_configuration_test(
name = name + "_configuration",
target_under_test = ":analysis_fixture",
tags = [name],
target_under_test = "//tests/fixtures/analysis:analysis_fixture",
)
_dokka_defaults_test(
name = name + "_defaults",
target_under_test = ":defaults_fixture",
tags = [name],
target_under_test = "//tests/fixtures/analysis:defaults_fixture",
)
_dokka_deps_test(
name = name + "_deps",
target_under_test = ":deps_fixture",
tags = [name],
target_under_test = "//tests/fixtures/analysis:deps_fixture",
)
_dokka_wasm_test(
name = name + "_wasm",
target_under_test = ":wasm_fixture",
tags = [name],
target_under_test = "//tests/fixtures/analysis:wasm_fixture",
)
_dokka_multi_module_test(
name = name + "_multi_module",
target_under_test = ":multi_module_fixture",
tags = [name],
target_under_test = "//tests/fixtures/analysis:multi_module_fixture",
)
_dokka_reusable_config_test(
name = name + "_reusable_config",
target_under_test = ":configured_fixture",
tags = [name],
target_under_test = "//tests/fixtures/analysis:configured_fixture",
)
_invalid_config_test(
name = name + "_invalid_config",
target_under_test = ":invalid_config_fixture",
tags = [name],
target_under_test = "//tests/fixtures/analysis:invalid_config_fixture",
)
_duplicate_module_path_test(
name = name + "_duplicate_module_path",
target_under_test = ":duplicate_aggregate_fixture",
tags = [name],
target_under_test = "//tests/fixtures/analysis:duplicate_aggregate_fixture",
)
_duplicate_module_name_test(
name = name + "_duplicate_module_name",
target_under_test = ":duplicate_module_name_aggregate_fixture",
tags = [name],
target_under_test = "//tests/fixtures/analysis:duplicate_module_name_aggregate_fixture",
)
_invalid_module_path_test(
name = name + "_invalid_module_path",
target_under_test = ":invalid_path_aggregate_fixture",
tags = [name],
target_under_test = "//tests/fixtures/analysis:invalid_path_aggregate_fixture",
)
_reserved_module_path_test(
name = name + "_reserved_module_path",
target_under_test = ":reserved_path_aggregate_fixture",
tags = [name],
target_under_test = "//tests/fixtures/analysis:reserved_path_aggregate_fixture",
)
_non_html_module_test(
name = name + "_non_html_module",
target_under_test = ":non_html_aggregate_fixture",
tags = [name],
target_under_test = "//tests/fixtures/analysis:non_html_aggregate_fixture",
)
native.test_suite(
name = name,
tests = [
":" + name + "_configuration",
":" + name + "_defaults",
":" + name + "_deps",
":" + name + "_duplicate_module_name",
":" + name + "_duplicate_module_path",
":" + name + "_invalid_config",
":" + name + "_invalid_module_path",
":" + name + "_multi_module",
":" + name + "_non_html_module",
":" + name + "_reserved_module_path",
":" + name + "_reusable_config",
":" + name + "_wasm",
],
tags = [name],
)
8 changes: 8 additions & 0 deletions tests/fixtures/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

package(default_visibility = ["//tests:__subpackages__"])

bzl_library(
name = "common",
srcs = ["common.bzl"],
)
50 changes: 27 additions & 23 deletions tests/rules/BUILD.bazel → tests/fixtures/analysis/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")
load("//dokka:defs.bzl", "dokka", "dokka_config", "dokka_multi_module")
load(":dokka_analysis_test.bzl", "dokka_analysis_test_suite")
load("//tests/fixtures:common.bzl", "FIXTURE_TAGS")

package(default_visibility = ["//tests:__subpackages__"])

kt_jvm_library(
name = "dependency",
srcs = ["Dependency.kt"],
neverlink = True,
tags = FIXTURE_TAGS,
)

kt_jvm_library(
name = "custom_plugin",
srcs = ["CustomPlugin.kt"],
tags = FIXTURE_TAGS,
)

dokka_config(
Expand All @@ -37,6 +41,7 @@ dokka_config(
suppress_annotated_with = ["com.example.InternalApi"],
suppress_inherited_members = True,
suppress_obvious_functions = False,
tags = FIXTURE_TAGS,
)

dokka_config(
Expand All @@ -63,12 +68,13 @@ dokka_config(
suppress_annotated_with = ["com.example.ExperimentalApi"],
suppress_inherited_members = True,
suppress_obvious_functions = False,
tags = FIXTURE_TAGS,
)

dokka_config(
name = "wasm_config",
analysis_platform = "wasm",
tags = ["manual"],
tags = FIXTURE_TAGS,
)

dokka(
Expand All @@ -81,34 +87,34 @@ dokka(
module_version = "1.2.3",
samples = ["Sample.kt"],
suppressed_files = ["Suppressed.kt"],
tags = ["manual"],
tags = FIXTURE_TAGS,
deps = [":dependency"],
)

dokka(
name = "wasm_fixture",
srcs = ["Fixture.kt"],
config = ":wasm_config",
tags = ["manual"],
tags = FIXTURE_TAGS,
)

dokka(
name = "defaults_fixture",
srcs = ["Fixture.kt"],
tags = ["manual"],
tags = FIXTURE_TAGS,
)

dokka(
name = "deps_fixture",
srcs = ["DepsFixture.kt"],
tags = ["manual"],
tags = FIXTURE_TAGS,
deps = [":dependency"],
)

dokka(
name = "docs",
srcs = ["Fixture.kt"],
tags = ["manual"],
tags = FIXTURE_TAGS,
)

dokka(
Expand All @@ -117,39 +123,39 @@ dokka(
includes = ["module.md"],
module_name = "API",
module_path = "api",
tags = ["manual"],
tags = FIXTURE_TAGS,
)

dokka(
name = "duplicate_module_path_fixture",
srcs = ["Fixture.kt"],
module_path = "api",
tags = ["manual"],
tags = FIXTURE_TAGS,
)

dokka(
name = "invalid_module_path_fixture",
srcs = ["Fixture.kt"],
module_path = "../invalid",
tags = ["manual"],
tags = FIXTURE_TAGS,
)

dokka(
name = "reserved_module_path_fixture",
srcs = ["Fixture.kt"],
module_path = "scripts/api",
tags = ["manual"],
tags = FIXTURE_TAGS,
)

dokka_multi_module(
name = "multi_module_fixture",
config = ":shared_config",
includes = ["module.md"],
modules = [
"//tests/rules/nested:docs",
"//tests/fixtures/analysis/nested:docs",
":module_api_fixture",
],
tags = ["manual"],
tags = FIXTURE_TAGS,
title = "Project API Reference",
)

Expand All @@ -159,34 +165,34 @@ dokka_multi_module(
":module_api_fixture",
":duplicate_module_path_fixture",
],
tags = ["manual"],
tags = FIXTURE_TAGS,
)

dokka_multi_module(
name = "duplicate_module_name_aggregate_fixture",
modules = [
"//tests/rules/nested:docs",
"//tests/fixtures/analysis/nested:docs",
":docs",
],
tags = ["manual"],
tags = FIXTURE_TAGS,
)

dokka_multi_module(
name = "invalid_path_aggregate_fixture",
modules = [":invalid_module_path_fixture"],
tags = ["manual"],
tags = FIXTURE_TAGS,
)

dokka_multi_module(
name = "reserved_path_aggregate_fixture",
modules = [":reserved_module_path_fixture"],
tags = ["manual"],
tags = FIXTURE_TAGS,
)

dokka_multi_module(
name = "non_html_aggregate_fixture",
modules = [":analysis_fixture"],
tags = ["manual"],
tags = FIXTURE_TAGS,
)

dokka(
Expand All @@ -197,13 +203,11 @@ dokka(
includes = ["module.md"],
module_name = "configured-module",
module_version = "4.5.6",
tags = ["manual"],
tags = FIXTURE_TAGS,
)

dokka_config(
name = "invalid_config_fixture",
documented_visibilities = ["public"],
tags = ["manual"],
tags = FIXTURE_TAGS,
)

dokka_analysis_test_suite(name = "tests")
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.
10 changes: 10 additions & 0 deletions tests/fixtures/analysis/nested/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
load("//dokka:defs.bzl", "dokka")
load("//tests/fixtures:common.bzl", "FIXTURE_TAGS")

package(default_visibility = ["//tests:__subpackages__"])

dokka(
name = "docs",
srcs = ["Nested.kt"],
tags = FIXTURE_TAGS,
)
File renamed without changes.
8 changes: 8 additions & 0 deletions tests/fixtures/common.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""Common definitions used by test fixtures."""

# Fixture targets are analyzed by tests or consumed as test data. They should
# not be selected as runnable test entry points themselves.
FIXTURE_TAGS = [
"manual",
"notap",
]
Loading