Selaa lähdekoodia

Add line number assert function

Alois Mahdal 11 vuotta sitten
vanhempi
commit
1465aff5ab
1 muutettua tiedostoa jossa 16 lisäystä ja 0 poistoa
  1. 16
    0
      include/testing.sh

+ 16
- 0
include/testing.sh Näytä tiedosto

@@ -2,6 +2,22 @@
2 2
 
3 3
 ffoo import core
4 4
 
5
+assert_linecount() {
6
+    #
7
+    # Assert that count of lines in $1 is $2
8
+    #
9
+    local ex file num
10
+    file="$1"
11
+    ex="$@"
12
+    case $ex in
13
+        [0-9]*) ex="-eq $ex" ;;
14
+        -*)     true         ;;
15
+        *)      usage_is -l "FILE EXPR" \
16
+                            "FILE NUM" ;;
17
+    esac
18
+    test 0$(wc -l <$file) $2
19
+}
20
+
5 21
 collect_artifacts() {
6 22
     #
7 23
     # Collect everything that is registered as artifact