]> thyrsus.com Git - src.git/commitdiff
Use -S to make the test clean up after itself.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 7 Nov 2014 21:05:52 +0000 (16:05 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 7 Nov 2014 21:05:52 +0000 (16:05 -0500)
src
src.asc
srctest

diff --git a/src b/src
index 306ce56856fce46278e6cbbfa40776e929e09cb5..b3170cff1e74c491e5448b73de46d76f2de332bc 100755 (executable)
--- a/src
+++ b/src
@@ -35,6 +35,9 @@ DEBUG_PARSE     = 2    # Debug logfile parse
 # If true (option -T) use an artificial clock for regression testing
 pseudotime = False
 
+# Repo directory
+repodir = ".src"
+
 def do_or_die(dcmd, legend=b"", loud=False):
     "Either execute a command or raise a fatal exception."
     if legend:
@@ -118,7 +121,7 @@ class RCSLog:
         self.name = name
         self.revlist = []
         self.symbols = {}
-        with popen_or_die("cd .src >/dev/null; rlog %s; cd ..>/dev/null" % name) as fp:
+        with popen_or_die("cd %s >/dev/null; rlog %s; cd ..>/dev/null" % (repodir, name)) as fp:
             self.revlist = []
             self.lockrevs = []
             maxrevno = 0
@@ -251,7 +254,7 @@ src help [command]
    Displays help for commands.
 
 src init::
-   Creates a .src directory if none already exists
+   Creates a repo directory if none already exists
 
 src add ['file'...]
    Initialize new project histories for specified files.
@@ -296,16 +299,16 @@ src fast-export ['file'...]
 """
 
 def init_method(*args):
-    "Create a .src directory if none already exists."
-    if not os.path.exists(".src"):
+    "Create a repo directory if none already exists."
+    if not os.path.exists(repodir):
         try:
-            os.mkdir(".src")
+            os.mkdir(repodir)
         except OSError:
-            complain(".src/ creation failed, check directory permissions.")
-    elif os.path.isdir(".src"):
-        complain(".src/ already exists.")
+            complain("creation failed, check directory permissions.")
+    elif os.path.isdir(repodir):
+        complain("%s already exists." % repodir)
     else:
-        complain(".src/ exists but is not a directory.")
+        complain("%s exists but is not a directory." % repodir)
 
 def preamble(cmd, args):
     "Common setup code."
@@ -343,7 +346,10 @@ def preamble(cmd, args):
                 croak("malformed revision spec: %s" % revspec)
             revspec = (start, end)
     if not args:
-        masters = os.listdir(".src")
+        try:
+            masters = os.listdir(repodir)
+        except OSError:
+            croak("repo directory %s does not exist" % repodir)
         if len(masters) == 1:
             args += [master[:-2] for master in masters]
         else:
@@ -358,10 +364,10 @@ def add_method(*args):
     for arg in args:
        if not os.path.exists(arg):
            complain("I see no '%s' here." % arg)
-       elif os.path.exists(".src/%s,v" % arg):
+       elif os.path.exists("%s/%s,v" % (repodir, arg)):
            complain("%s is already registered." % arg)
        else:
-           do_or_die("rcs -q -kb -i {0} </dev/null && mv {0},v .src".format(arg))
+           do_or_die("rcs -q -kb -i {0} </dev/null && mv {0},v {1}".format(arg, repodir))
            announce("%s: 0" % arg) 
 
 class lifted:
@@ -369,9 +375,9 @@ class lifted:
     def __init__(self, name):
         self.name = name
     def __enter__(self):
-        do_or_die("mv .src/{0},v .".format(self.name))
+        do_or_die("mv {0}/{1},v .".format(repodir, self.name))
     def __exit__(self, extype, value, traceback_unused):
-        do_or_die("mv {0},v .src".format(self.name))
+        do_or_die("mv {0},v {1}".format(self.name, repodir))
         if extype:
             raise extype(value)
         return True
@@ -406,9 +412,9 @@ def commit_method(*args):
         croak("commit doesn't take a revision spec")
     for arg in args:
        if not os.path.exists(arg):
-           complain("I see no '%s' here." % arg)
-       elif not os.path.exists(".src/%s,v" % arg):
-           complain("%s is not registered." % arg)
+           croak("I see no '%s' here." % arg)
+       elif not os.path.exists("%s/%s,v" % (repodir, arg)):
+           croak("%s is not registered." % arg)
        else:
            if not comment:
                editor = os.getenv("EDITOR") or "emacsclient"
@@ -642,8 +648,11 @@ if __name__ == "__main__":
     while command and command[0].startswith("-"):
         if command[0] == '-d':
             debug += 1
-        if command[0] == '-T':
+        elif command[0] == '-T':
             pseudotime = True
+        elif command[0] == '-S':
+            repodir = command[1] 
+            command.pop(0)
         command.pop(0)
     if not command:
         help_method()
diff --git a/src.asc b/src.asc
index 4930e6f45ad210c21cd0ee0647b78638a86c2c04..5373fea4402fadcf6b74e8b978508159f9fcd3a0 100644 (file)
--- a/src.asc
+++ b/src.asc
@@ -88,11 +88,20 @@ src fast-export ['file'...]
 
 If no files are specified, all eligible files are operated on in sequence.
 
+== DEBUGGING OPTIONS ==
+
+These will be of interet mainly to developers"
+
 A '-d' option before the main command word turns on debugging
-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.
+messages; it can be repeated for higher debugging levels.
+
+A -S (sandbox) option can be used to set the repository directory
+to something other than its default of ".src".
+
+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 also attributes all commits to J. Random Hacker and sets a
+constant screen witch of 79. 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 888b87231f10b9d36f006da31ef8e9b7dfb84b4b..725418187abb2ae052623d1e83b0537970c717df 100755 (executable)
--- a/srctest
+++ b/srctest
@@ -2,7 +2,7 @@
 #
 # Regression tester for SRC.
 #
-trap "rm -f testfile* .src/testfile*" 0 1 2 15
+trap "rm -f testfile* .sandbox/testfile*" 0 1 2 15
 
 check() {
     case $? in
@@ -11,9 +11,14 @@ check() {
     esac
 }
 
-TESTOPTS=-T
+TESTOPTS="-T -S .sandbox $*"
+
+rm -fr .sandbox
 
 # Catches dumb and obvious case of code having a Python syntax error
+src $TESTOPTS init
+check "init"
+
 src $TESTOPTS >>/dev/null 2>&1
 check "smoke test"