]> thyrsus.com Git - src.git/commitdiff
Wecan time-freeze for regression testing now.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 7 Nov 2014 17:52:26 +0000 (12:52 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 7 Nov 2014 17:52:26 +0000 (12:52 -0500)
src
src.asc
srctest

diff --git a/src b/src
index fc2208ade71c7f94cd0fb5cd9ed58ac529bb193f..a9299b72ef082ae62f44512e74808c29439f8e70 100755 (executable)
--- 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 efb008ca2004508af646b147c10253079aefa1e4..4930e6f45ad210c21cd0ee0647b78638a86c2c04 100644 (file)
--- 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 d522bb112d1b3c27fc76895d096c0ad948237a3f..585ad72b95425fdbc1792035461a02bfb19772e9 100755 (executable)
--- 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$$ <<EOF
+cat >testfile1 <<EOF
 Now is the time
 EOF
 
-src add testfile$$ >/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$$ <<EOF
+cat >testfile1 <<EOF
 Now is the time
 for all good men
 EOF
 
-echo "Second comment" | src commit - testfile$$ >/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 <<EOF
+= testfile1 =====================================================================
+2     * 1970-01-02T00:01:00Z Second comment
+1     - 1970-01-02T00:02:00Z First comment
+EOF
+
+src $TESTOPTS list testfile1 >testfile3
+
+diff testfile2 testfile3
+check "list test"
+
 # end