]> scripts.mit.edu Git - wizard.git/commitdiff
Revamp tests, fix minor usability problems with installer.
authorEdward Z. Yang <ezyang@mit.edu>
Tue, 3 Nov 2009 17:56:28 +0000 (12:56 -0500)
committerEdward Z. Yang <ezyang@mit.edu>
Tue, 3 Nov 2009 17:56:28 +0000 (12:56 -0500)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
13 files changed:
TODO
tests/all.sh
tests/setup
tests/test-backup-restore-mediawiki.sh
tests/test-continue-upgrade-mediawiki.sh
tests/test-install-mediawiki.sh [new file with mode: 0755]
tests/test-install-wordpress.sh
tests/test-upgrade-mediawiki-fail.sh
tests/test-upgrade-mediawiki-restore.sh
tests/test-upgrade-mediawiki-webfail.sh
tests/test-upgrade-mediawiki.sh
wizard/command/install.py
wizard/prompt.py

diff --git a/TODO b/TODO
index d070299f2f958791547f92112f7c2ab2a26f7811..7cf8c5b80d07419545734e592dc059e91ec2e76f 100644 (file)
--- a/TODO
+++ b/TODO
@@ -223,11 +223,16 @@ OVERALL PLAN:
        inheriting from wizard.app.Application (check existing modules for
        the boilerplate code).
 
-    2. Implement download()
+    2. Implement download().  "wizard prepare-pristine" will use this in order
+       to download the next version of an application.
 
     3. Create a git repository with `git init`
 
-    4. Use `wizard prepare-pristine APP-VERSION`
+    4. Use `wizard prepare-pristine APP-VERSION` to download the tarball and
+       extract it into the directory.  If download() doesn't work and you don't
+       want to special case it (for example, you need a /really old version/
+       for record-keeping purposes), replace APP-VERSION with PATH, where PATH
+       is the tarball to extract.
 
     5. `git commit -asm "APP VERSION"`
 
@@ -249,7 +254,10 @@ OVERALL PLAN:
    10. Implement install().  Test using `wizard install APP`; you won't
        be able to do a version-specific install with `wizard install APP-VERSION`
        until you generate a tag (which will become out of date once you
-       amend the commit.)
+       amend the commit.)  Now might be a good time to create a
+       tests/test-install-APP.sh file (use the other tests as reference) so
+       you don't have to constantly enter the parameters when you're doing
+       an install.
 
    11. Push your changes to a directory accessible in the production environment.
        In the case of scripts, this is equivalent to your AFS homedir, and
index 5f5dfe602aecc6ac7f025a49f4f0c0260f3c755d..461f465ffeb04880adce8aa0d15b2f2c5d889342 100755 (executable)
@@ -1,9 +1,14 @@
-#!/bin/sh
+#!/bin/bash
 bold="`tput -T${TERM:-dumb} bold`"
 red="`tput -T${TERM:-dumb} setf 4`"
 sgr0="`tput -T${TERM:-dumb} sgr0`"
-for i in test-*.sh; do
-    ./$i "$1"
+APP="$1"
+if [ "$APP" == "" ]; then
+    echo "Must specify application"
+    exit 1
+fi
+for i in test-*-$1*.sh; do
+    ./$i "$2"
     if [ $? -eq 0 ]
     then
         echo "${bold}OK${sgr0}"
index 699a5b9b5fb4effd62f48268030180b29287382e..3ba48c1fda6c788e682434e6cb109abbb3f28dcc 100644 (file)
@@ -6,12 +6,17 @@
 
 VERSION="$1"
 if [ "$VERSION" == "" ]; then
-    echo "Must specify version"
-    exit 1
+    if [ "$DEFAULT_HEAD" == "1" ]; then
+        VERSION="head"
+    else
+        echo "Must specify version"
+        exit 1
+    fi
 fi
 
 UVERSION=`echo "$VERSION" | sed s/[-.]/_/g`
 TESTID="${TESTNAME}_$UVERSION"
+echo "$TESTID"
 TESTDIR="testdir_${TESTNAME}_$VERSION"
 export WIZARD_ADMIN_NAME="admin"
 export WIZARD_ADMIN_PASSWORD="wizard"
index 368c7d54b7a6c176156a1686825db7122a9ac767..a5f00de21b87a7a8470b8a8dc98cfa4d0564d46d 100755 (executable)
@@ -3,7 +3,7 @@
 TESTNAME="backup_restore_mediawiki"
 source ./setup
 
-wizard install mediawiki-$VERSION-scripts "$TESTDIR" -- --title="TestApp"
+wizard install mediawiki-$VERSION-scripts "$TESTDIR" --non-interactive -- --title="TestApp"
 cd "$TESTDIR"
 wizard backup
 
index 0c5493ad400da52018ab071b15af8caf2f495a19..2a9827f9a82ab649ea43755a16d83e5d433e078c 100755 (executable)
@@ -3,7 +3,7 @@
 TESTNAME="continue_upgrade_mediawiki"
 source ./setup
 
-wizard install mediawiki-$VERSION-scripts "$TESTDIR" -- --title="TestApp"
+wizard install mediawiki-$VERSION-scripts "$TESTDIR" --non-interactive -- --title="TestApp"
 
 # nuke the install
 FROB="RELEASE-NOTES"
diff --git a/tests/test-install-mediawiki.sh b/tests/test-install-mediawiki.sh
new file mode 100755 (executable)
index 0000000..cadcecf
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/bash -e
+
+DEFAULT_HEAD=1
+TESTNAME="install_mediawiki"
+source ./setup
+
+wizard install "mediawiki-$VERSION-scripts" "$TESTDIR" --non-interactive -- --title="TestApp"
index 68a6b6c1e485bdb437f27721f20f1672924c2d3c..254f4ef52b11005edf1a14092b9c5b836d36a79c 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/bash -e
 
-TESTNAME="upgrade_wordpress"
+DEFAULT_HEAD=1
+TESTNAME="install_wordpress"
 source ./setup
 
-#wizard install wordpress-$VERSION-scripts "$TESTDIR" -- --title="My Blog"
-wizard install wordpress "$TESTDIR" -- --title="My Blog"
+wizard install "wordpress-$VERSION-scripts" "$TESTDIR" --non-interactive -- --title="My Blog"
index fc6795a92da3ecdccc2053bfb8c22e54795bf8af..9dd8e0ef183948d20f36ca533fa743bc3eb057ae 100755 (executable)
@@ -3,7 +3,7 @@
 TESTNAME="upgrade_mediawiki_fail"
 source ./setup
 
-wizard install mediawiki-$VERSION-scripts "$TESTDIR" -- --title="TestApp"
+wizard install mediawiki-$VERSION-scripts "$TESTDIR" --non-interactive -- --title="TestApp"
 echo "FAILURE" > "$TESTDIR/maintenance/update.php"
 wizard upgrade "$TESTDIR" || true
 cd "$TESTDIR"
index a2af3e63b66ea6ddd0eb16205271f904baf969bc..c7bb743bdb2f121e4571ad40892e05c72089db52 100755 (executable)
@@ -3,7 +3,7 @@
 TESTNAME="upgrade_mediawiki_restore"
 source ./setup
 
-wizard install mediawiki-$VERSION-scripts "$TESTDIR" -- --title="TestApp"
+wizard install mediawiki-$VERSION-scripts "$TESTDIR" --non-interactive -- --title="TestApp"
 wizard upgrade "$TESTDIR"
 cd "$TESTDIR"
 BACKUP=`wizard restore | head -n1`
index b03adbd16e15488846ee01f7304895fb29d7dcb0..dde0d031e5575fe249263cccb36e1ce9ac500e1b 100755 (executable)
@@ -3,7 +3,7 @@
 TESTNAME="upgrade_mediawiki_webfail"
 source ./setup
 
-wizard install mediawiki-$VERSION-scripts "$TESTDIR" -- --title="TestApp"
+wizard install mediawiki-$VERSION-scripts "$TESTDIR" --non-interactive -- --title="TestApp"
 cp test-upgrade-mediawiki-webfail-php "$TESTDIR/maintenance/update.php"
 wizard upgrade "$TESTDIR" || true
 cd "$TESTDIR"
index 2dd38fcbb01e4c8383b4512faf499c904ca3f1c7..334a13b750555bfdeffbe08113e8e45071a58228 100755 (executable)
@@ -3,5 +3,5 @@
 TESTNAME="upgrade_mediawiki"
 source ./setup
 
-wizard install mediawiki-$VERSION-scripts "$TESTDIR" -- --title="TestApp"
+wizard install mediawiki-$VERSION-scripts "$TESTDIR" --non-interactive -- --title="TestApp"
 wizard upgrade "$TESTDIR"
index cacaf3ca8d413bde3029f3a9c05cbe1b125c58f0..ca637bc6f597d1b76865a854d64d7911ce274dff 100644 (file)
@@ -44,13 +44,12 @@ Autoinstalls the application %s in the directory DIR.""" % (appname, appname))
     input.infobox("Copying files (this may take a while)...")
     sh.call("git", "clone", "-q", "--shared", application.repository(old_options.srv_path), dir)
     with util.ChangeDirectory(dir):
-        if version:
-            # XXX: do something smart if -scripts is not at the end
+        if version and version != "head-scripts": # for ease in testing
             sh.call("git", "reset", "-q", "--hard", appstr)
         input.infobox("Installing...")
         application.install(distutils.version.LooseVersion(version), options)
         git.commit_configure()
-    input.infobox("Congratulations, your new install is now accessible at http://%s%s" % (options.web_host, options.web_path))
+    input.infobox("Congratulations, your new install is now accessible at:\n\nhttp://%s%s" % (options.web_host, options.web_path), width=80)
 
 def configure_parser(parser, baton):
     parser.add_option("--prompt", dest="prompt", action="store_true",
index 43329e7edc04a1954ed36cb96cd806eee164ccaa..ce6a5f5e7d832eaf4159299cb3d6e8dbce07e042 100644 (file)
@@ -21,14 +21,15 @@ try:
 except ImportError:
     has_dialog = False
 
-def fill(text, width=60):
-    return "\n\n".join(textwrap.fill(p, width=width) for p in text.split("\n\n"))
+def fill(text, width=60, **kwargs):
+    return "\n\n".join(textwrap.fill(p, width=width, **kwargs) for p in text.split("\n\n"))
 
 def guess_dimensions(text, width=60):
     # +1 for the fact that there's no trailing newline from fill
     # +2 for the borders
     # +1 as a buffer in case we underestimate
-    return width, fill(text).count("\n", width-2) + 1 + 2 + 1
+    print fill(text)
+    return width, fill(text, width-2).count("\n") + 1 + 2 + 1
 
 def make(prompt, non_interactive):
     if non_interactive:
@@ -52,6 +53,8 @@ def dialog_wrap(f, self, text, *args, **kwargs):
     if 'cmdopt' in kwargs: del kwargs['cmdopt']
     if 'width' not in kwargs and 'height' not in kwargs:
         kwargs["width"], kwargs["height"] = guess_dimensions(text)
+    elif 'width' in kwargs and 'height' not in kwargs:
+        kwargs["width"], kwargs["height"] = guess_dimensions(text, width=kwargs["width"])
     result = f(self, text, *args, **kwargs)
     if not isinstance(result, tuple):
         exit = result
@@ -160,10 +163,10 @@ class FailPrompt(object):
         raise MissingRequiredParam(kwargs['cmdopt'])
     def msgbox(self, text, **kwargs):
         print ""
-        print fill(text.strip())
+        print fill(text.strip(), break_long_words=False)
     def infobox(self, text, **kwargs):
         print ""
-        print fill(text.strip())
+        print fill(text.strip(), break_long_words=False)
 
 class Error(wizard.Error):
     pass