Exemple #1
0
    def test_coverDoBuild(self, mock_is_writeable, mock_getStatusOutputBash,
                          mock_banner, mock_readlink, mock_glob, mock_shutil,
                          mock_open, mock_utilities_open, mock_debug,
                          mock_makedirs, mock_read_defaults, mock_die,
                          mock_sys, mock_workarea_exists, mock_exists,
                          mock_getstatusoutput, mock_workarea_execute,
                          mock_execute, mock_get):
        mock_readlink.side_effect = dummy_readlink
        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"
            ],
            "/sw/TARS/osx_x86-64/zlib/zlib-v1.2.3-*.osx_x86-64.tar.gz": [],
            "/sw/TARS/osx_x86-64/ROOT/ROOT-v6-08-30-*.osx_x86-64.tar.gz": [],
            "/sw/TARS/osx_x86-64/store/27/27ce49698e818e8efb56b6eff6dd785e503df341/*":
            [],
            "/sw/TARS/osx_x86-64/store/3e/3e90b4e08bad439fa5f25282480d1adb9efb0c0d/*":
            [],
            "/sw/TARS/osx_x86-64/store/%s/%s/*" % (TEST_ROOT_BUILD_HASH[0:2], TEST_ROOT_BUILD_HASH):
            [],
            "/sw/TARS/osx_x86-64/defaults-release/defaults-release-v1-1.osx_x86-64.tar.gz":
            [
                "../../osx_x86-64/store/27/27ce49698e818e8efb56b6eff6dd785e503df341/defaults-release-v1-1.osx_x86-64.tar.gz"
            ],
        }[x]
        os.environ["ALIBUILD_NO_ANALYTICS"] = "1"
        mock_utilities_open.side_effect = lambda x: {
            "/alidist/root.sh": StringIO(TEST_ROOT_RECIPE),
            "/alidist/zlib.sh": StringIO(TEST_ZLIB_RECIPE),
            "/alidist/defaults-release.sh": StringIO(TEST_DEFAULT_RELEASE)
        }[x]
        mock_is_writeable.side_effect = lambda x: True
        mock_open.side_effect = dummy_open

        mock_git_clone = MagicMock(return_value=None)
        mock_git_fetch = MagicMock(return_value=None)
        mock_execute.side_effect = lambda x, **kwds: dummy_execute(
            x, mock_git_clone, mock_git_fetch, **kwds)
        mock_workarea_execute.side_effect = lambda x, **kwds: dummy_execute(
            x, mock_git_clone, mock_git_fetch, **kwds)

        mock_exists.side_effect = dummy_exists
        mock_workarea_exists.side_effect = dummy_exists
        mock_getstatusoutput.side_effect = dummy_getstatusoutput
        mock_getStatusOutputBash.side_effect = dummy_getStatusOutputBash
        mock_parser = MagicMock()
        mock_read_defaults.return_value = (OrderedDict({
            "package": "defaults-release",
            "disable": []
        }), "")
        args = Namespace(remoteStore="",
                         writeStore="",
                         referenceSources="/sw/MIRROR",
                         docker=False,
                         architecture="osx_x86-64",
                         workDir="/sw",
                         pkgname=["root"],
                         configDir="/alidist",
                         disable=[],
                         defaults="release",
                         jobs=2,
                         preferSystem=[],
                         noSystem=False,
                         debug=True,
                         dryRun=False,
                         aggressiveCleanup=False,
                         environment={},
                         autoCleanup=False,
                         noDevel=[],
                         fetchRepos=False)
        mock_sys.version_info = sys.version_info

        mock_git_clone.reset_mock()
        mock_git_fetch.reset_mock()
        fmt, msg, code = doBuild(args, mock_parser)
        self.assertEqual(
            mock_git_clone.call_count, 1,
            "Expected only one call to git clone (called %d times instead)" %
            mock_git_clone.call_count)
        self.assertEqual(
            mock_git_fetch.call_count, 0,
            "Expected only no calls to git fetch (called %d times instead)" %
            mock_git_fetch.call_count)

        # Force fetching repos
        mock_git_clone.reset_mock()
        mock_git_fetch.reset_mock()
        args.fetchRepos = True
        fmt, msg, code = doBuild(args, mock_parser)
        mock_glob.assert_called_with(
            "/sw/TARS/osx_x86-64/ROOT/ROOT-v6-08-30-*.osx_x86-64.tar.gz")
        self.assertEqual(msg, "Everything done")
        self.assertEqual(
            mock_git_clone.call_count, 1,
            "Expected only one call to git clone (called %d times instead)" %
            mock_git_clone.call_count)
        self.assertEqual(
            mock_git_fetch.call_count, 1,
            "Expected only one call to git fetch (called %d times instead)" %
            mock_git_fetch.call_count)
Exemple #2
0
  def test_coverDoBuild(self, mock_is_writeable, mock_getStatusOutputBash, mock_banner,
                              mock_readlink, mock_glob, mock_shutil, mock_open, mock_utilities_open,
                              mock_debug, mock_makedirs, mock_read_defaults, mock_die, mock_sys,
                              mock_workarea_exists, mock_exists, mock_getstatusoutput,
                              mock_workarea_execute, mock_execute, mock_urlopen):
    mock_readlink.side_effect = dummy_readlink
    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"],
        "/sw/TARS/osx_x86-64/zlib/zlib-v1.2.3-*.osx_x86-64.tar.gz": [],
        "/sw/TARS/osx_x86-64/ROOT/ROOT-v6-08-30-*.osx_x86-64.tar.gz": [],
        "/sw/TARS/osx_x86-64/store/27/27ce49698e818e8efb56b6eff6dd785e503df341/*": [],
        "/sw/TARS/osx_x86-64/store/3e/3e90b4e08bad439fa5f25282480d1adb9efb0c0d/*": [],
        "/sw/TARS/osx_x86-64/store/%s/%s/*" % (TEST_ROOT_BUILD_HASH[0:2], TEST_ROOT_BUILD_HASH): [],
        "/sw/TARS/osx_x86-64/defaults-release/defaults-release-v1-1.osx_x86-64.tar.gz": ["../../osx_x86-64/store/27/27ce49698e818e8efb56b6eff6dd785e503df341/defaults-release-v1-1.osx_x86-64.tar.gz"],
      }[x]
    os.environ["ALIBUILD_NO_ANALYTICS"] = "1"
    mock_utilities_open.side_effect = lambda x : {
      "/alidist/root.sh": StringIO(TEST_ROOT_RECIPE),
      "/alidist/zlib.sh": StringIO(TEST_ZLIB_RECIPE),
      "/alidist/defaults-release.sh": StringIO(TEST_DEFAULT_RELEASE)
    }[x]
    mock_is_writeable.side_effect = lambda x: True
    mock_open.side_effect = dummy_open

    mock_git_clone = MagicMock(return_value=None)
    mock_git_fetch = MagicMock(return_value=None)
    mock_execute.side_effect = lambda x, **kwds: dummy_execute(x, mock_git_clone, mock_git_fetch, **kwds)
    mock_workarea_execute.side_effect = lambda x, **kwds: dummy_execute(x, mock_git_clone, mock_git_fetch, **kwds)

    mock_exists.side_effect = dummy_exists
    mock_workarea_exists.side_effect = dummy_exists
    mock_getstatusoutput.side_effect = dummy_getstatusoutput
    mock_getStatusOutputBash.side_effect = dummy_getStatusOutputBash
    mock_parser = MagicMock()
    mock_read_defaults.return_value = (OrderedDict({"package": "defaults-release", "disable": []}), "")
    args = Namespace(
      remoteStore="",
      writeStore="",
      referenceSources="/sw/MIRROR",
      docker=False,
      architecture="osx_x86-64",
      workDir="/sw",
      pkgname=["root"],
      configDir="/alidist",
      disable=[],
      defaults="release",
      jobs=2,
      preferSystem=[],
      noSystem=False,
      debug=True,
      dryRun=False,
      aggressiveCleanup=False,
      environment={},
      autoCleanup=False,
      noDevel=[],
      fetchRepos=False
    )
    mock_sys.version_info = sys.version_info

    mock_git_clone.reset_mock()
    mock_git_fetch.reset_mock()
    fmt, msg, code = doBuild(args, mock_parser)
    self.assertEqual(mock_git_clone.call_count, 1, "Expected only one call to git clone (called %d times instead)" % mock_git_clone.call_count)
    self.assertEqual(mock_git_fetch.call_count, 0, "Expected only no calls to git fetch (called %d times instead)" % mock_git_fetch.call_count)

    # Force fetching repos
    mock_git_clone.reset_mock()
    mock_git_fetch.reset_mock()
    args.fetchRepos = True
    fmt, msg, code = doBuild(args, mock_parser)
    mock_glob.assert_called_with("/sw/TARS/osx_x86-64/ROOT/ROOT-v6-08-30-*.osx_x86-64.tar.gz")
    self.assertEqual(msg, "Everything done")
    self.assertEqual(mock_git_clone.call_count, 1, "Expected only one call to git clone (called %d times instead)" % mock_git_clone.call_count)
    self.assertEqual(mock_git_fetch.call_count, 1, "Expected only one call to git fetch (called %d times instead)" % mock_git_fetch.call_count)
Exemple #3
0
    def test_coverDoBuild(self, mock_debug, mock_glob, mock_sys,
                          mock_workarea_git):
        mock_workarea_git.side_effect = dummy_git
        mock_debug.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"
            ],
            "/sw/TARS/osx_x86-64/zlib/zlib-v1.2.3-*.osx_x86-64.tar.gz": [],
            "/sw/TARS/osx_x86-64/ROOT/ROOT-v6-08-30-*.osx_x86-64.tar.gz": [],
            "/sw/TARS/osx_x86-64/store/%s/%s/*gz" % (TEST_DEFAULT_RELEASE_BUILD_HASH[:2], TEST_DEFAULT_RELEASE_BUILD_HASH):
            [],
            "/sw/TARS/osx_x86-64/store/%s/%s/*gz" % (TEST_ZLIB_BUILD_HASH[:2], TEST_ZLIB_BUILD_HASH):
            [],
            "/sw/TARS/osx_x86-64/store/%s/%s/*gz" % (TEST_ROOT_BUILD_HASH[:2], TEST_ROOT_BUILD_HASH):
            [],
            "/sw/TARS/osx_x86-64/defaults-release/defaults-release-v1-1.osx_x86-64.tar.gz":
            [
                "../../osx_x86-64/store/%s/%s/defaults-release-v1-1.osx_x86-64.tar.gz"
                % (TEST_DEFAULT_RELEASE_BUILD_HASH[:2],
                   TEST_DEFAULT_RELEASE_BUILD_HASH)
            ],
        }[x]
        os.environ["ALIBUILD_NO_ANALYTICS"] = "1"

        mock_parser = MagicMock()
        args = Namespace(remoteStore="",
                         writeStore="",
                         referenceSources="/sw/MIRROR",
                         docker=False,
                         architecture="osx_x86-64",
                         workDir="/sw",
                         pkgname=["root"],
                         configDir="/alidist",
                         disable=[],
                         defaults="release",
                         jobs=2,
                         preferSystem=[],
                         noSystem=False,
                         debug=True,
                         dryRun=False,
                         aggressiveCleanup=False,
                         environment={},
                         autoCleanup=False,
                         noDevel=[],
                         fetchRepos=False,
                         forceTracked=False,
                         plugin="legacy")
        mock_sys.version_info = sys.version_info

        mock_workarea_git.reset_mock()
        mock_debug.reset_mock()
        exit_code = doBuild(args, mock_parser)
        self.assertEqual(exit_code, 0)
        mock_debug.assert_called_with("Everything done")
        mock_workarea_git.assert_called_once_with(list(GIT_CLONE_ZLIB_ARGS[0]))

        # Force fetching repos
        mock_workarea_git.reset_mock()
        mock_debug.reset_mock()
        args.fetchRepos = True
        exit_code = doBuild(args, mock_parser)
        self.assertEqual(exit_code, 0)
        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")
        fetch_args, fetch_dir, fetch_check = GIT_FETCH_ROOT_ARGS
        # We can't compare directly against the list of calls here as they
        # might happen in any order.
        self.assertEqual(mock_workarea_git.call_count, 2)
        mock_workarea_git.has_calls([
            call(list(GIT_CLONE_ZLIB_ARGS[0])),
            call(fetch_args, directory=fetch_dir, check=fetch_check),
        ])
Exemple #4
0
    def test_coverDoBuild(self, mock_debug, mock_glob, mock_sys,
                          mock_sync_execute, mock_workarea_execute,
                          mock_execute):
        mock_debug.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"
            ],
            "/sw/TARS/osx_x86-64/zlib/zlib-v1.2.3-*.osx_x86-64.tar.gz": [],
            "/sw/TARS/osx_x86-64/ROOT/ROOT-v6-08-30-*.osx_x86-64.tar.gz": [],
            "/sw/TARS/osx_x86-64/store/%s/%s/*gz" % (TEST_DEFAULT_RELEASE_BUILD_HASH[:2], TEST_DEFAULT_RELEASE_BUILD_HASH):
            [],
            "/sw/TARS/osx_x86-64/store/%s/%s/*gz" % (TEST_ZLIB_BUILD_HASH[:2], TEST_ZLIB_BUILD_HASH):
            [],
            "/sw/TARS/osx_x86-64/store/%s/%s/*gz" % (TEST_ROOT_BUILD_HASH[:2], TEST_ROOT_BUILD_HASH):
            [],
            "/sw/TARS/osx_x86-64/defaults-release/defaults-release-v1-1.osx_x86-64.tar.gz":
            [
                "../../osx_x86-64/store/%s/%s/defaults-release-v1-1.osx_x86-64.tar.gz"
                % (TEST_DEFAULT_RELEASE_BUILD_HASH[:2],
                   TEST_DEFAULT_RELEASE_BUILD_HASH)
            ],
        }[x]
        os.environ["ALIBUILD_NO_ANALYTICS"] = "1"

        mock_git_clone = MagicMock(return_value=None)
        mock_git_fetch = MagicMock(return_value=None)
        mock_execute.side_effect = lambda x, **kwds: dummy_execute(
            x, mock_git_clone, mock_git_fetch, **kwds)
        mock_workarea_execute.side_effect = lambda x, **kwds: dummy_execute(
            x, mock_git_clone, mock_git_fetch, **kwds)
        mock_sync_execute.side_effect = lambda x, **kwds: dummy_execute(
            x, mock_git_clone, mock_git_fetch, **kwds)

        mock_parser = MagicMock()
        args = Namespace(
            remoteStore="",
            writeStore="",
            referenceSources="/sw/MIRROR",
            docker=False,
            architecture="osx_x86-64",
            workDir="/sw",
            pkgname=["root"],
            configDir="/alidist",
            disable=[],
            defaults="release",
            jobs=2,
            preferSystem=[],
            noSystem=False,
            debug=True,
            dryRun=False,
            aggressiveCleanup=False,
            environment={},
            autoCleanup=False,
            noDevel=[],
            fetchRepos=False,
        )
        mock_sys.version_info = sys.version_info

        mock_git_clone.reset_mock()
        mock_git_fetch.reset_mock()
        mock_debug.reset_mock()
        exit_code = doBuild(args, mock_parser)
        self.assertEqual(exit_code, 0)
        mock_debug.assert_called_with("Everything done")
        mock_git_clone.assert_called_once()
        mock_git_fetch.assert_not_called()

        # Force fetching repos
        mock_git_clone.reset_mock()
        mock_git_fetch.reset_mock()
        mock_debug.reset_mock()
        args.fetchRepos = True
        exit_code = doBuild(args, mock_parser)
        self.assertEqual(exit_code, 0)
        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")
        mock_git_clone.assert_called_once()
        mock_git_fetch.assert_called_once()