Skip to content

Commit

Permalink
Convert pkg_deb tests from shell to python (#211)
Browse files Browse the repository at this point in the history
* Replace build_deb_test.sh with pkg_deb_test.py
* enable deb test on macos and windows
* remove third_party bashunit
* test needs hack on windows for  #213 and #214
  • Loading branch information
aiuto authored Aug 7, 2020
1 parent dbd2c4b commit 933fa6f
Show file tree
Hide file tree
Showing 7 changed files with 240 additions and 1,075 deletions.
6 changes: 3 additions & 3 deletions .bazelci/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ tasks:
working_directory: ../pkg
test_targets:
- "..."
# This uses dpkg-deb(1), which is not available by default in macOS
- "-//tests:build_test_deb"
# rpmbuild(8) is not available by default on macOS
- "-//tests:make_rpm_test"
- "-//experimental/tests:pkg_rpm_basic_test"
windows:
working_directory: ../pkg
# We can not build any RPM files or do the .deb tests.
# We can not build any RPM files.
# Also, many other tests are simply broken on windows. So we start with the
# one that works and can add to the list as we fix the broken behavior or
# broken test.
test_targets:
- "//tests:zip_test"
- "//tests:pkg_deb_test"

30 changes: 10 additions & 20 deletions pkg/tests/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-

licenses(["notice"])

load("//:pkg.bzl", "pkg_deb", "pkg_tar", "pkg_zip")
Expand Down Expand Up @@ -176,12 +177,6 @@ py_test(
],
)

genrule(
name = "test-deb-preinst",
outs = ["test-deb.preinst"],
cmd = "echo -n \"#!/usr/bin/env bash\n# tete ®, Й, ק ,م, ๗, あ, 叶, 葉, 말, ü and é\necho fnord\" > \"$@\"",
)

pkg_deb(
name = "test-deb",
breaks = ["oldbrokenpkg"],
Expand All @@ -201,7 +196,7 @@ pkg_deb(
maintainer = "somé[email protected]",
make_deb = "//:make_deb",
package = "titi",
preinst = ":test-deb-preinst",
preinst = "testdata/deb_preinst",
replaces = ["oldpkg"],
templates = ":testdata/templates",
urgency = "low",
Expand Down Expand Up @@ -236,7 +231,7 @@ pkg_deb(
maintainer = "somé[email protected]",
make_deb = "//:make_deb_py2",
package = "titi",
preinst = ":test-deb-preinst",
preinst = "testdata/deb_preinst",
replaces = ["oldpkg"],
templates = ":testdata/templates",
urgency = "low",
Expand Down Expand Up @@ -370,25 +365,20 @@ py_test(
python_version = "PY3",
)

sh_test(
name = "build_test_deb",
py_test(
name = "pkg_deb_test",
size = "medium",
srcs = [
"build_test_deb.sh",
"pkg_deb_test.py",
],
python_version = "PY3",
data = [
"testenv.sh",
":test-deb.deb",
":test-deb-py2.deb",
":titi_test_all.deb",
":titi_test_all.changes",
],
tags = [
# dpkg tools are only available on debian
"no_macos",
"no_windows",
],
deps = [
"@rules_pkg//third_party/bazel/src/test/shell:bashunit",
"//:archive",
"@bazel_tools//tools/python/runfiles",
],
)

Expand Down
172 changes: 0 additions & 172 deletions pkg/tests/build_test_deb.sh

This file was deleted.

Loading

0 comments on commit 933fa6f

Please sign in to comment.