Skip to content

Commit ba68dff

Browse files
committed
(test) adjust CLI testing to remove colors when verifying the printouts
1 parent 6beb1a9 commit ba68dff

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

tests/cli.nim

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@ import std/hashes
99
import ../nimplex
1010
import std/sets
1111
import std/times
12+
import std/re
1213

1314
let t0 = cpuTime()
15+
16+
proc stripAnsiEscapeCodes(s: string): string =
17+
let regex = re(r"\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]")
18+
return s.replace(regex, "")
19+
1420
echo "***** CLI Tests *****"
1521

1622
suite "test if correct grid output is given when nimplex is run in command line with some selected configurations":
@@ -31,7 +37,7 @@ suite "test if correct grid output is given when nimplex is run in command line
3137
"Shape: [10, 3]"]
3238
check exitCode == 0
3339
for i in 0..<reference.len:
34-
check outputLines[i] == reference[i]
40+
check outputLines[i].stripAnsiEscapeCodes() == reference[i]
3541

3642
test "generate large integer simplex grid (FIS 9 12) and print shape to stdout":
3743
let
@@ -42,7 +48,7 @@ suite "test if correct grid output is given when nimplex is run in command line
4248
"Shape: [125970, 9]"]
4349
check exitCode == 0
4450
for i in 0..<reference.len:
45-
check outputLines[i] == reference[i]
51+
check outputLines[i].stripAnsiEscapeCodes() == reference[i]
4652

4753
test "generate large internal integer simplex grid (IIS 7 12) and print shape to stdout":
4854
let
@@ -53,7 +59,7 @@ suite "test if correct grid output is given when nimplex is run in command line
5359
"Shape: [462, 7]"]
5460
check exitCode == 0
5561
for i in 0..<reference.len:
56-
check outputLines[i] == reference[i]
62+
check outputLines[i].stripAnsiEscapeCodes() == reference[i]
5763

5864
test "generate small integer simplex grid (FIP 3 3) and print values to stdout":
5965
let
@@ -75,7 +81,7 @@ suite "test if correct grid output is given when nimplex is run in command line
7581
]
7682
check exitCode == 0
7783
for i in 0..<reference.len:
78-
check outputLines[i] == reference[i]
84+
check outputLines[i].stripAnsiEscapeCodes() == reference[i]
7985

8086
test "generate small integer internal simplex grid (IIP 3 5) and print values to stdout":
8187
let
@@ -93,7 +99,7 @@ suite "test if correct grid output is given when nimplex is run in command line
9399
]
94100
check exitCode == 0
95101
for i in 0..<reference.len:
96-
check outputLines[i] == reference[i]
102+
check outputLines[i].stripAnsiEscapeCodes() == reference[i]
97103

98104
test "(significant if previous failes) values themself generated for small integer internal simplex grid (IIP 3 5) corectness":
99105
let
@@ -161,7 +167,7 @@ suite "test if correct graph output is given when nimplex is run in command line
161167
]
162168
check exitCode == 0
163169
for i in 0..<reference.len:
164-
check outputLines[i] == reference[i]
170+
check outputLines[i].stripAnsiEscapeCodes() == reference[i]
165171

166172
test "generate medium size integer simplex graph (GIS 7 12) and print shape to stdout":
167173
let
@@ -174,7 +180,7 @@ suite "test if correct graph output is given when nimplex is run in command line
174180
]
175181
check exitCode == 0
176182
for i in 0..<reference.len:
177-
check outputLines[i] == reference[i]
183+
check outputLines[i].stripAnsiEscapeCodes() == reference[i]
178184

179185
test "generate small integer simplex graph (GIP 3 3), print values to stdout, and check them for corectness":
180186
let
@@ -199,7 +205,7 @@ suite "test if correct graph output is given when nimplex is run in command line
199205
]
200206
check exitCode == 0
201207
for i in 0..<reference.len:
202-
check outputLines[i] == reference[i]
208+
check outputLines[i].stripAnsiEscapeCodes() == reference[i]
203209

204210
test "generate small fractional simplex graph (GFS 3 3) and print shape to stdout":
205211
let
@@ -212,7 +218,7 @@ suite "test if correct graph output is given when nimplex is run in command line
212218
]
213219
check exitCode == 0
214220
for i in 0..<reference.len:
215-
check outputLines[i] == reference[i]
221+
check outputLines[i].stripAnsiEscapeCodes() == reference[i]
216222

217223
test "generate small fractional simplex graph (GFP 3 3), print values to stdout, and check them for node corectness":
218224
let

0 commit comments

Comments
 (0)