summary refs log tree commit diff stats
path: root/testament/lib
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2020-12-01 12:12:40 -0800
committerGitHub <noreply@github.com>2020-12-01 21:12:40 +0100
commite0b4f05053e87b5b498c53338eed643787783b18 (patch)
tree4a7b9b5f1a43436a6686b8e4ab4e2c8b2ba66d70 /testament/lib
parent62eb1312a099aeae0115beb038ed8449ccd095a7 (diff)
downloadNim-e0b4f05053e87b5b498c53338eed643787783b18.tar.gz
nimout now consistently uses nimoutCheck (#16189)
Diffstat (limited to 'testament/lib')
-rw-r--r--testament/lib/stdtest/testutils.nim11
1 files changed, 11 insertions, 0 deletions
diff --git a/testament/lib/stdtest/testutils.nim b/testament/lib/stdtest/testutils.nim
index 8083a63e8..34aa3b751 100644
--- a/testament/lib/stdtest/testutils.nim
+++ b/testament/lib/stdtest/testutils.nim
@@ -1,4 +1,5 @@
 import std/private/miscdollars
+import std/strutils
 
 template flakyAssert*(cond: untyped, msg = "", notifySuccess = true) =
   ## API to deal with flaky or failing tests. This avoids disabling entire tests
@@ -23,3 +24,13 @@ template flakyAssert*(cond: untyped, msg = "", notifySuccess = true) =
       msg2.add " FLAKY_FAILURE "
     msg2.add $expr & " " & msg
     echo msg2
+
+proc greedyOrderedSubsetLines*(lhs, rhs: string): bool =
+  ## returns true if each stripped line in `lhs` appears in rhs, using a greedy matching.
+  let rhs = rhs.strip
+  var currentPos = 0
+  for line in lhs.strip.splitLines:
+    currentPos = rhs.find(line.strip, currentPos)
+    if currentPos < 0:
+      return false
+  return true