• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2023 The Bazel Authors. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import os
16import pathlib
17import subprocess
18import unittest
19
20from python.runfiles import runfiles
21
22
23class ExampleTest(unittest.TestCase):
24    def test_entry_point(self):
25        rlocation_path = os.environ.get("YAMLLINT_ENTRY_POINT")
26        assert (
27            rlocation_path is not None
28        ), "expected 'YAMLLINT_ENTRY_POINT' env variable to be set to rlocation of the tool"
29
30        entry_point = pathlib.Path(runfiles.Create().Rlocation(rlocation_path))
31        self.assertTrue(entry_point.exists(), f"'{entry_point}' does not exist")
32
33        proc = subprocess.run(
34            [str(entry_point), "--version"],
35            check=True,
36            stdout=subprocess.PIPE,
37            stderr=subprocess.PIPE,
38        )
39        self.assertEqual(proc.stdout.decode("utf-8").strip(), "yamllint 1.28.0")
40
41
42if __name__ == "__main__":
43    unittest.main()
44