Skip to content

Commit 950fe96

Browse files
committed
test: keep TV Hilt imports single-owned
1 parent 38285ad commit 950fe96

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

tests/native_reader_runtime_bootstrap_test.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
sys.path.insert(0, str(SCRIPTS))
1111

1212
from augment_native_corpus_request_contract import kotlin_map # noqa: E402
13-
from augment_native_provider_loading import platform_set_literal, repository_helpers, tv_helpers # noqa: E402
13+
from augment_native_provider_loading import insert_imports, platform_set_literal, repository_helpers, tv_helpers # noqa: E402
14+
from native_player_diagnostics_codegen import TV_IMPORTS # noqa: E402
1415
from nuvio_tv_test_bootstrap import enable_tv_tests # noqa: E402
1516

1617
request_contract = (SCRIPTS / "augment_native_corpus_request_contract.py").read_text(encoding="utf-8")
@@ -45,6 +46,23 @@
4546
assert "emptyMap<String, com.nuvio.tv.domain.model.ScraperInfo>()" in provider_loading
4647
assert "emptyMap<String, PluginScraper>()" in provider_loading
4748

49+
# Player and repository augmentation are two layers of one generated TV test.
50+
# Repository loading owns their shared Hilt/Flow imports; the player layer must
51+
# never emit a second copy (the official 0.8.7 Kotlin compiler rejects duplicates).
52+
layered_tv_imports = insert_imports(
53+
"import androidx.test.platform.app.InstrumentationRegistry\n" + TV_IMPORTS,
54+
"tv",
55+
)
56+
for shared_import in (
57+
"import dagger.hilt.EntryPoint\n",
58+
"import dagger.hilt.InstallIn\n",
59+
"import dagger.hilt.android.EntryPointAccessors\n",
60+
"import dagger.hilt.components.SingletonComponent\n",
61+
"import kotlinx.coroutines.flow.first\n",
62+
):
63+
assert shared_import not in TV_IMPORTS, shared_import
64+
assert layered_tv_imports.count(shared_import) == 1, shared_import
65+
4866
# NuvioTV instrumentation bootstrap is a structural contract, never a client
4967
# version contract. The official client advanced from 0.8.4 to 0.8.7 and exposed
5068
# why anchoring on versionName was wrong. Future version bumps must remain valid.
@@ -98,6 +116,6 @@
98116

99117
print(
100118
"native reader runtime bootstrap contract passed: "
101-
"tv_explicit_pairs=true generated_empty_generics_typed=true tv_version_agnostic_bootstrap=true "
102-
"mobile_real_app=true desktop_ordinary_jvm_policy=true"
119+
"tv_explicit_pairs=true generated_empty_generics_typed=true tv_single_owner_hilt_imports=true "
120+
"tv_version_agnostic_bootstrap=true mobile_real_app=true desktop_ordinary_jvm_policy=true"
103121
)

0 commit comments

Comments
 (0)