Skip to content

Commit

Permalink
Reapply "Bug 1906941 - Update kotlin jinja template import statement (#…
Browse files Browse the repository at this point in the history
…740)"

This reverts commit 6404b29.
  • Loading branch information
badboy committed Aug 14, 2024
1 parent a3e988c commit 98fbc26
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- **Breaking change:** Updating Kotlin template import statement as part of removing `service-glean` from Android Components. ([bug 1906941](https://bugzilla.mozilla.org/show_bug.cgi?id=1906941))

## 14.5.2

- Revert updating Kotlin template import statement as part of removing `service-glean` from Android Components.
Expand Down
4 changes: 2 additions & 2 deletions glean_parser/templates/kotlin.geckoview.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package {{ namespace }}

import {{ glean_namespace }}.private.BooleanMetricType // ktlint-disable import-ordering no-unused-imports
import {{ glean_namespace }}.private.CounterMetricType // ktlint-disable import-ordering no-unused-imports
import {{ glean_namespace }}.private.HistogramMetricBase // ktlint-disable import-ordering no-unused-imports
import {{ glean_namespace }}.private.HistogramBase // ktlint-disable import-ordering no-unused-imports
import {{ glean_namespace }}.private.LabeledMetricType // ktlint-disable import-ordering no-unused-imports
import {{ glean_namespace }}.private.QuantityMetricType // ktlint-disable import-ordering no-unused-imports
import {{ glean_namespace }}.private.StringMetricType // ktlint-disable import-ordering no-unused-imports
Expand All @@ -28,7 +28,7 @@ internal object GleanGeckoMetricsMapping {
// Support exfiltration of Gecko histograms from products using both the
// Glean SDK and GeckoView. See bug 1566356 for more context.
@Suppress("UNUSED_PARAMETER")
fun getHistogram(geckoMetricName: String): HistogramMetricBase? {
fun getHistogram(geckoMetricName: String): HistogramBase? {
{% if 'histograms' in gecko_metrics %}
return when (geckoMetricName) {
{% for category in gecko_metrics['histograms'].keys()|sort %}
Expand Down
6 changes: 3 additions & 3 deletions tests/test_kotlin.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,13 @@ def test_gecko_datapoints(tmp_path):
with (tmp_path / "GleanGeckoMetricsMapping.kt").open("r", encoding="utf-8") as fd:
content = fd.read()
# Make sure we're adding the relevant Glean SDK import, once.
assert content.count("import Bar.private.HistogramMetricBase") == 1
assert content.count("import Bar.private.HistogramBase") == 1

# Validate the generated Gecko metric mapper Kotlin functions.
# NOTE: Indentation, whitespaces and text formatting of the block
# below are important. Do not change them unless the file format
# changes, otherwise validation will fail.
expected_func = """ fun getHistogram(geckoMetricName: String): HistogramMetricBase? {
expected_func = """ fun getHistogram(geckoMetricName: String): HistogramBase? {
return when (geckoMetricName) {
// From GfxContentCheckerboard.kt
"CHECKERBOARD_DURATION" -> GfxContentCheckerboard.duration
Expand Down Expand Up @@ -338,7 +338,7 @@ def test_gecko_datapoints(tmp_path):
for file_name in metrics_files:
with (tmp_path / file_name).open("r", encoding="utf-8") as fd:
content = fd.read()
assert "HistogramMetricBase" not in content
assert "HistogramBase" not in content

run_linters(tmp_path.glob("*.kt"))

Expand Down

0 comments on commit 98fbc26

Please sign in to comment.