bazelbuild / rules_pkg

Bazel rules for creating packages of many types (zip, tar, deb, rpm, ...)
Apache License 2.0
216 stars 174 forks source link

`verify_archive_test` refers to non-existent package `pkg` #704

Closed sschwebach closed 1 year ago

sschwebach commented 1 year ago

In experimenting with the new verify_archive_test macro I noticed using it outside of rules_pkg itself would lead to a loading error.

Example rules_pkg_test/BUILD:

load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("@rules_pkg//pkg:verify_archive.bzl", "verify_archive_test")

pkg_tar(
    name = "external_archive",
    srcs = ["file.txt"],
)

verify_archive_test(
    name = "external_archive_test",
    max_size = 1,
    min_size = 1,
    must_contain = ["file.txt"],
    target = ":external_archive",
)

When building/testing the external_archive_test target Bazel produces the following output (line numbers omitted):

rules_pkg_test/BUILD: no such package 'pkg': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
 - ~/rules_pkg_test/pkg and referenced by '//:external_archive_test'

It appears the verify_archive_test macro is evaluating "//pkg:verify_archive_test_lib" inside the caller's BUILD context instead of within rules_pkg.