diff -Nru cmdtest-0.27/debian/changelog cmdtest-0.32/debian/changelog --- cmdtest-0.27/debian/changelog 2016-09-21 07:32:41.000000000 +0000 +++ cmdtest-0.32/debian/changelog 2018-02-24 07:59:34.000000000 +0000 @@ -1,3 +1,35 @@ +cmdtest (0.32-1) unstable; urgency=medium + + * New upstream version. A no-change release, to trigger an upload to + Debian. (Closes: #890628) + + -- Lars Wirzenius Sat, 24 Feb 2018 09:59:34 +0200 + +cmdtest (0.31-1) unstable; urgency=medium + + * New upstream version. + + -- Lars Wirzenius Sun, 30 Apr 2017 11:25:58 +0300 + +cmdtest (0.30-1) unstable; urgency=medium + + * New upstream version. + + -- Lars Wirzenius Sun, 16 Apr 2017 12:58:29 +0300 + +cmdtest (0.29-1) unstable; urgency=medium + + * New upstream version. + + -- Lars Wirzenius Tue, 11 Apr 2017 20:23:16 +0300 + +cmdtest (0.28-1) unstable; urgency=medium + + * New upstream version. + * Require Python 2.7 + + -- Lars Wirzenius Tue, 28 Mar 2017 21:12:55 +0300 + cmdtest (0.27-1) unstable; urgency=medium * New upstream version. diff -Nru cmdtest-0.27/debian/compat cmdtest-0.32/debian/compat --- cmdtest-0.27/debian/compat 2015-11-13 11:01:52.000000000 +0000 +++ cmdtest-0.32/debian/compat 2018-02-09 16:29:34.000000000 +0000 @@ -1 +1 @@ -7 +9 diff -Nru cmdtest-0.27/debian/control cmdtest-0.32/debian/control --- cmdtest-0.27/debian/control 2016-09-21 07:26:07.000000000 +0000 +++ cmdtest-0.32/debian/control 2018-02-09 16:29:34.000000000 +0000 @@ -3,15 +3,15 @@ Homepage: http://liw.fi/cmdtest/ Section: devel Priority: optional -Standards-Version: 3.9.5 -Build-Depends: debhelper (>= 7.3.8), python-all (>= 2.6.6-3~), +Standards-Version: 3.9.8 +Build-Depends: debhelper (>= 9), python-all (>= 2.7~), python-cliapp, python-ttystatus, python-markdown -X-Python-Version: >= 2.6 +X-Python-Version: >= 2.7 Package: cmdtest Provides: yarn Architecture: all -Depends: ${python:Depends}, ${misc:Depends}, python (>= 2.6), python-cliapp, +Depends: ${python:Depends}, ${misc:Depends}, python (>= 2.7), python-cliapp, python-ttystatus, python-markdown Description: blackbox testing of Unix command line programs cmdtest black box tests Unix command line tools. Roughly, it is given a diff -Nru cmdtest-0.27/fail-tests/fail.stdout-diff cmdtest-0.32/fail-tests/fail.stdout-diff --- cmdtest-0.27/fail-tests/fail.stdout-diff 2016-09-21 07:32:41.000000000 +0000 +++ cmdtest-0.32/fail-tests/fail.stdout-diff 2018-02-24 07:59:34.000000000 +0000 @@ -1,4 +1,4 @@ ---- /dev/null 2016-04-16 10:19:56.078575363 +0300 -+++ fail-tests/fail.stdout-actual 2016-04-18 20:07:06.926378332 +0300 +--- /dev/null 2017-04-20 17:06:09.455944599 +0300 ++++ fail-tests/fail.stdout-actual 2017-04-30 11:15:56.619905930 +0300 @@ -0,0 +1 @@ +this is not empty output to make test fail diff -Nru cmdtest-0.27/NEWS cmdtest-0.32/NEWS --- cmdtest-0.27/NEWS 2016-09-21 07:32:41.000000000 +0000 +++ cmdtest-0.32/NEWS 2018-02-24 07:59:34.000000000 +0000 @@ -3,6 +3,39 @@ This file summarizes changes between releases of cmdtest. +Version 0.32, released 2018-02-24 +---------------------------------- + +* No changes. Want a new release to trigger an upload to Debian. + +Version 0.31, released 2017-04-30 +---------------------------------- + +* Add yarnutil.Variables methods: save, append, get. + +Version 0.30, released 2017-04-16 +---------------------------------- + +* Fix check for whether Python is used a shell. Previously the shell + had to be exactly "python", not anything that contains that is + enough. This is necessary to trigger PYTHONPATH manipulation when + using python2 explicitly. + +Version 0.29, released 2017-04-11 +---------------------------------- + +* Add assertions and getting the next parameter match to `yarnutils`. + +Version 0.28, released 2017-03-28 +---------------------------------- + +* Output from `--timings` is now properly formatted, rather than it + all being on one line. Daniel Silverstone reported the bug. + +* Add a new Python package `yarnutils` that can be imported into + IMPLEMENTS written in Python to simplify things. This version + provided persistent variables. + Version 0.27, released 2016-09-21 ---------------------------------- diff -Nru cmdtest-0.27/README cmdtest-0.32/README --- cmdtest-0.27/README 2016-09-21 07:32:41.000000000 +0000 +++ cmdtest-0.32/README 2018-02-24 07:59:34.000000000 +0000 @@ -37,11 +37,14 @@ [BDD]: https://en.wikipedia.org/wiki/Behavior-driven_development +It is possible that yarn will be split off into its own project +eventually. + Legalese -------- -Copyright 2011-2015 Lars Wirzenius +Copyright 2011-2017 Lars Wirzenius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff -Nru cmdtest-0.27/setup.py cmdtest-0.32/setup.py --- cmdtest-0.27/setup.py 2016-09-21 07:32:41.000000000 +0000 +++ cmdtest-0.32/setup.py 2018-02-24 07:59:34.000000000 +0000 @@ -103,7 +103,7 @@ url='http://liw.fi/cmdtest/', scripts=['cmdtest', 'yarn'], py_modules=['cmdtestlib'], - packages=['yarnlib'], + packages=['yarnlib', 'yarnutils'], data_files=[('share/man/man1', glob.glob('*.1'))], cmdclass={ 'build': GenerateManpage, diff -Nru cmdtest-0.27/without-tests cmdtest-0.32/without-tests --- cmdtest-0.27/without-tests 2016-09-21 07:32:41.000000000 +0000 +++ cmdtest-0.32/without-tests 2018-02-24 07:59:34.000000000 +0000 @@ -1,3 +1,5 @@ yarnlib/__init__.py +yarnlib/version.py setup.py yarnlib/elements.py +yarnutils/__init__.py diff -Nru cmdtest-0.27/yarn cmdtest-0.32/yarn --- cmdtest-0.27/yarn 2016-09-21 07:32:41.000000000 +0000 +++ cmdtest-0.32/yarn 2018-02-24 07:59:34.000000000 +0000 @@ -515,7 +515,7 @@ # used. This is a bit of magic that hopefully won't surprise # users too much. - if self.settings['shell'] == 'python': + if 'python' in self.settings['shell']: pythonpath = env.get('PYTHONPATH', None) if pythonpath: pythonpath += ':' + srcdir @@ -587,9 +587,9 @@ def report_timings(self): for scenario_name, scenario_duration, step_tuples in self.timings: - self.stdout('%5.1f %s' % (scenario_duration, scenario_name)) + self.stdout('%5.1f %s\n' % (scenario_duration, scenario_name)) for step_name, step_duration in step_tuples: - self.stdout(' %5.1f %s' % (step_duration, step_name)) + self.stdout(' %5.1f %s\n' % (step_duration, step_name)) YarnRunner(version=yarnlib.__version__).run() diff -Nru cmdtest-0.27/yarnlib/version.py cmdtest-0.32/yarnlib/version.py --- cmdtest-0.27/yarnlib/version.py 2016-09-21 07:32:41.000000000 +0000 +++ cmdtest-0.32/yarnlib/version.py 2018-02-24 07:59:34.000000000 +0000 @@ -1,2 +1,2 @@ -__version__ = "0.27" -__version_info__ = (0, 27) +__version__ = "0.32" +__version_info__ = (0, 32) diff -Nru cmdtest-0.27/yarnutils/asserts.py cmdtest-0.32/yarnutils/asserts.py --- cmdtest-0.27/yarnutils/asserts.py 1970-01-01 00:00:00.000000000 +0000 +++ cmdtest-0.32/yarnutils/asserts.py 2018-02-24 07:59:34.000000000 +0000 @@ -0,0 +1,66 @@ +# Copyright 2017 Lars Wirzenius +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# =*= License: GPL-3+ =*= + + +class AssertError(Exception): + + pass + + +def assertTrue(thing): + if not thing: + raise AssertError('expected {!r} to be true'.format(thing)) + + +def assertFalse(thing): + if thing: + raise AssertError('expected {!r} to be false'.format(thing)) + + +def assertEqual(a, b): + if a != b: + raise AssertError( + 'expected {!r} and {!r} to be equal, but they are not'.format( + a, b)) + + +def assertNotEqual(a, b): + if a == b: + raise AssertError( + 'expected {!r} and {!r} to be different, but they are not'.format( + a, b)) + + +def assertGreaterThan(a, b): + if a <= b: + raise AssertError( + 'expected {!r} > {!r}, but am disappoint'.format( + a, b)) + + +def assertLessThan(a, b): + if a >= b: + raise AssertError( + 'expected {!r} < {!r}, but am disappoint'.format( + a, b)) + + +def assertIn(a, b): + if a not in b: + raise AssertError( + 'expected {!r} in {!r}, but am disappoint'.format( + a, b)) diff -Nru cmdtest-0.27/yarnutils/asserts_tests.py cmdtest-0.32/yarnutils/asserts_tests.py --- cmdtest-0.27/yarnutils/asserts_tests.py 1970-01-01 00:00:00.000000000 +0000 +++ cmdtest-0.32/yarnutils/asserts_tests.py 2018-02-24 07:59:34.000000000 +0000 @@ -0,0 +1,68 @@ +# Copyright 2017 Lars Wirzenius +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# =*= License: GPL-3+ =*= + + +import unittest + +import yarnutils + + +class AssertTests(unittest.TestCase): + + def test_true_and_false_work(self): + truths = [ + True, 1, "notempty", [0], (0,), {'foo': 0}, + ] + falsehoods = [ + None, False, 0, "", [], {}, + ] + + for thing in truths: + yarnutils.assertTrue(thing) + with self.assertRaises(yarnutils.AssertError): + yarnutils.assertFalse(thing) + + for thing in falsehoods: + yarnutils.assertFalse(thing) + with self.assertRaises(yarnutils.AssertError): + yarnutils.assertTrue(thing) + + def test_equal_works(self): + yarnutils.assertEqual(0, 0) + with self.assertRaises(yarnutils.AssertError): + yarnutils.assertEqual("foo", None) + + def test_not_equal_works(self): + yarnutils.assertNotEqual(0, 1) + with self.assertRaises(yarnutils.AssertError): + yarnutils.assertNotEqual(0, 0) + + def test_gt_works(self): + yarnutils.assertGreaterThan(1, 0) + with self.assertRaises(yarnutils.AssertError): + yarnutils.assertGreaterThan(0, 1) + + def test_lt_works(self): + yarnutils.assertLessThan(0, 1) + with self.assertRaises(yarnutils.AssertError): + yarnutils.assertLessThan(1, 0) + + def test_in_works(self): + yarnutils.assertIn(0, [0]) + with self.assertRaises(yarnutils.AssertError): + yarnutils.assertIn(0, []) + yarnutils.assertIn(0, [1, 2, 3]) diff -Nru cmdtest-0.27/yarnutils/__init__.py cmdtest-0.32/yarnutils/__init__.py --- cmdtest-0.27/yarnutils/__init__.py 1970-01-01 00:00:00.000000000 +0000 +++ cmdtest-0.32/yarnutils/__init__.py 2018-02-24 07:59:34.000000000 +0000 @@ -0,0 +1,30 @@ +# Copyright 2017 Lars Wirzenius +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# =*= License: GPL-3+ =*= + + +from .vars import Variables +from .matches import get_next_match, set_env_for_matches +from .asserts import ( + AssertError, + assertTrue, + assertFalse, + assertEqual, + assertNotEqual, + assertGreaterThan, + assertLessThan, + assertIn, +) diff -Nru cmdtest-0.27/yarnutils/matches.py cmdtest-0.32/yarnutils/matches.py --- cmdtest-0.27/yarnutils/matches.py 1970-01-01 00:00:00.000000000 +0000 +++ cmdtest-0.32/yarnutils/matches.py 2018-02-24 07:59:34.000000000 +0000 @@ -0,0 +1,41 @@ +# Copyright 2017 Lars Wirzenius +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# =*= License: GPL-3+ =*= + + +import os + + +_env = {} +_next_match = 1 + + +def get_next_match(): + global _env, _next_match + key = 'MATCH_{}'.format(_next_match) + if key not in _env: + raise Exception('No further matches') + _next_match += 1 + return _env[key] + + +def set_env_for_matches(env): + global _env, _next_match + _env = env.copy() + _next_match = 1 + + +set_env_for_matches(os.environ) # pragma: no cover diff -Nru cmdtest-0.27/yarnutils/matches_tests.py cmdtest-0.32/yarnutils/matches_tests.py --- cmdtest-0.27/yarnutils/matches_tests.py 1970-01-01 00:00:00.000000000 +0000 +++ cmdtest-0.32/yarnutils/matches_tests.py 2018-02-24 07:59:34.000000000 +0000 @@ -0,0 +1,54 @@ +# Copyright 2017 Lars Wirzenius +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# =*= License: GPL-3+ =*= + + +import unittest + +import yarnutils + + +class GetNextMatchTests(unittest.TestCase): + + def test_raises_error_if_no_matches(self): + yarnutils.set_env_for_matches({}) + with self.assertRaises(Exception): + yarnutils.get_next_match() + + def test_returns_first_match(self): + yarnutils.set_env_for_matches({ + 'MATCH_1': 'foo', + }) + self.assertEqual(yarnutils.get_next_match(), 'foo') + + def test_returns_first_two_matches(self): + yarnutils.set_env_for_matches({ + 'MATCH_1': 'foo', + 'MATCH_2': 'bar', + }) + self.assertEqual(yarnutils.get_next_match(), 'foo') + self.assertEqual(yarnutils.get_next_match(), 'bar') + + def test_raises_error_after_last_match(self): + yarnutils.set_env_for_matches({}) + yarnutils.set_env_for_matches({ + 'MATCH_1': 'foo', + 'MATCH_2': 'bar', + }) + yarnutils.get_next_match() + yarnutils.get_next_match() + with self.assertRaises(Exception): + yarnutils.get_next_match() diff -Nru cmdtest-0.27/yarnutils/vars.py cmdtest-0.32/yarnutils/vars.py --- cmdtest-0.27/yarnutils/vars.py 1970-01-01 00:00:00.000000000 +0000 +++ cmdtest-0.32/yarnutils/vars.py 2018-02-24 07:59:34.000000000 +0000 @@ -0,0 +1,62 @@ +# Copyright 2017 Lars Wirzenius +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# =*= License: GPL-3+ =*= + + +import os +import yaml + + +class Variables(object): + + _basename = 'vars.yaml' + + def __init__(self, dirname): + self._filename = os.path.join(dirname, self._basename) + self._dict = self._load() + + def _load(self): + if os.path.exists(self._filename): + with open(self._filename) as f: + return yaml.safe_load(f) + else: + return {} + + def _save(self, values): + with open(self._filename, 'w') as f: + return yaml.safe_dump(values, stream=f) + + def __getitem__(self, key): + return self._dict.get(key) + + def __setitem__(self, key, value): + self._dict[key] = value + self._save(self._dict) + + def get(self, key, default=None): + return self._dict.get(key, default) + + def save(self): + self._save(self._dict) + + def append(self, key, value): + if key in self._dict: + if not isinstance(self[key], list): + raise Exception('Value for {} is not a list'.format(key)) + if key not in self._dict: + self._dict[key] = [] + self._dict[key].append(value) + self.save() diff -Nru cmdtest-0.27/yarnutils/vars_tests.py cmdtest-0.32/yarnutils/vars_tests.py --- cmdtest-0.27/yarnutils/vars_tests.py 1970-01-01 00:00:00.000000000 +0000 +++ cmdtest-0.32/yarnutils/vars_tests.py 2018-02-24 07:59:34.000000000 +0000 @@ -0,0 +1,80 @@ +# Copyright 2017 Lars Wirzenius +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# =*= License: GPL-3+ =*= + + +import shutil +import tempfile +import unittest + +import yarnutils + + +class VariablesTests(unittest.TestCase): + + def setUp(self): + self.tempdir = tempfile.mkdtemp() + + def tearDown(self): + shutil.rmtree(self.tempdir) + + def test_unset_variable_is_None(self): + vars = yarnutils.Variables(self.tempdir) + self.assertEqual(vars['foo'], None) + self.assertEqual(vars.get('foo'), None) + + def test_get_returns_default_for_missing_variable(self): + vars = yarnutils.Variables(self.tempdir) + self.assertEqual(vars.get('foo', 'default'), 'default') + + def test_get_returns_value_for_variable_that_exists(self): + vars = yarnutils.Variables(self.tempdir) + vars['foo'] = 'value' + self.assertEqual(vars.get('foo', 'default'), 'value') + + def test_set_value_is_persistent(self): + vars1 = yarnutils.Variables(self.tempdir) + vars1['foo'] = 'bar' + vars2 = yarnutils.Variables(self.tempdir) + self.assertEqual(vars1['foo'], vars2['foo']) + self.assertEqual(vars2['foo'], 'bar') + + def test_saves_explicitly(self): + vars1 = yarnutils.Variables(self.tempdir) + vars1['foo'] = [] + vars1['foo'].append(0) + vars1.save() + vars2 = yarnutils.Variables(self.tempdir) + self.assertEqual(vars1['foo'], vars2['foo']) + self.assertEqual(vars2['foo'], [0]) + + def test_appends_to_unset_key(self): + vars = yarnutils.Variables(self.tempdir) + vars.append('foo', 0) + self.assertEqual(vars['foo'], [0]) + + def test_append_saves(self): + vars1 = yarnutils.Variables(self.tempdir) + vars1.append('foo', 0) + vars2 = yarnutils.Variables(self.tempdir) + self.assertEqual(vars1['foo'], vars2['foo']) + self.assertEqual(vars2['foo'], [0]) + + def test_append_gives_error_if_appending_to_nonlist_value(self): + vars = yarnutils.Variables(self.tempdir) + vars['foo'] = 0 + with self.assertRaises(Exception): + vars.append('foo', 0)