From 333b28663b5282aeb90159c9c774953ecf7a085d Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 20 Jul 2009 23:43:34 -0300 Subject: [PATCH] Start a runtests.py script to setup a faux git repo for testing. We'll soon be running 'unit' tests inside this git repo to ensure tito does what it's supposed to do. --- test/fakegitfiles/a.txt | 1 + test/fakegitfiles/b.txt | 1 + test/fakegitfiles/c.txt | 1 + test/runtests.py | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 test/fakegitfiles/a.txt create mode 100644 test/fakegitfiles/b.txt create mode 100644 test/fakegitfiles/c.txt create mode 100644 test/runtests.py diff --git a/test/fakegitfiles/a.txt b/test/fakegitfiles/a.txt new file mode 100644 index 0000000..c1a7bd5 --- /dev/null +++ b/test/fakegitfiles/a.txt @@ -0,0 +1 @@ +blah blah blah diff --git a/test/fakegitfiles/b.txt b/test/fakegitfiles/b.txt new file mode 100644 index 0000000..243f64c --- /dev/null +++ b/test/fakegitfiles/b.txt @@ -0,0 +1 @@ +omg omg omg diff --git a/test/fakegitfiles/c.txt b/test/fakegitfiles/c.txt new file mode 100644 index 0000000..9d53b7d --- /dev/null +++ b/test/fakegitfiles/c.txt @@ -0,0 +1 @@ +bbq bbq bbq diff --git a/test/runtests.py b/test/runtests.py new file mode 100644 index 0000000..3e0c385 --- /dev/null +++ b/test/runtests.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +import sys +import os +import os.path + +# Python libraries are one level up from where this script lives: +TEST_SCRIPT_DIR = os.path.dirname(sys.argv[0]) +sys.path.append(os.path.join(TEST_SCRIPT_DIR, "../src/")) + +import spacewalk.releng.cli # prevents a circular import +from spacewalk.releng.common import * + +# A location where we can safely create a test git repository. +# WARNING: This location will be destroyed if present. +TEST_GIT_LOCATION = '/tmp/tito-test-git-repo' + +if __name__ == '__main__': + print "Running tito tests." + + if os.path.exists(TEST_GIT_LOCATION): + #error_out("Test Git repo already exists: %s" % TEST_GIT_LOCATION) + run_command('rm -rf %s' % TEST_GIT_LOCATION) + + run_command('mkdir -p %s' % TEST_GIT_LOCATION) + run_command('cp -R %s/* %s' % (os.path.join(TEST_SCRIPT_DIR, + 'fakegitfiles'), TEST_GIT_LOCATION)) + os.chdir(TEST_GIT_LOCATION) + run_command('git init') + run_command('git add a.txt') + run_command('git commit -a -m "added a.txt"') + run_command('git add b.txt') + run_command('git commit -a -m "added b.txt"') + run_command('git add c.txt') + run_command('git commit -a -m "added c.txt"') + +