From 15ba642cb8189f748c74bbbc0be1019722b88d53 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 7 Nov 2014 12:52:26 -0500 Subject: [PATCH] Wecan time-freeze for regression testing now. --- src | 36 +++++++++++++++++++++++++----------- src.asc | 5 ++++- srctest | 29 +++++++++++++++++++++-------- 3 files changed, 50 insertions(+), 20 deletions(-) diff --git a/src b/src index fc2208a..a9299b7 100755 --- a/src +++ b/src @@ -29,6 +29,9 @@ debug = 0 DEBUG_COMMANDS = 1 # Show commands as they are executed DEBUG_PARSE = 2 # Debug logfile parse +# If true (option -T) use an artificial clock for regression testing +pseudotime = False + def do_or_die(dcmd, legend=b"", loud=False): "Either execute a command or raise a fatal exception." if legend: @@ -166,10 +169,15 @@ class RCSLog: maxrevno += 1 elif line.startswith("date"): fields = line.split() - date = fields[1] + " " + fields[2] - if date.endswith(";"): - date = date[:-1] - date = date.replace("/", "-").replace(" ", "T") + "Z" + if pseudotime: + # Artificial date one day after the epoch + # to avoid timezone issues. + date = rfc3339(86400 + len(self) * 60) + else: + date = fields[1] + " " + fields[2] + if date.endswith(";"): + date = date[:-1] + date = date.replace("/","-").replace(" ","T") + "Z" self.revlist[-1].date = date elif line.startswith("======================="): if not self.revlist[-1].log.endswith("\n"): @@ -558,8 +566,12 @@ def fast_export_method(*args): if revspec and len(revspec) > 1: croak("checkout needs an empty or singleton revision spec") mark = 0 - username = capture_or_die("git config --get user.name").strip() - useremail = capture_or_die("git config --get user.email").strip() + if pseudotime: + username = "J. Random Hacker" + useremail = "jrh@nowhere.man" + else: + username = capture_or_die("git config --get user.name").strip() + useremail = capture_or_die("git config --get user.email").strip() attribution = "%s <%s>" % (username, useremail) for arg in args: executable = os.stat(arg).st_mode & stat.S_IXUSR @@ -623,14 +635,16 @@ dispatch = { if __name__ == "__main__": - command = sys.argv[1:] + command = list(sys.argv[1:]) + while command and command[0].startswith("-"): + if command[0] == '-d': + debug += 1 + if command[0] == '-T': + pseudotime = True + command.pop(0) if not command: help_method() else: - command = list(command) - while command[0] == "-d": - debug += 1 - command.pop(0) try: apply(dispatch[command[0]], command[1:]) except KeyError: diff --git a/src.asc b/src.asc index efb008c..4930e6f 100644 --- a/src.asc +++ b/src.asc @@ -89,7 +89,10 @@ src fast-export ['file'...] If no files are specified, all eligible files are operated on in sequence. A '-d' option before the main command word turns on debugging -messages; it can be repeated for higher debugging levels. +messages; it can be repeated for higher debugging levels. A -T option +sets up an artificial clock that ticks once on each revision and +fixes the user information to be used in fast-export; it's for +regression testing. == DANGER! DANGER! == This is a proof-of-concept alpha release. The 'branch' and diff --git a/srctest b/srctest index d522bb1..585ad72 100755 --- a/srctest +++ b/srctest @@ -11,32 +11,45 @@ check() { esac } +TESTOPTS=-T + # Catches dumb and obvious case of code having a Python syntax error -src >>/dev/null 2>&1 +src $TESTOPTS >>/dev/null 2>&1 check "smoke test" -cat >testfile$$ <testfile1 </dev/null +src $TESTOPTS add testfile1 >/dev/null check "add" -src commit -m "First comment" testfile$$ >/dev/null +src $TESTOPTS commit -m "First comment" testfile1 >/dev/null check "commit with -m option" -src cat testfile$$ | diff testfile$$ - >/dev/null +src $TESTOPTS cat testfile1 | diff testfile1 - >/dev/null check "content check after first commit" -cat >testfile$$ <testfile1 </dev/null +echo "Second comment" | src $TESTOPTS commit - testfile1 >/dev/null check "commit with -" -src cat testfile$$ | diff testfile$$ - +src $TESTOPTS cat testfile1 | diff testfile1 - check "content check after second commit" +cat >testfile2 <testfile3 + +diff testfile2 testfile3 +check "list test" + # end -- 2.43.0