summary refs log tree commit diff stats
path: root/tests/testament
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2015-04-21 08:51:16 +0200
committerAndreas Rumpf <rumpf_a@web.de>2015-04-21 08:51:16 +0200
commit3e2c086b1fa65361daa9272efeafc3d725f87818 (patch)
treef3b396a7f9ba1f0da0a6b440cc0c241e8a1eba1c /tests/testament
parent248dc42aa5c18aae9d63c863998ca938593bc227 (diff)
parent505836385cbbfdc6a4a728b07dd1c528f59dc8d7 (diff)
downloadNim-3e2c086b1fa65361daa9272efeafc3d725f87818.tar.gz
Merge pull request #2575 from nanoant/test-for-error-location-column
Tests: Optional error location column spec
Diffstat (limited to 'tests/testament')
-rw-r--r--tests/testament/specs.nim6
-rw-r--r--tests/testament/tester.nim15
2 files changed, 15 insertions, 6 deletions
diff --git a/tests/testament/specs.nim b/tests/testament/specs.nim
index 2a8a4ea24..8bf1a4ad7 100644
--- a/tests/testament/specs.nim
+++ b/tests/testament/specs.nim
@@ -42,7 +42,8 @@ type
     action*: TTestAction
     file*, cmd*: string
     outp*: string
-    line*, exitCode*: int
+    line*, column*: int
+    exitCode*: int
     msg*: string
     ccodeCheck*: string
     err*: TResultEnum
@@ -98,6 +99,8 @@ proc parseSpec*(filename: string): TSpec =
   result.nimout = ""
   result.ccodeCheck = ""
   result.cmd = cmdTemplate
+  result.line = 0
+  result.column = 0
   parseSpecAux:
     case normalize(e.key)
     of "action":
@@ -108,6 +111,7 @@ proc parseSpec*(filename: string): TSpec =
       else: echo ignoreMsg(p, e)
     of "file": result.file = e.value
     of "line": discard parseInt(e.value, result.line)
+    of "column": discard parseInt(e.value, result.column)
     of "output": 
       result.action = actionRun
       result.outp = e.value
diff --git a/tests/testament/tester.nim b/tests/testament/tester.nim
index 7391b105e..ed39109ad 100644
--- a/tests/testament/tester.nim
+++ b/tests/testament/tester.nim
@@ -50,7 +50,7 @@ type
 
 let
   pegLineError =
-    peg"{[^(]*} '(' {\d+} ', ' \d+ ') ' ('Error') ':' \s* {.*}"
+    peg"{[^(]*} '(' {\d+} ', ' {\d+} ') ' ('Error') ':' \s* {.*}"
   pegOtherError = peg"'Error:' \s* {.*}"
   pegSuccess = peg"'Hint: operation successful'.*"
   pegOfInterest = pegLineError / pegOtherError
@@ -77,11 +77,13 @@ proc callCompiler(cmdTemplate, filename, options: string,
   result.msg = ""
   result.file = ""
   result.outp = ""
-  result.line = -1
+  result.line = 0
+  result.column = 0
   if err =~ pegLineError:
     result.file = extractFilename(matches[0])
     result.line = parseInt(matches[1])
-    result.msg = matches[2]
+    result.column = parseInt(matches[2])
+    result.msg = matches[3]
   elif err =~ pegOtherError:
     result.msg = matches[0]
   elif suc =~ pegSuccess:
@@ -130,8 +132,11 @@ proc cmpMsgs(r: var TResults, expected, given: TSpec, test: TTest) =
   elif extractFilename(expected.file) != extractFilename(given.file) and
       "internal error:" notin expected.msg:
     r.addResult(test, expected.file, given.file, reFilesDiffer)
-  elif expected.line != given.line and expected.line != 0:
-    r.addResult(test, $expected.line, $given.line, reLinesDiffer)
+  elif expected.line   != given.line   and expected.line   != 0 or
+       expected.column != given.column and expected.column != 0:
+    r.addResult(test, $expected.line & ':' & $expected.column,
+                      $given.line    & ':' & $given.column,
+                      reLinesDiffer)
   else:
     r.addResult(test, expected.msg, given.msg, reSuccess)
     inc(r.passed)
51ee524109cf7e3e86c676bc1676063a01bfd979'>^
335c19c86 ^
20b5f31c0 ^


2fb5d6292 ^
20b5f31c0 ^
4ab56d6be ^
20b5f31c0 ^




16b15f360 ^
20b5f31c0 ^















6725aa363 ^
20b5f31c0 ^
16b15f360 ^
20b5f31c0 ^










6725aa363 ^
20b5f31c0 ^

335c19c86 ^
20b5f31c0 ^

505836385 ^

391f2fc9b ^


6725aa363 ^
25abb7c2b ^








6725aa363 ^


20b5f31c0 ^









505836385 ^
2240fd3f3 ^


6725aa363 ^
20b5f31c0 ^





f12a0820e ^

6725aa363 ^
20b5f31c0 ^
f49f2f38f ^




20b5f31c0 ^

335c19c86 ^

20b5f31c0 ^












1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168