mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-23 20:22:46 +00:00
Expand tagging tests.
This commit is contained in:
parent
69a108dfad
commit
0de5290258
7 changed files with 52 additions and 26 deletions
2
bin/tito
2
bin/tito
|
@ -17,7 +17,7 @@
|
||||||
import sys
|
import sys
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
from spacewalk.releng.cli import CLI
|
from tito.cli import CLI
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
CLI().main()
|
CLI().main()
|
||||||
|
|
|
@ -32,11 +32,11 @@ TEST_SCRIPT_DIR = os.path.abspath(os.path.dirname(sys.argv[0]))
|
||||||
SRC_DIR = os.path.normpath(os.path.join(TEST_SCRIPT_DIR, "src/"))
|
SRC_DIR = os.path.normpath(os.path.join(TEST_SCRIPT_DIR, "src/"))
|
||||||
SRC_BIN_DIR = os.path.abspath(os.path.join(TEST_SCRIPT_DIR, "bin/"))
|
SRC_BIN_DIR = os.path.abspath(os.path.join(TEST_SCRIPT_DIR, "bin/"))
|
||||||
|
|
||||||
os.environ['TITO_SRC_DIR'] = SRC_DIR
|
os.environ['PYTHONPATH'] = SRC_DIR
|
||||||
os.environ['TITO_SRC_BIN_DIR'] = SRC_BIN_DIR
|
os.environ['TITO_SRC_BIN_DIR'] = SRC_BIN_DIR
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print("Running tito tests.")
|
print("Running tito tests against: %s" % SRC_DIR)
|
||||||
|
|
||||||
import nose
|
import nose
|
||||||
nose.main()
|
nose.main()
|
||||||
|
|
|
@ -579,7 +579,7 @@ class Builder(object):
|
||||||
# file we're building off. (note that this is a temp copy of the
|
# file we're building off. (note that this is a temp copy of the
|
||||||
# spec) Swap out the actual release for one that includes the git
|
# spec) Swap out the actual release for one that includes the git
|
||||||
# SHA1 we're building for our test package:
|
# SHA1 we're building for our test package:
|
||||||
setup_specfile_script = "test-setup-specfile.pl"
|
setup_specfile_script = get_script_path("test-setup-specfile.pl")
|
||||||
cmd = "%s %s %s %s-%s %s" % \
|
cmd = "%s %s %s %s-%s %s" % \
|
||||||
(
|
(
|
||||||
setup_specfile_script,
|
setup_specfile_script,
|
||||||
|
|
|
@ -419,6 +419,9 @@ class TagModule(BaseCliModule):
|
||||||
default=False,
|
default=False,
|
||||||
help=("Don't automatically create a changelog "
|
help=("Don't automatically create a changelog "
|
||||||
"entry for this tag if none is found"))
|
"entry for this tag if none is found"))
|
||||||
|
self.parser.add_option("--accept-auto-changelog", action="store_true",
|
||||||
|
default=False,
|
||||||
|
help=("Automatically accept the generated changelog."))
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
BaseCliModule.main(self)
|
BaseCliModule.main(self)
|
||||||
|
@ -471,9 +474,9 @@ class InitModule(BaseCliModule):
|
||||||
# write out tito.props
|
# write out tito.props
|
||||||
out_f = open(filename, 'w')
|
out_f = open(filename, 'w')
|
||||||
out_f.write("[globalconfig]\n")
|
out_f.write("[globalconfig]\n")
|
||||||
out_f.write("default_builder = %s\n" % DEFAULT_BUILDER)
|
out_f.write("default_builder = %s\n" % 'tito.builder.Builder')
|
||||||
out_f.write(
|
out_f.write(
|
||||||
"default_tagger = %s\n" % DEFAULT_TAGGER)
|
"default_tagger = %s\n" % 'tito.tagger.VersionTagger')
|
||||||
out_f.close()
|
out_f.close()
|
||||||
print(" - wrote %s" % GLOBAL_BUILD_PROPS_FILENAME)
|
print(" - wrote %s" % GLOBAL_BUILD_PROPS_FILENAME)
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,6 @@ import os.path
|
||||||
import sys
|
import sys
|
||||||
import commands
|
import commands
|
||||||
|
|
||||||
#SCRIPT_DIR = os.path.abspath(os.path.join(os.path.dirname(
|
|
||||||
# os.path.abspath(sys.argv[0])), "../"))
|
|
||||||
|
|
||||||
DEFAULT_BUILD_DIR = "/tmp/spacewalk-build"
|
DEFAULT_BUILD_DIR = "/tmp/spacewalk-build"
|
||||||
|
|
||||||
|
|
||||||
|
@ -202,7 +199,7 @@ def create_tgz(git_root, prefix, commit, relative_dir, rel_eng_dir,
|
||||||
os.chdir(os.path.abspath(git_root))
|
os.chdir(os.path.abspath(git_root))
|
||||||
timestamp = get_commit_timestamp(commit)
|
timestamp = get_commit_timestamp(commit)
|
||||||
|
|
||||||
timestamp_script = "tar-fixup-stamp-comment.pl"
|
timestamp_script = get_script_path("tar-fixup-stamp-comment.pl")
|
||||||
|
|
||||||
#if not os.path.exists(timestamp_script):
|
#if not os.path.exists(timestamp_script):
|
||||||
# error_out("Unable to locate required script: %s" % timestamp_script)
|
# error_out("Unable to locate required script: %s" % timestamp_script)
|
||||||
|
@ -262,3 +259,15 @@ def normalize_class_name(name):
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
|
||||||
|
def get_script_path(scriptname):
|
||||||
|
"""
|
||||||
|
Hack to accomodate functional tests running from source, rather than
|
||||||
|
requiring tito to actually be installed. This variable is only set by
|
||||||
|
test scripts, normally we assume scripts are on PATH.
|
||||||
|
"""
|
||||||
|
# TODO: Would be nice to get rid of this hack.
|
||||||
|
scriptpath = scriptname # assume on PATH by default
|
||||||
|
if 'TITO_SRC_BIN_DIR' in os.environ:
|
||||||
|
bin_dir = os.environ['TITO_SRC_BIN_DIR']
|
||||||
|
scriptpath = os.path.join(bin_dir, scriptname)
|
||||||
|
return scriptpath
|
||||||
|
|
|
@ -60,6 +60,7 @@ class VersionTagger(object):
|
||||||
self.git_user, self.git_email))
|
self.git_user, self.git_email))
|
||||||
|
|
||||||
self._no_auto_changelog = False
|
self._no_auto_changelog = False
|
||||||
|
self._accept_auto_changelog = False
|
||||||
|
|
||||||
def run(self, options):
|
def run(self, options):
|
||||||
"""
|
"""
|
||||||
|
@ -73,6 +74,8 @@ class VersionTagger(object):
|
||||||
" 'tito tag' will accomplish the same thing.")
|
" 'tito tag' will accomplish the same thing.")
|
||||||
if options.no_auto_changelog:
|
if options.no_auto_changelog:
|
||||||
self._no_auto_changelog=True
|
self._no_auto_changelog=True
|
||||||
|
if options.accept_auto_changelog:
|
||||||
|
self._accept_auto_changelog=True
|
||||||
self._tag_release()
|
self._tag_release()
|
||||||
|
|
||||||
def _tag_release(self):
|
def _tag_release(self):
|
||||||
|
@ -152,11 +155,12 @@ class VersionTagger(object):
|
||||||
|
|
||||||
os.write(fd, "\n")
|
os.write(fd, "\n")
|
||||||
|
|
||||||
editor = 'vi'
|
if not self._accept_auto_changelog:
|
||||||
if "EDITOR" in os.environ:
|
# Give the user a chance to edit the generated changelog:
|
||||||
editor = os.environ["EDITOR"]
|
editor = 'vi'
|
||||||
|
if "EDITOR" in os.environ:
|
||||||
subprocess.call([editor, name])
|
editor = os.environ["EDITOR"]
|
||||||
|
subprocess.call([editor, name])
|
||||||
|
|
||||||
os.lseek(fd, 0, 0)
|
os.lseek(fd, 0, 0)
|
||||||
file = os.fdopen(fd)
|
file = os.fdopen(fd)
|
||||||
|
@ -231,7 +235,7 @@ class VersionTagger(object):
|
||||||
if release:
|
if release:
|
||||||
bump_type = "bump-release"
|
bump_type = "bump-release"
|
||||||
|
|
||||||
script_path = "bump-version.pl"
|
script_path = get_script_path("bump-version.pl")
|
||||||
cmd = "%s %s --specfile %s" % \
|
cmd = "%s %s --specfile %s" % \
|
||||||
(script_path, bump_type, self.spec_file)
|
(script_path, bump_type, self.spec_file)
|
||||||
run_command(cmd)
|
run_command(cmd)
|
||||||
|
|
|
@ -32,6 +32,7 @@ TEST_DIR = '/tmp/titotests/'
|
||||||
SINGLE_GIT = os.path.join(TEST_DIR, 'single.git')
|
SINGLE_GIT = os.path.join(TEST_DIR, 'single.git')
|
||||||
#MULTI_GIT = os.path.join(TEST_DIR, 'multi.git')
|
#MULTI_GIT = os.path.join(TEST_DIR, 'multi.git')
|
||||||
|
|
||||||
|
TEST_PKG_NAME = 'tito-test-pkg'
|
||||||
TEST_SPEC = """
|
TEST_SPEC = """
|
||||||
Name: tito-test-pkg
|
Name: tito-test-pkg
|
||||||
Version: 0.0.1
|
Version: 0.0.1
|
||||||
|
@ -70,17 +71,21 @@ def tito(argstring):
|
||||||
if 'TITO_SRC_BIN_DIR' in os.environ:
|
if 'TITO_SRC_BIN_DIR' in os.environ:
|
||||||
bin_dir = os.environ['TITO_SRC_BIN_DIR']
|
bin_dir = os.environ['TITO_SRC_BIN_DIR']
|
||||||
tito_path = os.path.join(bin_dir, 'tito')
|
tito_path = os.path.join(bin_dir, 'tito')
|
||||||
run_command("%s %s" % (tito_path, argstring))
|
(status, output) = commands.getstatusoutput("%s %s" % (tito_path,
|
||||||
|
argstring))
|
||||||
|
if status > 0:
|
||||||
|
print output
|
||||||
|
raise Exception()
|
||||||
|
|
||||||
def cleanup_test_git_repos():
|
def cleanup_temp_git():
|
||||||
""" Delete the test directory if it exists. """
|
""" Delete the test directory if it exists. """
|
||||||
if os.path.exists(TEST_DIR):
|
if os.path.exists(TEST_DIR):
|
||||||
#error_out("Test Git repo already exists: %s" % TEST_DIR)
|
#error_out("Test Git repo already exists: %s" % TEST_DIR)
|
||||||
run_command('rm -rf %s' % TEST_DIR)
|
run_command('rm -rf %s' % TEST_DIR)
|
||||||
|
|
||||||
def create_test_git_repo(multi_project=False):
|
def create_temp_git(multi_project=False):
|
||||||
""" Create a test git repository. """
|
""" Create a test git repository. """
|
||||||
cleanup_test_git_repos()
|
cleanup_temp_git()
|
||||||
|
|
||||||
run_command('mkdir -p %s' % TEST_DIR)
|
run_command('mkdir -p %s' % TEST_DIR)
|
||||||
run_command('mkdir -p %s' % SINGLE_GIT)
|
run_command('mkdir -p %s' % SINGLE_GIT)
|
||||||
|
@ -108,9 +113,8 @@ def create_test_git_repo(multi_project=False):
|
||||||
class TaggerTests(unittest.TestCase):
|
class TaggerTests(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
create_test_git_repo()
|
create_temp_git()
|
||||||
|
|
||||||
# Probably already there but just to make sure:
|
|
||||||
os.chdir(SINGLE_GIT)
|
os.chdir(SINGLE_GIT)
|
||||||
self.assertFalse(os.path.exists(os.path.join(SINGLE_GIT, "rel-eng")))
|
self.assertFalse(os.path.exists(os.path.join(SINGLE_GIT, "rel-eng")))
|
||||||
tito("init")
|
tito("init")
|
||||||
|
@ -122,10 +126,16 @@ class TaggerTests(unittest.TestCase):
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
os.chdir('/tmp') # anywhere but the git repo were about to delete
|
os.chdir('/tmp') # anywhere but the git repo were about to delete
|
||||||
cleanup_test_git_repos()
|
cleanup_temp_git()
|
||||||
|
|
||||||
def test_tag_new_package(self):
|
def test_initial_tag_keep_version(self):
|
||||||
#tito("tag")
|
""" Create an initial package tag with --keep-version. """
|
||||||
pass
|
tito("tag --keep-version --accept-auto-changelog --debug")
|
||||||
|
check_tag_exists("%s-0.0.1-1" % TEST_PKG_NAME, offline=True)
|
||||||
|
|
||||||
|
def test_initial_tag(self):
|
||||||
|
""" Test creating an initial tag. """
|
||||||
|
tito("tag --accept-auto-changelog --debug")
|
||||||
|
check_tag_exists("%s-0.0.2-1" % TEST_PKG_NAME, offline=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue