xref: /aosp_15_r20/external/bazelbuild-rules_android/test/rules/android_revision/BUILD (revision 9e965d6fece27a77de5377433c2f7e6999b8cc0b)
1# Description:
2#   Tests for the AndroidRevisionInfo provider.
3
4load(":test.bzl", "android_revision_comparision_test", "android_revision_test")
5load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
6
7licenses(["notice"])
8
9# Test revision string parsing.
10# buildifier: leave-alone
11android_revision_test(
12    name = "version_1.2.3",
13    input = "1.2.3",
14    expected_major = 1,
15    expected_minor = 2,
16    expected_micro = 3,
17    expected_version = "1.2.3",
18    expected_dir = "1.2.3",
19)
20
21# buildifier: leave-alone
22android_revision_test(
23    name = "micro_missing",
24    input = "1.2",
25    expected_major = 1,
26    expected_minor = 2,
27    expected_micro = 0,
28    expected_version = "1.2",
29    expected_dir = "1.2",
30)
31
32# buildifier: leave-alone
33android_revision_test(
34    name = "minor_missing",
35    input = "1",
36    expected_major = 1,
37    expected_minor = 0,
38    expected_micro = 0,
39    expected_version = "1",
40    expected_dir = "1",
41)
42
43# Test revision comparisions.
44VERSIONS = [
45    ("2.0.0", "1.0.0"),
46    ("12.0.0", "11.0.0"),
47    ("1.1.0", "1.0.0"),
48    ("1.0.1", "1.0.0"),
49    ("1.1.1", "1.0.1"),
50    ("2", "1"),
51    ("2.1", "2"),
52    ("2", "1.0"),
53    # TODO(katre): Re-add when previews are supported.
54    #("1.1.0-rc1", "1.0.0-rc1"),
55    #("1.1.0-alpha1", "1.0.0-rc1"),
56    #("1.0.0", "1.0.0-rc1"),
57    #("1.0.0", "1.0.0-rc2"),
58    #("1.0.0", "1.0.0-alpha1"),
59    #("1.0.0", "1.0.0-alpha2"),
60    #("1.0.0", "1.0.0-beta1"),
61    #("1.0.0", "1.0.0-beta2"),
62    #("1.0.0-rc1", "1.0.0-beta1"),
63    #("1.0.0-beta1", "1.0.0-alpha1"),
64    #("1.0.0-beta1", "1.0.0-alpha2"),
65    #("1.0.0-rc2", "1.0.0-rc1"),
66    #("1.0.0-beta2", "1.0.0-beta1"),
67    #("1.0.0-alpha2", "1.0.0-alpha1"),
68    #("1 rc1", "1 beta1"),
69]
70
71[
72    android_revision_comparision_test(
73        name = "compare_%s_%s" % (higher, lower),
74        higher = higher,
75        lower = lower,
76    )
77    for (higher, lower) in VERSIONS
78]
79
80bzl_library(
81    name = "bzl",
82    srcs = glob(["*.bzl"]),
83    visibility = ["//visibility:private"],
84)
85