From d9f0a876a0ec1c5320d77b0b4314bbd4a5b11bd3 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Thu, 19 Sep 2013 19:09:00 +0100 Subject: Match IMPLEMENTS always case-insensitively Reported-by: Jannis Pohlmann --- NEWS | 3 +++ yarn | 16 ++++++++++++++-- yarn.tests/env.script | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 797291e..9aad0a2 100644 --- a/NEWS +++ b/NEWS @@ -32,6 +32,9 @@ Bug fixes: * Yarn now checks for duplicate scenario names. +* Yarn now always checks for IMPLEMENTS sections with case-insensitive + matching. Reported, with test case, by Jannis Pohlmann. + Version 0.9, released 2013-07-23 -------------------------------- diff --git a/yarn b/yarn index 501d10e..f4abcdc 100755 --- a/yarn +++ b/yarn @@ -204,7 +204,7 @@ class YarnRunner(cliapp.Application): def connect_implementation(self, scenario, step, implementations): matching = [i for i in implementations if step.what == i.what and - re.match('(%s)$' % i.regexp, step.text, re.I)] + self.implements_matches_step(i, step)] if len(matching) == 0: raise cliapp.AppException( @@ -371,7 +371,7 @@ class YarnRunner(cliapp.Application): self.ts['step_name'] = '%s %s' % (step.what, step.text) self.steps_run += 1 - m = re.match(step.implementation.regexp, step.text) + m = self.implements_matches_step(step.implementation, step) assert m is not None env = self.clean_env() env['DATADIR'] = datadir @@ -439,6 +439,18 @@ class YarnRunner(cliapp.Application): nice = ''.join(nice) return nice + def implements_matches_step(self, implements, step): + '''Return re.Match if implements matches the step. + + Otherwise, return None. + + ''' + + m = re.match(implements.regexp, step.text, re.I) + if m and m.end() != len(step.text): + return None + return m + def indent(self, s): return ''.join(' %s\n' % line for line in s.splitlines()) diff --git a/yarn.tests/env.script b/yarn.tests/env.script index 2ef35c6..d14a21a 100755 --- a/yarn.tests/env.script +++ b/yarn.tests/env.script @@ -9,6 +9,7 @@ cat << 'EOF' > "$DATADIR/env.yarn" AND NOTSET is not set IMPLEMENTS THEN (\S+) is set + env env | grep "^$MATCH_1=" IMPLEMENTS THEN (\S+) is not set -- cgit v1.2.1