diff options
author | Tomasz Wojno <tomasz.wojno@sandboxquantum.com> | 2023-10-16 10:17:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-16 13:17:36 -0400 |
commit | cdaa05f3457c7ea0a6b26fb1e575e2d91d3d918b (patch) | |
tree | edbf0be9433af1dac95b635b19f7f1edce76ef3c | |
parent | 7defd216955d46e6520f56b30bb534c7274f85a6 (diff) | |
download | rules_pkg-cdaa05f3457c7ea0a6b26fb1e575e2d91d3d918b.tar.gz |
Align pkg_rpm returned files with other rules (#692)
* Align pkg_rpm returned files with other rules
pkg_rpm returns the package file named after `package_file_name` and a
symbolic link to the file called `target_name`, while other rules do
not return the symbolic link.
* Merge branch 'bazelbuild:main' into main
-rw-r--r-- | pkg/rpm_pfg.bzl | 2 | ||||
-rw-r--r-- | tests/rpm/BUILD | 4 | ||||
-rw-r--r-- | tests/rpm/analysis_tests.bzl | 22 | ||||
-rw-r--r-- | tests/rpm/pkg_rpm_basic_test.py | 6 | ||||
-rw-r--r-- | tests/rpm/source_date_epoch/BUILD | 4 | ||||
-rw-r--r-- | tests/rpm/tree_artifacts/BUILD | 4 |
6 files changed, 21 insertions, 21 deletions
diff --git a/pkg/rpm_pfg.bzl b/pkg/rpm_pfg.bzl index 194af83..28c5b2d 100644 --- a/pkg/rpm_pfg.bzl +++ b/pkg/rpm_pfg.bzl @@ -675,7 +675,7 @@ def _pkg_rpm_impl(ctx): return [ OutputGroupInfo(**output_groups), DefaultInfo( - files = depset(outputs), + files = depset([output_file]), ), ] diff --git a/tests/rpm/BUILD b/tests/rpm/BUILD index 5f91da8..a8d008a 100644 --- a/tests/rpm/BUILD +++ b/tests/rpm/BUILD @@ -151,7 +151,7 @@ pkg_rpm( # Just like the above one, except the compression is changed. pkg_rpm( - name = "test_rpm-bzip2", + name = "test_rpm_bzip2", srcs = [ ":test_pfg", ], @@ -305,7 +305,7 @@ sh_library( testonly = True, srcs = [ ":test_rpm", - ":test_rpm-bzip2", + ":test_rpm_bzip2", ":test_rpm_direct", ":test_rpm_manifest", ":test_rpm_metadata", diff --git a/tests/rpm/analysis_tests.bzl b/tests/rpm/analysis_tests.bzl index 0cec5a8..3565b47 100644 --- a/tests/rpm/analysis_tests.bzl +++ b/tests/rpm/analysis_tests.bzl @@ -182,8 +182,9 @@ def _package_naming_test_impl(ctx): # Try to find the expected files in the DefaultInfo. out_file_found = False rpm_file_found = False - changes_file_found = False if changes_file else True + changes_file_found = False default_name_found = False + for f in target_under_test[DefaultInfo].files.to_list(): if f == out_file: out_file_found = True @@ -191,20 +192,20 @@ def _package_naming_test_impl(ctx): rpm_file_found = True if f == changes_file: changes_file_found = True - elif f.basename == ctx.attr.expected_default_name and not default_name_found: + if f.basename == ctx.attr.expected_name: default_name_found = True asserts.true( env, - out_file_found, - "out component of OutputGroupInfo '{}' is not in DefaultInfo".format(out_file), - ) - asserts.true( - env, rpm_file_found, "rpm component of OutputGroupInfo '{}' is not in DefaultInfo".format(rpm_file), ) - asserts.true( + asserts.false( + env, + out_file_found, + "out component of OutputGroupInfo '{}' is not in DefaultInfo".format(out_file), + ) + asserts.false( env, changes_file_found, "changes component of OutputGroupInfo '{}' is not in DefaultInfo".format(changes_file), @@ -212,7 +213,7 @@ def _package_naming_test_impl(ctx): asserts.true( env, default_name_found, - "Expected package file with default name '{}' is not in DefaultInfo".format(ctx.attr.expected_default_name), + "Expected package file with default name '{}' is not in DefaultInfo".format(ctx.attr.expected_name), ) return analysistest.end(env) @@ -221,7 +222,6 @@ package_naming_test = analysistest.make( _package_naming_test_impl, attrs = { "expected_name": attr.string(), - "expected_default_name": attr.string(), }, ) @@ -262,7 +262,6 @@ def _test_naming(name): name = name + "_no_extra", target_under_test = ":" + name + "_no_extra_rpm", expected_name = name + "_no_extra_rpm-1.0-1.noarch.rpm", - expected_default_name = name + "_no_extra_rpm" + ".rpm", ) ################################################## @@ -286,7 +285,6 @@ def _test_naming(name): name = name + "_with_different_name", target_under_test = ":" + name + "_with_different_name_rpm", expected_name = name + "-foo-bar.rpm", - expected_default_name = name + "_with_different_name_rpm" + ".rpm", ) ################################################## diff --git a/tests/rpm/pkg_rpm_basic_test.py b/tests/rpm/pkg_rpm_basic_test.py index 8569f48..990fc4f 100644 --- a/tests/rpm/pkg_rpm_basic_test.py +++ b/tests/rpm/pkg_rpm_basic_test.py @@ -43,11 +43,11 @@ class PkgRpmBasicTest(unittest.TestCase): def setUp(self): self.runfiles = runfiles.Create() self.test_rpm_path = self.runfiles.Rlocation( - "rules_pkg/tests/rpm/test_rpm.rpm") + "rules_pkg/tests/rpm/test_rpm-1.1.1-2222.noarch.rpm") self.test_rpm_direct_path = self.runfiles.Rlocation( - "rules_pkg/tests/rpm/test_rpm_direct.rpm") + "rules_pkg/tests/rpm/test_rpm_direct-1.1.1-2222.noarch.rpm") self.test_rpm_bzip2_path = self.runfiles.Rlocation( - "rules_pkg/tests/rpm/test_rpm-bzip2.rpm") + "rules_pkg/tests/rpm/test_rpm_bzip2-1.1.1-2222.noarch.rpm") self.maxDiff = None def test_scriptlet_content(self): diff --git a/tests/rpm/source_date_epoch/BUILD b/tests/rpm/source_date_epoch/BUILD index c6baced..156f844 100644 --- a/tests/rpm/source_date_epoch/BUILD +++ b/tests/rpm/source_date_epoch/BUILD @@ -28,7 +28,7 @@ py_test( name = "source_date_epoch_insource", srcs = ["rpm_contents_vs_manifest_test.py"], data = [":rpm_sde_insource_data"], - env = {"TEST_RPM": "rpm_sde_insource.rpm"}, + env = {"TEST_RPM": "rpm_sde_insource-1.1.1-2222.noarch.rpm"}, main = "rpm_contents_vs_manifest_test.py", tags = [ "no_windows", # Windows doesn't have rpm(8) or rpmbuild(8) @@ -94,7 +94,7 @@ py_test( name = "source_date_epoch_from_file", srcs = ["rpm_contents_vs_manifest_test.py"], data = [":rpm_sde_fromfile_data"], - env = {"TEST_RPM": "rpm_sde_fromfile.rpm"}, + env = {"TEST_RPM": "rpm_sde_fromfile-1.1.1-2222.noarch.rpm"}, main = "rpm_contents_vs_manifest_test.py", tags = [ "no_windows", # Windows doesn't have rpm(8) or rpmbuild(8) diff --git a/tests/rpm/tree_artifacts/BUILD b/tests/rpm/tree_artifacts/BUILD index 04d7d8e..f962faa 100644 --- a/tests/rpm/tree_artifacts/BUILD +++ b/tests/rpm/tree_artifacts/BUILD @@ -48,6 +48,7 @@ py_test( tags = [ "no_windows", # Windows doesn't have rpm(8) or rpmbuild(8) ], + env = {"TEST_RPM": "test_dirs_rpm-1.1.1-2222.noarch.rpm"}, deps = [ "//tests/rpm:rpm_util", "@rules_python//python/runfiles", @@ -152,7 +153,7 @@ py_test( name = "layer_with_files_reversed", srcs = ["rpm_contents_vs_manifest_test.py"], data = [":layer_with_files_reversed_test_data"], - env = {"TEST_RPM": "test_dirs_rpm_reversed.rpm"}, + env = {"TEST_RPM": "test_dirs_rpm_reversed-1.1.1-2222.noarch.rpm"}, main = "rpm_contents_vs_manifest_test.py", tags = [ "no_windows", # Windows doesn't have rpm(8) or rpmbuild(8) @@ -205,6 +206,7 @@ py_test( srcs = ["rpm_treeartifact_ops_test.py"], data = [":treeartifact_ops_rpm_test_data"], main = "rpm_treeartifact_ops_test.py", + env = {"TEST_RPM": "treeartifact_ops_rpm-1.1.1-2222.noarch.rpm"}, tags = [ "no_windows", # Windows doesn't have rpm(8) or rpmbuild(8) ], |