From d9b602a2af0090614ef4fee736516aa98a013a12 Mon Sep 17 00:00:00 2001 From: James Wainwright Date: Fri, 23 Aug 2024 12:08:26 +0100 Subject: [PATCH] Add test module which uses the rule Checks that the rule is usable, but doesn't necessary test that it's checking the correct files. Signed-off-by: James Wainwright --- .bazelignore | 1 + tests/.gitignore | 1 + tests/BUILD | 16 ++++++++++++++++ tests/MODULE.bazel | 13 +++++++++++++ tests/WORKSPACE | 17 +++++++++++++++++ tests/file_with_licence.txt | 5 +++++ tests/file_without_licence.txt | 1 + 7 files changed, 54 insertions(+) create mode 100644 .bazelignore create mode 100644 tests/.gitignore create mode 100644 tests/BUILD create mode 100644 tests/MODULE.bazel create mode 100644 tests/WORKSPACE create mode 100644 tests/file_with_licence.txt create mode 100644 tests/file_without_licence.txt diff --git a/.bazelignore b/.bazelignore new file mode 100644 index 0000000..2b29f27 --- /dev/null +++ b/.bazelignore @@ -0,0 +1 @@ +tests diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..648fc0e --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1 @@ +MODULE.bazel.lock diff --git a/tests/BUILD b/tests/BUILD new file mode 100644 index 0000000..bbb5512 --- /dev/null +++ b/tests/BUILD @@ -0,0 +1,16 @@ +# Copyright lowRISC contributors. +# Licensed under the Apache License, Version 2.0, see LICENSE for details. +# SPDX-License-Identifier: Apache-2.0 + +load("@lowrisc_misc_linters//rules:rules.bzl", "licence_test") + +licence_test( + name = "licence_check", + exclude_patterns = ["file_without_licence.txt"], + licence = """ + Copyright lowRISC contributors. + Licensed under the Apache License, Version 2.0, see LICENSE for details. + SPDX-License-Identifier: Apache-2.0 + """, + workspace = ":MODULE.bazel", +) diff --git a/tests/MODULE.bazel b/tests/MODULE.bazel new file mode 100644 index 0000000..076dc60 --- /dev/null +++ b/tests/MODULE.bazel @@ -0,0 +1,13 @@ +# Copyright lowRISC contributors. +# Licensed under the Apache License, Version 2.0, see LICENSE for details. +# SPDX-License-Identifier: Apache-2.0 + +module(name = "lowrisc_misc_linters_tests") + +bazel_dep(name = "lowrisc_misc_linters") +local_path_override(module_name = "lowrisc_misc_linters", path = "../") + +bazel_dep(name = "rules_python", version = "0.34.0") +python = use_extension("@rules_python//python/extensions:python.bzl", "python") +python.toolchain(python_version = "3.9") + diff --git a/tests/WORKSPACE b/tests/WORKSPACE new file mode 100644 index 0000000..9d4e96b --- /dev/null +++ b/tests/WORKSPACE @@ -0,0 +1,17 @@ +# Copyright lowRISC contributors. +# Licensed under the Apache License, Version 2.0, see LICENSE for details. +# SPDX-License-Identifier: Apache-2.0 + +local_repository( + name = "lowrisc_misc_linters", + path = "..", +) + +load("@lowrisc_misc_linters//rules:repos.bzl", "lowrisc_misc_linters_repos") +lowrisc_misc_linters_repos() +load("@lowrisc_misc_linters//rules:deps.bzl", "lowrisc_misc_linters_dependencies") +lowrisc_misc_linters_dependencies() +load("@lowrisc_misc_linters//rules:pip.bzl", "lowrisc_misc_linters_pip_dependencies") +lowrisc_misc_linters_pip_dependencies() +load("@lowrisc_misc_linters_pip//:requirements.bzl", "install_deps") +install_deps() diff --git a/tests/file_with_licence.txt b/tests/file_with_licence.txt new file mode 100644 index 0000000..4ade057 --- /dev/null +++ b/tests/file_with_licence.txt @@ -0,0 +1,5 @@ +# Copyright lowRISC contributors. +# Licensed under the Apache License, Version 2.0, see LICENSE for details. +# SPDX-License-Identifier: Apache-2.0 + +This file has a licence! diff --git a/tests/file_without_licence.txt b/tests/file_without_licence.txt new file mode 100644 index 0000000..2769225 --- /dev/null +++ b/tests/file_without_licence.txt @@ -0,0 +1 @@ +This file intentionally has no licence.