summaryrefslogtreecommitdiff
path: root/yarns/010-tests.yarn
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2014-04-16 18:53:05 +0100
committerLars Wirzenius <liw@liw.fi>2014-04-16 18:53:05 +0100
commitc390eeae90f68def13e3a718f0fa013f36c719a7 (patch)
tree293c1988deb9c937b882f2c6c50344b12d9cb0c3 /yarns/010-tests.yarn
parent0b4585915a6c03fc15e8627b0308dbc7d194a2da (diff)
parent3f6f737c4fbcbd267ed135f968eec181d6ced508 (diff)
downloadcopyright-statement-lint-c390eeae90f68def13e3a718f0fa013f36c719a7.tar.gz
Merge branch 'liw/add-tests'
Diffstat (limited to 'yarns/010-tests.yarn')
-rw-r--r--yarns/010-tests.yarn140
1 files changed, 139 insertions, 1 deletions
diff --git a/yarns/010-tests.yarn b/yarns/010-tests.yarn
index 72020c0..e2ec72d 100644
--- a/yarns/010-tests.yarn
+++ b/yarns/010-tests.yarn
@@ -16,7 +16,8 @@ the output of the tool is as expected.
Scenarios
=========
-Simple case: no copyright file.
+No copyright file
+-----------------
SCENARIO no copyright file
GIVEN an empty file FOOBAR
@@ -24,6 +25,131 @@ Simple case: no copyright file.
THEN exit code is 1
AND stderr contains "FOOBAR.*no copyright statement"
+Simple copyright statement
+--------------------------
+
+ SCENARIO simple copyright statement
+ GIVEN a file FOOBAR containing "Copyright 2014 Foo Bar"
+
+ GIVEN commit year is 2013
+ WHEN copyright-statement-lint is run against FOOBAR
+ THEN exit code is 1
+ AND stderr contains "FOOBAR.*2013 not contained"
+
+ GIVEN commit year is 2014
+ WHEN copyright-statement-lint is run against FOOBAR
+ THEN exit code is 0
+
+ GIVEN commit year is 2015
+ WHEN copyright-statement-lint is run against FOOBAR
+ THEN exit code is 1
+ AND stderr contains "FOOBAR.*2015 not contained"
+
+Itemised copyright years
+------------------------
+
+ SCENARIO itemised copyright years
+ GIVEN a file FOOBAR containing "Copyright 1999,2014 Foo Bar"
+
+ GIVEN commit year is 1998
+ WHEN copyright-statement-lint is run against FOOBAR
+ THEN exit code is 1
+ AND stderr contains "FOOBAR.*1998 not contained"
+
+ GIVEN commit year is 1999
+ WHEN copyright-statement-lint is run against FOOBAR
+ THEN exit code is 0
+
+ GIVEN commit year is 2000
+ WHEN copyright-statement-lint is run against FOOBAR
+ THEN exit code is 1
+ AND stderr contains "FOOBAR.*2000 not contained"
+
+ GIVEN commit year is 2013
+ WHEN copyright-statement-lint is run against FOOBAR
+ THEN exit code is 1
+ AND stderr contains "FOOBAR.*2013 not contained"
+
+ GIVEN commit year is 2014
+ WHEN copyright-statement-lint is run against FOOBAR
+ THEN exit code is 0
+
+ GIVEN commit year is 2015
+ WHEN copyright-statement-lint is run against FOOBAR
+ THEN exit code is 1
+ AND stderr contains "FOOBAR.*2015 not contained"
+
+Range of copyright years
+------------------------
+
+ SCENARIO range of copyright years
+ GIVEN a file FOOBAR containing "Copyright 1999-2014 Foo Bar"
+
+ GIVEN commit year is 1998
+ WHEN copyright-statement-lint is run against FOOBAR
+ THEN exit code is 1
+ AND stderr contains "FOOBAR.*1998 not contained"
+
+ GIVEN commit year is 1999
+ WHEN copyright-statement-lint is run against FOOBAR
+ THEN exit code is 0
+
+ GIVEN commit year is 2000
+ WHEN copyright-statement-lint is run against FOOBAR
+ THEN exit code is 0
+
+ GIVEN commit year is 2013
+ WHEN copyright-statement-lint is run against FOOBAR
+ THEN exit code is 0
+
+ GIVEN commit year is 2014
+ WHEN copyright-statement-lint is run against FOOBAR
+ THEN exit code is 0
+
+ GIVEN commit year is 2015
+ WHEN copyright-statement-lint is run against FOOBAR
+ THEN exit code is 1
+ AND stderr contains "FOOBAR.*2015 not contained"
+
+Combined itemised and range of copyright years
+----------------------------------------------
+
+ SCENARIO combined itemised and range of copyright years
+ GIVEN a file FOOBAR containing "Copyright 1999-2000, 2014 Foo Bar"
+
+ GIVEN commit year is 1998
+ WHEN copyright-statement-lint is run against FOOBAR
+ THEN exit code is 1
+ AND stderr contains "FOOBAR.*1998 not contained"
+
+ GIVEN commit year is 1999
+ WHEN copyright-statement-lint is run against FOOBAR
+ THEN exit code is 0
+
+ GIVEN commit year is 2000
+ WHEN copyright-statement-lint is run against FOOBAR
+ THEN exit code is 0
+
+ GIVEN commit year is 2001
+ WHEN copyright-statement-lint is run against FOOBAR
+ THEN exit code is 1
+ AND stderr contains "FOOBAR.*2001 not contained"
+
+ GIVEN commit year is 2013
+ WHEN copyright-statement-lint is run against FOOBAR
+ THEN exit code is 1
+ AND stderr contains "FOOBAR.*2013 not contained"
+
+ GIVEN commit year is 2014
+ WHEN copyright-statement-lint is run against FOOBAR
+ THEN exit code is 0
+
+ GIVEN commit year is 2015
+ WHEN copyright-statement-lint is run against FOOBAR
+ THEN exit code is 1
+ AND stderr contains "FOOBAR.*2015 not contained"
+
+
Implementations
===============
@@ -36,6 +162,16 @@ in `$DATADIR` using names given by the user.
IMPLEMENTS GIVEN an empty file (\S+)
touch "$DATADIR/$MATCH_1"
+ IMPLEMENTS GIVEN a file (\S+) containing "(.*)"
+ printf '%s\n' "$MATCH_2" > "$DATADIR/$MATCH_1"
+
+Pretending what the commit year is
+----------------------------------
+
+ IMPLEMENTS GIVEN commit year is (\d+)
+ printf '[config]\ndebug-commit-year = %s\n' "$MATCH_1" \
+ > "$DATADIR/test.conf"
+
Running and checking the results of `copyright-statement-lint`
--------------------------------------------------------------
@@ -48,6 +184,7 @@ tool fails.
# code. Don't want to turn set -e off, so we capture other errors.
if "$SRCDIR/copyright-statement-lint" \
--no-default-config "$DATADIR/$MATCH_1" \
+ --config "$DATADIR/test.conf" \
> "$DATADIR/stdout" \
2> "$DATADIR/stderr"
then
@@ -67,4 +204,5 @@ every scenario is expected to check the exit code.
Check stdout/stderr.
IMPLEMENTS THEN (\S+) contains "(.*)"
+ cat "$DATADIR/$MATCH_1"
grep "$MATCH_2" "$DATADIR/$MATCH_1"