Skip to content

Commit

Permalink
Improved smoketest script, made logging optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maggie-M committed Jun 3, 2013
1 parent 74c7410 commit 0b07410
Showing 1 changed file with 35 additions and 71 deletions.
106 changes: 35 additions & 71 deletions utils/smoketest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
import subprocess as sp
import sys
import time

from os.path import exists, join
from shutil import rmtree
Expand All @@ -13,73 +15,31 @@
# os.environ['CIO_TEST'] = 2

cmds = [
(
"conda info"
),
(
"conda list ^m.*lib$"
),
(
"conda search ^m.*lib$"
),
(
"conda search --all -v numpy"
),
(
"conda depends numpy"
),
(
"conda info -e"
),
(
"conda create --yes -p %s sqlite python=2.6" % myenv
),
(
"conda install --yes -p %s pandas=0.8.1" % myenv
),
(
"conda install --yes -p %s numba=0.1.1" % myenv
),
(
"conda install --yes -p %s cython=0.16" % myenv
),
(
"conda install --yes -p %s cython=0.17.3" % myenv
),
(
"conda install --yes -p %s accelerate" % myenv
),
(
"conda remove --yes -p %s accelerate" % myenv
),
(
"conda update --yes -p %s pandas" % myenv
),
(
"conda install --yes -p %s iopro" % myenv
),
(
"conda remove --yes -p %s iopro" % myenv
),
(
"conda local --yes -d numba-0.3.1-np17py27_0"
),
(
"conda env --yes -lp %s numba-0.3.1-np17py27_0" % myenv
),
(
"conda env --yes -up %s sqlite-3.7.13-0" % myenv
),
(
"conda local --yes -r zeromq-2.2.0-0"
),
(
"conda local --yes -d zeromq-2.2.0-0"
)
"conda info",
"conda list ^m.*lib$",
"conda search ^m.*lib$",
"conda search -v numpy",
"conda search -c numpy",
"conda info -e",
"conda creae --yes -p %s sqlite python=2.6" % myenv,
"conda install --yes -p %s pandas=0.8.1" % myenv,
"conda install --yes -p %s numba=0.1.1" % myenv,
"conda install --yes -p %s cython=0.16" % myenv,
"conda install --yes -p %s cython=0.17.3" % myenv,
"conda install --yes -p %s accelerate" % myenv,
"conda remove --yes -p %s accelerate" % myenv,
"conda update --yes -p %s pandas" % myenv,
"conda install --yes -p %s iopro" % myenv,
"conda remove --yes -p %s iopro" % myenv,
"conda info -e",
"conda info -a",
"conda info --license",
"conda info -s",
]

def tester(commands):
cmds = commands
errs = []
fails = []
for cmd in cmds:
print "-"*120
Expand All @@ -91,29 +51,33 @@ def tester(commands):
ret = child.returncode
if ret != 0:
print "\nFAILED\n"
f.write("\n%s\n \n%s" % (cmd, err))
errs.append("\n%s\n \n%s" % (cmd, err))
fails.append(cmd)
else:
print "\nPASSED\n"
except Exception as e:
print e
f.write("\nThe script had the following error running %s: %s" % (cmd, e))

return fails
return (fails, errs)


if __name__ == '__main__':
TESTLOG="conda-testlog.txt"
if exists(TESTLOG):
os.remove(TESTLOG)
f = open(TESTLOG, "w")
fails = tester(cmds)
f.close()
TESTLOG = ''
if len(sys.argv) == 2 and sys.argv[1] == 'log':
TESTLOG="conda-testlog.txt"
fails, errs = tester(cmds)
if fails:
print "These commands failed: \n"
for line, fail in enumerate(fails, 1):
print "%d: %s\n" % (line, fail)
print "Writing failed commands to conda-testlog.txt"
header = 'Test Results For %s' % time.asctime()
if TESTLOG:
with open(TESTLOG, "a") as f:
f.write('%s\n%s\n' % (header, '-'*len(header)))
for error in errs:
f.write(error)

try:
rmtree(myenv)
Expand Down

0 comments on commit 0b07410

Please sign in to comment.