From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/standard/
Date: Wed, 3 Aug 2011 20:17:02 +0000 (UTC) [thread overview]
Message-ID: <10a7eae3dede3ddb44240ec57729c0b8daec92f8.mgorny@gentoo> (raw)
commit: 10a7eae3dede3ddb44240ec57729c0b8daec92f8
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 3 19:08:35 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Aug 3 19:08:35 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=10a7eae3
Migrate the variable scope test to use assertions.
...and regexps. And add a test for unsetting a global var.
---
pmstestsuite/library/standard/variable_scope.py | 66 +++++++++++++++--------
1 files changed, 44 insertions(+), 22 deletions(-)
diff --git a/pmstestsuite/library/standard/variable_scope.py b/pmstestsuite/library/standard/variable_scope.py
index 9815a2d..c907ca7 100644
--- a/pmstestsuite/library/standard/variable_scope.py
+++ b/pmstestsuite/library/standard/variable_scope.py
@@ -10,43 +10,65 @@ class VariableScopeTest(DBusEbuildTestCase):
""" A test for scoping of variables. """
ebuild_vars = {
- 'GLOBAL_TEST': 'foo'
+ 'GLOBAL_TEST': 'foo',
+ 'UNSET_GLOBAL': 'foo'
}
phase_funcs = {
+ 'src_unpack': [
+ 'unset LOCAL_TEST'
+ ],
'src_compile': [
'GLOBAL_TEST=bar',
+ 'unset UNSET_GLOBAL',
'DEFAULT_TEST=foo',
'export EXPORT_TEST=foo',
'local LOCAL_TEST=bar'
],
'src_install': [
'pms-test-dbus_append_result "$(declare -p %s)"' % var
- for var in ('GLOBAL_TEST', 'DEFAULT_TEST',
+ for var in ('GLOBAL_TEST', 'UNSET_GLOBAL', 'DEFAULT_TEST',
'EXPORT_TEST', 'LOCAL_TEST')
]
}
declare_re = re.compile(r'^declare -([-x]) ([A-Z_]+)="([a-z]+)"$')
def check_dbus_result(self, output, pm):
- myvars = ('GLOBAL_TEST', 'DEFAULT_TEST', 'EXPORT_TEST', 'LOCAL_TEST')
- res = []
- for i, l in enumerate(output):
- m = self.declare_re.match(l)
- if not m or m.group(2) != myvars[i]:
- return False
- res.append([m.group(x) for x in (1,3)])
-
- # GLOBAL can retain its value or be reset
- if res[0][1] not in ('foo', 'bar'):
- return False
- # DEFAULT and EXPORT should retain their values
- elif res[1][1] != 'foo' or res[2][1] != 'foo':
- return False
- # EXPORT shall be exported
- elif res[2][0] != 'x':
- return False
- # LOCAL shall be forgot
- elif len(res) > 3 and res[3][1] != '':
- return False
+ class RegExpMatcher(object):
+ """ A matcher using a regular expression. """
+
+ def __init__(self, regexp, name):
+ self._re = re.compile(regexp)
+ self._re_str = regexp
+ self._name = name
+
+ def __eq__(self, other):
+ return bool(self._re.match(other))
+
+ def __repr__(self):
+ return 're(%s)' % repr(self._re_str.strip('^$'))
+
+ @property
+ def name(self):
+ return self._name
+
+ matches = [
+ # GLOBAL can retain its value or be reset
+ RegExpMatcher(r'^declare -[-x] GLOBAL_TEST="(foo|bar)"$',
+ 'global variable'),
+ # UNSET_GLOBAL can remain unset or be reset
+ RegExpMatcher(r'^(|declare -[-x] GLOBAL_TEST="foo")$',
+ 'unset global variable'),
+ # DEFAULT must retain its value
+ RegExpMatcher(r'^declare -[-x] DEFAULT_TEST="foo"$',
+ 'simple variable'),
+ # EXPORT must retain its value and be exported
+ RegExpMatcher(r'^declare -x EXPORT_TEST="foo"$',
+ 'exported variable'),
+ # LOCAL must be forgotten
+ RegExpMatcher(r'^$', 'local variable')
+ ]
+
+ for var, regexp in zip(output, matches):
+ self.assertEqual(var, regexp, regexp.name)
return DBusEbuildTestCase.check_dbus_result(self, output, pm)
next reply other threads:[~2011-08-03 20:17 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-03 20:17 Michał Górny [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-06-20 8:01 [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/standard/ Michał Górny
2012-01-03 17:50 Michał Górny
2012-01-03 17:50 Michał Górny
2012-01-03 15:52 Michał Górny
2011-08-13 8:54 Michał Górny
2011-08-12 20:55 Michał Górny
2011-08-08 2:56 Michał Górny
2011-08-07 14:57 Michał Górny
2011-08-07 14:57 Michał Górny
2011-08-07 14:48 Michał Górny
2011-08-06 14:25 Michał Górny
2011-08-06 8:31 Michał Górny
2011-08-06 8:31 Michał Górny
2011-08-05 21:36 Michał Górny
2011-08-05 21:36 Michał Górny
2011-08-05 21:36 Michał Górny
2011-08-05 21:36 Michał Górny
2011-08-05 10:04 Michał Górny
2011-08-05 8:54 Michał Górny
2011-08-03 20:17 Michał Górny
2011-08-03 17:10 Michał Górny
2011-08-03 17:10 Michał Górny
2011-08-03 17:10 Michał Górny
2011-08-03 8:17 Michał Górny
2011-08-02 18:53 Michał Górny
2011-08-02 18:53 Michał Górny
2011-07-28 17:15 Michał Górny
2011-07-27 16:50 Michał Górny
2011-07-27 16:50 Michał Górny
2011-07-27 16:50 Michał Górny
2011-07-26 17:34 Michał Górny
2011-07-24 14:37 Michał Górny
2011-07-24 14:37 Michał Górny
2011-07-18 6:32 Michał Górny
2011-07-18 6:32 Michał Górny
2011-06-29 17:52 Michał Górny
2011-06-29 12:58 Michał Górny
2011-06-28 16:15 Michał Górny
2011-06-28 16:15 Michał Górny
2011-06-25 8:39 Michał Górny
2011-06-24 18:03 [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/standard/ Michał Górny
2011-06-24 18:03 Michał Górny
2011-06-24 18:03 Michał Górny
2011-06-23 21:14 Michał Górny
2011-06-23 21:14 Michał Górny
2011-06-23 9:51 Michał Górny
2011-06-22 19:53 Michał Górny
2011-06-22 13:32 Michał Górny
2011-06-17 14:28 Michał Górny
2011-06-17 14:28 Michał Górny
2011-06-17 14:28 Michał Górny
2011-05-31 19:18 Michał Górny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=10a7eae3dede3ddb44240ec57729c0b8daec92f8.mgorny@gentoo \
--to=mgorny@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox