diff options
Diffstat (limited to 'distro/packaging_test.py')
-rw-r--r-- | distro/packaging_test.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/distro/packaging_test.py b/distro/packaging_test.py index e89bdd0..38c34c8 100644 --- a/distro/packaging_test.py +++ b/distro/packaging_test.py @@ -15,10 +15,11 @@ """Test that the rules_pkg distribution is usable.""" import os +import re import subprocess import unittest -from bazel_tools.tools.python.runfiles import runfiles +from python.runfiles import runfiles from pkg.releasing import release_tools from distro import release_version @@ -34,6 +35,24 @@ class PackagingTest(unittest.TestCase): self.dest_repo = 'not_named_rules_pkg' self.version = release_version.RELEASE_VERSION + def testVersionsMatch(self): + """version.bzl must match MODULE.bazel""" + module_bazel_path = self.data_files.Rlocation( + 'rules_pkg/MODULE.bazel') + with open(module_bazel_path, encoding="utf-8") as inp: + want = 'version = "%s"' % self.version + content = inp.read() + if _VERBOSE: + print('=== Expect', want) + module_block_re = re.compile + m = re.search( + r"""module\([^)]+\)""", + content, + flags=re.MULTILINE|re.DOTALL) + self.assertTrue(m) + got = m.group() + self.assertIn(want, got, 'Expected <%s>, got <%s>' % (want, got)) + def testBuild(self): # Set up a fresh Bazel workspace using the currently build repo. tempdir = os.path.join(os.environ['TEST_TMPDIR'], 'build') |