gitutils: add diffStrings, diffFiles, and use it in testament to compare expected vs gotten (#17892)
* gitutils: add diffStrings, diffFiles, and use it in testament to compare expected vs gotten * refactor with createTempDir * cleanup * refacotr * PRTEMP fake test spec changes to show effect of diffStrings * add runnableExamples for experimental/diff + cross-reference with gitutils * Revert "PRTEMP fake test spec changes to show effect of diffStrings" This reverts commit 57dc8d642dce6c1127c98b7cbc9edbfe747d4047.
This commit is contained in:
parent
1640508348
commit
20248a68fd
8 changed files with 99 additions and 52 deletions
|
|
@ -665,8 +665,8 @@ proc runJoinedTest(r: var TResults, cat: Category, testsDir: string, options: st
|
|||
|
||||
if buf != outputExpected:
|
||||
writeFile(outputExceptedFile, outputExpected)
|
||||
discard execShellCmd("diff -uNdr $1 $2" % [outputExceptedFile, outputGottenFile])
|
||||
echo failString & "megatest output different!"
|
||||
echo diffFiles(outputGottenFile, outputExceptedFile).output
|
||||
echo failString & "megatest output different, see $1 vs $2" % [outputGottenFile, outputExceptedFile]
|
||||
# outputGottenFile, outputExceptedFile not removed on purpose for debugging.
|
||||
quit 1
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ from std/sugar import dup
|
|||
import compiler/nodejs
|
||||
import lib/stdtest/testutils
|
||||
from lib/stdtest/specialpaths import splitTestFile
|
||||
from std/private/gitutils import diffStrings
|
||||
|
||||
proc trimUnitSep(x: var string) =
|
||||
let L = x.len
|
||||
|
|
@ -307,7 +308,7 @@ proc addResult(r: var TResults, test: TTest, target: TTarget,
|
|||
maybeStyledEcho styleBright, expected, "\n"
|
||||
maybeStyledEcho fgYellow, "Gotten:"
|
||||
maybeStyledEcho styleBright, given, "\n"
|
||||
|
||||
echo diffStrings(expected, given).output
|
||||
|
||||
if backendLogging and (isAppVeyor or isAzure):
|
||||
let (outcome, msg) =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue