2014-04-06 09:55:13 -07:00
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
|
2014-04-05 10:39:16 -07:00
|
|
|
from spec import Spec, skip
|
2014-04-06 09:55:13 -07:00
|
|
|
from invoke import run
|
2014-04-05 10:39:16 -07:00
|
|
|
|
|
|
|
|
|
|
|
class integration(Spec):
|
2014-04-06 09:55:13 -07:00
|
|
|
def setup(self):
|
|
|
|
self.cwd = os.getcwd()
|
|
|
|
|
|
|
|
def teardown(self):
|
|
|
|
os.chdir(self.cwd)
|
|
|
|
|
2014-04-06 10:41:11 -07:00
|
|
|
def _assert_worked(self, folder, opts=None, target='changelog'):
|
|
|
|
# Dynamic sphinx opt overrides
|
|
|
|
pairs = map(lambda x: '='.join(x), (opts or {}).items())
|
|
|
|
flags = map(lambda x: '-D {0}'.format(x), pairs)
|
|
|
|
flagstr = ' '.join(flags)
|
|
|
|
# Setup
|
2014-04-06 10:21:08 -07:00
|
|
|
os.chdir(os.path.join('tests', '_support'))
|
|
|
|
build = os.path.join(folder, '_build')
|
2014-04-06 09:55:13 -07:00
|
|
|
try:
|
2014-04-06 10:41:11 -07:00
|
|
|
# Build
|
|
|
|
cmd = 'sphinx-build {2} -c . -W {0} {1}'.format(
|
|
|
|
folder, build, flagstr)
|
2014-04-06 10:02:26 -07:00
|
|
|
result = run(cmd, warn=True, hide=True)
|
2014-04-06 10:41:11 -07:00
|
|
|
# Check for errors
|
2014-04-06 09:55:13 -07:00
|
|
|
msg = "Build failed w/ stderr: {0}"
|
|
|
|
assert result.ok, msg.format(result.stderr)
|
2014-04-06 10:41:11 -07:00
|
|
|
# Check for vaguely correct output
|
|
|
|
changelog = os.path.join(build, '{0}.html'.format(target))
|
2014-04-06 10:21:08 -07:00
|
|
|
with open(changelog) as fd:
|
2014-04-06 09:55:13 -07:00
|
|
|
text = fd.read()
|
|
|
|
assert "1.0.1" in text
|
|
|
|
assert "#1" in text
|
|
|
|
finally:
|
2014-04-06 10:21:08 -07:00
|
|
|
shutil.rmtree(build)
|
|
|
|
|
|
|
|
def vanilla_invocation(self):
|
|
|
|
# Doctree with just-a-changelog-named-changelog
|
|
|
|
self._assert_worked('vanilla')
|
2014-04-05 10:39:16 -07:00
|
|
|
|
|
|
|
def customized_filename_with_identical_title(self):
|
|
|
|
# Changelog named not 'changelog', same title
|
2014-04-06 10:41:11 -07:00
|
|
|
self._assert_worked(
|
|
|
|
folder='custom_identical',
|
|
|
|
opts={'releases_document_name': 'notachangelog'},
|
|
|
|
target='notachangelog',
|
|
|
|
)
|
2014-04-05 10:39:16 -07:00
|
|
|
|
|
|
|
def customized_filename_with_different_title(self):
|
|
|
|
# Changelog named not 'changelog', title distinct
|
2014-04-06 10:44:46 -07:00
|
|
|
# NOTE: the difference here is in the fixture!
|
|
|
|
self._assert_worked(
|
|
|
|
folder='custom_different',
|
|
|
|
opts={'releases_document_name': 'notachangelog'},
|
|
|
|
target='notachangelog',
|
|
|
|
)
|
2014-04-05 10:39:16 -07:00
|
|
|
|
|
|
|
def useful_error_if_changelog_is_missed(self):
|
|
|
|
# Don't barf with unknown-node errors if changelog not found.
|
|
|
|
skip()
|