Skip to content

Commit

Permalink
Test defaults recipe behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
TimoWilken committed Dec 12, 2023
1 parent 7ffe0b6 commit c118d5b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
package: defaults-release
version: v1
---
: this line should trigger a warning
"""
TEST_DEFAULT_RELEASE_BUILD_HASH = "27ce49698e818e8efb56b6eff6dd785e503df341"

Expand Down Expand Up @@ -206,6 +207,7 @@ class BuildTestCase(unittest.TestCase):
@patch("alibuild_helpers.build.sys")
@patch("alibuild_helpers.build.dieOnError", new=MagicMock())
@patch("alibuild_helpers.utilities.dieOnError", new=MagicMock())
@patch("alibuild_helpers.utilities.warning")
@patch("alibuild_helpers.build.readDefaults",
new=MagicMock(return_value=(OrderedDict({"package": "defaults-release", "disable": []}), "")))
@patch("alibuild_helpers.build.makedirs", new=MagicMock(return_value=None))
Expand All @@ -225,9 +227,10 @@ class BuildTestCase(unittest.TestCase):
@patch("alibuild_helpers.workarea.is_writeable", new=MagicMock(return_value=True))
@patch("alibuild_helpers.build.basename", new=MagicMock(return_value="aliBuild"))
@patch("alibuild_helpers.build.install_wrapper_script", new=MagicMock())
def test_coverDoBuild(self, mock_debug, mock_glob, mock_sys, mock_git_git):
def test_coverDoBuild(self, mock_debug, mock_glob, mock_warning, mock_sys, mock_git_git):
mock_git_git.side_effect = dummy_git
mock_debug.side_effect = lambda *args: None
mock_warning.side_effect = lambda *args: None
mock_glob.side_effect = lambda x: {
"*": ["zlib"],
"/sw/TARS/osx_x86-64/defaults-release/defaults-release-v1-*.osx_x86-64.tar.gz": ["/sw/TARS/osx_x86-64/defaults-release/defaults-release-v1-1.osx_x86-64.tar.gz"],
Expand Down Expand Up @@ -286,18 +289,22 @@ def test_coverDoBuild(self, mock_debug, mock_glob, mock_sys, mock_git_git):

mock_git_git.reset_mock()
mock_debug.reset_mock()
mock_warning.reset_mock()
exit_code = doBuild(args, mock_parser)
self.assertEqual(exit_code, 0)
mock_warning.assert_called_with("%s.sh contains a recipe, which will be ignored", "defaults-release")
mock_debug.assert_called_with("Everything done")
self.assertEqual(mock_git_git.call_count, len(common_calls))
mock_git_git.assert_has_calls(common_calls, any_order=True)

# Force fetching repos
mock_git_git.reset_mock()
mock_debug.reset_mock()
mock_warning.reset_mock()
args.fetchRepos = True
exit_code = doBuild(args, mock_parser)
self.assertEqual(exit_code, 0)
mock_warning.assert_called_with("%s.sh contains a recipe, which will be ignored", "defaults-release")
mock_debug.assert_called_with("Everything done")
mock_glob.assert_called_with("/sw/TARS/osx_x86-64/ROOT/ROOT-v6-08-30-*.osx_x86-64.tar.gz")
# We can't compare directly against the list of calls here as they
Expand All @@ -311,7 +318,7 @@ def setup_spec(self, script):
"""Parse the alidist recipe in SCRIPT and return its spec."""
err, spec, recipe = parseRecipe(lambda: script)
self.assertIsNone(err)
spec["recipe"] = recipe.strip("\n")
spec["recipe"] = "" if spec["package"].startswith("defaults-") else recipe.strip("\n")
spec.setdefault("tag", spec["version"])
spec["tag"] = resolve_tag(spec)
return spec
Expand Down

0 comments on commit c118d5b

Please sign in to comment.