tests/mocktime.py
author Pierre-Yves David <pierre-yves.david@octobus.net>
Thu, 22 Sep 2022 01:50:53 +0200
changeset 49497 1baf0fffd82f
parent 48946 642e31cb55f0
permissions -rw-r--r--
run-tests: display the time it took to install Mercurial It will help make people aware of this critical step and to assess the time it takes in various options (like a CI run for example).

import os
import time


class mocktime:
    def __init__(self, increment):
        self.time = 0
        self.increment = [float(s) for s in increment.split()]
        self.pos = 0

    def __call__(self):
        self.time += self.increment[self.pos % len(self.increment)]
        self.pos += 1
        return self.time


def uisetup(ui):
    time.time = mocktime(os.environ.get('MOCKTIME', '0.1'))