mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
nimsuggest tester: remove PCRE dependency (#25279)
Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
(cherry picked from commit 4c6d9b6068)
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
# When debugging, to run a single test, use for e.g.:
|
||||
# `nim r nimsuggest/tester.nim nimsuggest/tests/tsug_accquote.nim`
|
||||
|
||||
import os, osproc, strutils, streams, re, sexp, net
|
||||
import os, osproc, strutils, streams, sexp, net
|
||||
from sequtils import toSeq
|
||||
|
||||
type
|
||||
@@ -148,8 +148,28 @@ proc runCmd(cmd, dest: string): bool =
|
||||
quit "unknown command: " & cmd
|
||||
|
||||
proc smartCompare(pattern, x: string): bool =
|
||||
if pattern.contains('*'):
|
||||
result = match(x, re(escapeRe(pattern).replace("\\x2A","(.*)"), {}))
|
||||
let pp = splitLines(pattern.strip())
|
||||
let xx = splitLines(x.strip())
|
||||
if pp.len > xx.len:
|
||||
return false
|
||||
for l in 0..pp.len-1:
|
||||
let p = pp[l].split('\t')
|
||||
let x = xx[l].split('\t')
|
||||
if p.len > x.len:
|
||||
return false
|
||||
for i in 0..p.len-1:
|
||||
let starAt = p[i].find('*')
|
||||
if starAt >= 0:
|
||||
if p[i] == "*":
|
||||
discard "field exists, that is good enough"
|
||||
elif x[i].startsWith(p[i].substr(0, starAt-1)) and x[i].endsWith(p[i].substr(starAt+1)):
|
||||
discard
|
||||
else:
|
||||
return false
|
||||
else:
|
||||
if x[i] != p[i]:
|
||||
return false
|
||||
return true
|
||||
|
||||
proc sendEpcStr(socket: Socket; cmd: string) =
|
||||
let s = cmd.find(' ')
|
||||
|
||||
@@ -17,9 +17,9 @@ def;;skType;;minclude_types.Greet;;Greet;;*fixtures/minclude_types.nim;;4;;2;;""
|
||||
>def $path/fixtures/minclude_include.nim:3:71
|
||||
def;;skType;;minclude_types.Greet;;Greet;;*fixtures/minclude_types.nim;;4;;2;;"";;100
|
||||
>outline $path/fixtures/minclude_import.nim
|
||||
outline;;skProc;;minclude_import.say;;*fixtures/minclude_import.nim;;7;;5;;"";;100
|
||||
outline;;skProc;;minclude_import.create;;*fixtures/minclude_include.nim;;3;;5;;"";;100
|
||||
outline;;skProc;;minclude_import.say;;*fixtures/minclude_import.nim;;13;;5;;"";;100
|
||||
outline;;skProc;;minclude_import.say;;*;;*fixtures/minclude_import.nim;;7;;5;;"";;100
|
||||
outline;;skProc;;minclude_import.create;;*;;*fixtures/minclude_include.nim;;3;;5;;"";;100
|
||||
outline;;skProc;;minclude_import.say;;*;;*fixtures/minclude_import.nim;;13;;5;;"";;100
|
||||
"""
|
||||
|
||||
# TODO test/fix if the first `def` is not first or repeated we get no results
|
||||
|
||||
Reference in New Issue
Block a user