Updated tests to use yaml-test-suite repo url

This commit is contained in:
Felix Krause 2016-12-12 19:29:39 +01:00
parent 9b5d0e60c6
commit c2041b44d1
2 changed files with 17 additions and 16 deletions

3
.gitignore vendored
View File

@ -5,7 +5,6 @@ test/tdom
test/tserialization test/tserialization
test/tjson test/tjson
test/tparser test/tparser
test/yamlTestSuite
test/tquickstart test/tquickstart
test/*.exe test/*.exe
test/*.pdb test/*.pdb
@ -22,5 +21,5 @@ docout
doc/rstPreproc doc/rstPreproc
doc/tmp.rst doc/tmp.rst
doc/**/code doc/**/code
yaml-dev-kit test/yaml-test-suite
nimsuggest.log nimsuggest.log

View File

@ -8,19 +8,21 @@ import os, osproc, terminal, strutils, streams, macros, unittest
import testEventParser, commonTestUtils import testEventParser, commonTestUtils
import "../yaml" import "../yaml"
const devKitFolder = "yaml-dev-kit" const
testSuiteFolder = "yaml-test-suite"
testSuiteUrl = "https://github.com/yaml/yaml-test-suite.git"
proc echoError(msg: string) = proc echoError(msg: string) =
styledWriteLine(stdout, fgRed, "[error] ", fgWhite, msg, resetStyle) styledWriteLine(stdout, fgRed, "[error] ", fgWhite, msg, resetStyle)
proc ensureDevKitCloneCorrect(pwd: string) {.compileTime.} = proc ensureTestSuiteCloneCorrect(pwd: string) {.compileTime.} =
let absolutePath = pwd / devKitFolder let absolutePath = pwd / testSuiteFolder
if dirExists(absolutePath): if dirExists(absolutePath):
var isCorrectClone = true var isCorrectClone = true
if dirExists(absolutePath / ".git"): if dirExists(absolutePath / ".git"):
let remoteUrl = let remoteUrl =
staticExec("cd \"" & absolutePath & "\" && git remote get-url origin") staticExec("cd \"" & absolutePath & "\" && git remote get-url origin")
if remoteUrl != "https://github.com/ingydotnet/yaml-dev-kit.git": if remoteUrl != testSuiteUrl:
isCorrectClone = false isCorrectClone = false
let branches = staticExec("cd \"" & absolutePath & "\" && git branch") let branches = staticExec("cd \"" & absolutePath & "\" && git branch")
if "* data" notin branches.splitLines(): if "* data" notin branches.splitLines():
@ -28,25 +30,25 @@ proc ensureDevKitCloneCorrect(pwd: string) {.compileTime.} =
if isCorrectClone: if isCorrectClone:
let updateOutput = staticExec("cd \"" & absolutePath & "\" && git pull") let updateOutput = staticExec("cd \"" & absolutePath & "\" && git pull")
#if uError != 0: #if uError != 0:
# echo "could not update yaml-dev-kit! please fix this problem and compile again." # echo "could not update yaml-test-suite! please fix this problem and compile again."
# echo "output:\n" # echo "output:\n"
# echo "$ git pull" # echo "$ git pull"
# echo updateOutput # echo updateOutput
# quit 1 # quit 1
else: else:
echo devKitFolder, " exists, but is not in expected state. Make sure it is a git repo," echo testSuiteFolder, " exists, but is not in expected state. Make sure it is a git repo,"
echo "cloned from https://github.com/ingydotnet/yaml-dev-kit.git, and the data branch" echo "cloned from ", testSuiteUrl, ", and the data branch"
echo "is active. Alternatively, delete the folder " & devKitFolder & '.' echo "is active. Alternatively, delete the folder " & testSuiteFolder & '.'
quit 1 quit 1
else: else:
let cloneOutput = staticExec("cd \"" & pwd & let cloneOutput = staticExec("cd \"" & pwd &
"\" && git clone https://github.com/ingydotnet/yaml-dev-kit.git -b data") "\" && git clone " & testSuiteUrl & " -b data")
#if cError != 0: #if cError != 0:
if not(dirExists(absolutePath)) or not(dirExists(absolutePath / ".git")) or if not(dirExists(absolutePath)) or not(dirExists(absolutePath / ".git")) or
not(dirExists(absolutePath / "229Q")): not(dirExists(absolutePath / "229Q")):
echo "could not clone https://github.com/ingydotnet/yaml-dev-kit.git. Make sure" echo "could not clone ", testSuiteUrl, ". Make sure"
echo "you are connected to the internet and your proxy settings are correct. output:\n" echo "you are connected to the internet and your proxy settings are correct. output:\n"
echo "$ git clone https://github.com/ingydotnet/yaml-dev-kit.git" echo "$ git clone ", testSuiteUrl, " -b data"
echo cloneOutput echo cloneOutput
quit 1 quit 1
@ -95,9 +97,9 @@ proc parserTest(path: string): bool =
macro genTests(): untyped = macro genTests(): untyped =
let let
pwd = staticExec("pwd") pwd = staticExec("pwd")
absolutePath = '"' & (pwd / devKitFolder) & '"' absolutePath = '"' & (pwd / testSuiteFolder) & '"'
echo "[tparser] Generating tests from " & absolutePath echo "[tparser] Generating tests from " & absolutePath
ensureDevKitCloneCorrect(pwd) ensureTestSuiteCloneCorrect(pwd)
result = newStmtList() result = newStmtList()
# walkDir for some crude reason does not work with travis build # walkDir for some crude reason does not work with travis build
let dirItems = staticExec("ls -1d " & absolutePath / "*") let dirItems = staticExec("ls -1d " & absolutePath / "*")
@ -108,6 +110,6 @@ macro genTests(): untyped =
newLit(strip(title) & " [" & newLit(strip(title) & " [" &
dirPath[^4..^1] & ']'), newCall("doAssert", newCall("parserTest", dirPath[^4..^1] & ']'), newCall("doAssert", newCall("parserTest",
newLit(dirPath))))) newLit(dirPath)))))
result = newCall("suite", newLit("Parser Tests (from yaml-dev-kit)"), result) result = newCall("suite", newLit("Parser Tests (from yaml-test-suite)"), result)
genTests() genTests()