summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-06-09 17:34:51 +0200
committerAndreas Rumpf <rumpf_a@web.de>2016-06-09 17:34:57 +0200
commit76c8d6164b10846f18dbd441e4d1db5d501da09d (patch)
tree61127dbd248c2bfead73ce1e57e087a48bb858e4
parent0ea65a824d61dcfeb93193f38745667880943ba3 (diff)
downloadNim-76c8d6164b10846f18dbd441e4d1db5d501da09d.tar.gz
added 'koch testinstall' command; more installer related bugfixes
-rw-r--r--compiler/installer.ini1
-rw-r--r--koch.nim40
-rw-r--r--tests/async/tasynceverror.nim4
-rw-r--r--tests/testament/specs.nim6
-rw-r--r--tests/testament/tester.nim1
-rw-r--r--tools/niminst/niminst.nim6
-rw-r--r--tools/nimweb.nim37
7 files changed, 78 insertions, 17 deletions
diff --git a/compiler/installer.ini b/compiler/installer.ini
index 8fe269cdd..96254252f 100644
--- a/compiler/installer.ini
+++ b/compiler/installer.ini
@@ -68,6 +68,7 @@ Files: "web/ticker.html"
 Files: "web/*.nim"
 Files: "web/*.txt"
 Files: "web/*.rst"
+Files: "web/*.csv"
 Files: "web/news/*.rst"
 Files: "bin/nimblepkg/*.nim"
 Files: "bin/nimblepkg/*.cfg"
diff --git a/koch.nim b/koch.nim
index 3e893e841..4737d4a92 100644
--- a/koch.nim
+++ b/koch.nim
@@ -42,6 +42,7 @@ Possible Commands:
   boot [options]           bootstraps with given command line options
   install [bindir]         installs to given directory; Unix only!
   geninstall               generate ./install.sh; Unix only!
+  testinstall              test tar.xz package; Unix only! Only for devs!
   clean                    cleans Nim project; removes generated files
   web [options]            generates the website and the full documentation
   website [options]        generates only the website
@@ -91,6 +92,44 @@ proc exec(cmd: string, errorcode: int = QuitFailure, additionalPATH = "") =
   if execShellCmd(cmd) != 0: quit("FAILURE", errorcode)
   putEnv("PATH", prevPATH)
 
+proc execCleanPath(cmd: string,
+                   additionalPath = ""; errorcode: int = QuitFailure) =
+  # simulate a poor man's virtual environment
+  let prevPath = getEnv("PATH")
+  when defined(windows):
+    let CleanPath = r"$1\system32;$1;$1\System32\Wbem" % getEnv"SYSTEMROOT"
+  else:
+    const CleanPath = r"/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin"
+  putEnv("PATH", CleanPath & PathSep & additionalPath)
+  echo(cmd)
+  if execShellCmd(cmd) != 0: quit("FAILURE", errorcode)
+  putEnv("PATH", prevPath)
+
+proc testUnixInstall() =
+  let oldCurrentDir = getCurrentDir()
+  try:
+    let destDir = getTempDir()
+    copyFile("build/nim-$1.tar.xz" % VersionAsString,
+             destDir / "nim-$1.tar.xz" % VersionAsString)
+    setCurrentDir(destDir)
+    execCleanPath("tar -xzf nim-$1.tar.xz" % VersionAsString)
+    setCurrentDir("nim-$1" % VersionAsString)
+    execCleanPath("sh build.sh")
+    # first test: try if './bin/nim --version' outputs something sane:
+    let output = execProcess("./bin/nim --version").splitLines
+    if output.len > 0 and output[0].contains(VersionAsString):
+      echo "Version check: success"
+      execCleanPath("./bin/nim c koch.nim")
+      execCleanPath("./koch boot -d:release", destDir / "bin")
+      # check the docs build:
+      execCleanPath("./koch web", destDir / "bin")
+      # check the tests work:
+      execCleanPath("./koch tests", destDir / "bin")
+    else:
+      echo "Version check: failure"
+  finally:
+    setCurrentDir oldCurrentDir
+
 proc tryExec(cmd: string): bool =
   echo(cmd)
   result = execShellCmd(cmd) == 0
@@ -405,6 +444,7 @@ of cmdArgument:
   of "nsis": nsis(op.cmdLineRest)
   of "geninstall": geninstall(op.cmdLineRest)
   of "install": install(op.cmdLineRest)
+  of "testinstall": testUnixInstall()
   of "test", "tests": tests(op.cmdLineRest)
   of "update":
     when defined(withUpdate):
diff --git a/tests/async/tasynceverror.nim b/tests/async/tasynceverror.nim
index fd6d05c60..dd05c831b 100644
--- a/tests/async/tasynceverror.nim
+++ b/tests/async/tasynceverror.nim
@@ -1,9 +1,9 @@
 discard """
   file: "tasynceverror.nim"
   exitcode: 1
-  outputsub: "Error: unhandled exception: Connection reset by peer"
+  outputsub: "Error: unhandled exception: "
 """
-
+# error message is actually different on OSX
 import
     asyncdispatch,
     asyncnet,
diff --git a/tests/testament/specs.nim b/tests/testament/specs.nim
index 3f40a5342..b9519c70f 100644
--- a/tests/testament/specs.nim
+++ b/tests/testament/specs.nim
@@ -155,7 +155,11 @@ proc parseSpec*(filename: string): TSpec =
       result.nimout = e.value
     of "disabled":
       if parseCfgBool(e.value): result.err = reIgnored
-    of "cmd": result.cmd = e.value
+    of "cmd":
+      if e.value.startsWith("nim "):
+        result.cmd = "compiler" / e.value
+      else:
+        result.cmd = e.value
     of "ccodecheck": result.ccodeCheck = e.value
     of "target", "targets":
       for v in e.value.normalize.split:
diff --git a/tests/testament/tester.nim b/tests/testament/tester.nim
index da1c6fc2d..9a253d0ff 100644
--- a/tests/testament/tester.nim
+++ b/tests/testament/tester.nim
@@ -284,6 +284,7 @@ proc testSpec(r: var TResults, test: TTest) =
     return
 
   let tname = test.name.addFileExt(".nim")
+  #echo "TESTING ", tname
   inc(r.total)
   var expected: TSpec
   if test.action != actionRunNoSpec:
diff --git a/tools/niminst/niminst.nim b/tools/niminst/niminst.nim
index 9f255e64b..b2983b23b 100644
--- a/tools/niminst/niminst.nim
+++ b/tools/niminst/niminst.nim
@@ -635,8 +635,10 @@ proc xzDist(c: var ConfigData) =
     let oldDir = getCurrentDir()
     setCurrentDir(tmpDir)
     try:
-      if execShellCmd("XZ_OPT=-9 tar Jcf $1.tar.xz $1" % proj) != 0:
-        echo("External program failed")
+      if execShellCmd("XZ_OPT=-9 gtar Jcf $1.tar.xz $1 --exclude=.DS_Store" % proj) != 0:
+        # try old 'tar' without --exclude feature:
+        if execShellCmd("XZ_OPT=-9 tar Jcf $1.tar.xz $1" % proj) != 0:
+          echo("External program failed")
     finally:
       setCurrentDir(oldDir)
 
diff --git a/tools/nimweb.nim b/tools/nimweb.nim
index fd69bebdd..7cb4b5ab4 100644
--- a/tools/nimweb.nim
+++ b/tools/nimweb.nim
@@ -251,9 +251,22 @@ proc parseIniFile(c: var TConfigData) =
 
 # ------------------- main ----------------------------------------------------
 
+
+proc exe(f: string): string = return addFileExt(f, ExeExt)
+
+proc findNim(): string =
+  var nim = "nim".exe
+  result = "bin" / nim
+  if existsFile(result): return
+  for dir in split(getEnv("PATH"), PathSep):
+    if existsFile(dir / nim): return dir / nim
+  # assume there is a symlink to the exe or something:
+  return nim
+
 proc exec(cmd: string) =
   echo(cmd)
-  if os.execShellCmd(cmd) != 0: quit("external program failed")
+  let (_, exitCode) = osproc.execCmdEx(cmd)
+  if exitCode != 0: quit("external program failed")
 
 proc sexec(cmds: openarray[string]) =
   ## Serial queue wrapper around exec.
@@ -275,9 +288,9 @@ proc buildDocSamples(c: var TConfigData, destPath: string) =
   ## it didn't make much sense to integrate into the existing generic
   ## documentation builders.
   const src = "doc"/"docgen_sample.nim"
-  exec("nim doc $# -o:$# $#" %
+  exec(findNim() & " doc $# -o:$# $#" %
     [c.nimArgs, destPath / "docgen_sample.html", src])
-  exec("nim doc2 $# -o:$# $#" %
+  exec(findNim() & " doc2 $# -o:$# $#" %
     [c.nimArgs, destPath / "docgen_sample2.html", src])
 
 proc pathPart(d: string): string = splitFile(d).dir.replace('\\', '/')
@@ -288,30 +301,30 @@ proc buildDoc(c: var TConfigData, destPath: string) =
     commands = newSeq[string](len(c.doc) + len(c.srcdoc) + len(c.srcdoc2))
     i = 0
   for d in items(c.doc):
-    commands[i] = "nim rst2html $# --docSeeSrcUrl:$#/$#/$# -o:$# --index:on $#" %
+    commands[i] = findNim() & " rst2html $# --docSeeSrcUrl:$#/$#/$# -o:$# --index:on $#" %
       [c.nimArgs, c.gitRepo, c.gitCommit, d.pathPart,
       destPath / changeFileExt(splitFile(d).name, "html"), d]
     i.inc
   for d in items(c.srcdoc):
-    commands[i] = "nim doc $# --docSeeSrcUrl:$#/$#/$# -o:$# --index:on $#" %
+    commands[i] = findNim() & " doc $# --docSeeSrcUrl:$#/$#/$# -o:$# --index:on $#" %
       [c.nimArgs, c.gitRepo, c.gitCommit, d.pathPart,
       destPath / changeFileExt(splitFile(d).name, "html"), d]
     i.inc
   for d in items(c.srcdoc2):
-    commands[i] = "nim doc2 $# --docSeeSrcUrl:$#/$#/$# -o:$# --index:on $#" %
+    commands[i] = findNim() & " doc2 $# --docSeeSrcUrl:$#/$#/$# -o:$# --index:on $#" %
       [c.nimArgs, c.gitRepo, c.gitCommit, d.pathPart,
       destPath / changeFileExt(splitFile(d).name, "html"), d]
     i.inc
 
   mexec(commands, c.numProcessors)
-  exec("nim buildIndex -o:$1/theindex.html $1" % [destPath])
+  exec(findNim() & " buildIndex -o:$1/theindex.html $1" % [destPath])
 
 proc buildPdfDoc(c: var TConfigData, destPath: string) =
   if os.execShellCmd("pdflatex -version") != 0:
     echo "pdflatex not found; no PDF documentation generated"
   else:
     for d in items(c.pdf):
-      exec("nim rst2tex $# $#" % [c.nimArgs, d])
+      exec(findNim() & " rst2tex $# $#" % [c.nimArgs, d])
       # call LaTeX twice to get cross references right:
       exec("pdflatex " & changeFileExt(d, "tex"))
       exec("pdflatex " & changeFileExt(d, "tex"))
@@ -331,7 +344,7 @@ proc buildAddDoc(c: var TConfigData, destPath: string) =
   # build additional documentation (without the index):
   var commands = newSeq[string](c.webdoc.len)
   for i, doc in pairs(c.webdoc):
-    commands[i] = "nim doc2 $# --docSeeSrcUrl:$#/$# -o:$# $#" %
+    commands[i] = findNim() & " doc2 $# --docSeeSrcUrl:$#/$# -o:$# $#" %
       [c.nimArgs, c.gitRepo, c.gitCommit,
       destPath / changeFileExt(splitFile(doc).name, "html"), doc]
   mexec(commands, c.numProcessors)
@@ -415,7 +428,7 @@ proc buildNewsRss(c: var TConfigData, destPath: string) =
   generateRss(destFilename, parseNewsTitles(srcFilename))
 
 proc buildJS(destPath: string) =
-  exec("nim js -d:release --out:$1 web/nimblepkglist.nim" %
+  exec(findNim() & " js -d:release --out:$1 web/nimblepkglist.nim" %
       [destPath / "nimblepkglist.js"])
 
 proc readSponsors(sponsorsFile: string): seq[Sponsor] =
@@ -443,10 +456,10 @@ proc buildSponsors(c: var TConfigData, sponsorsFile: string, outputDir: string)
     quit("[Error] Cannot write file: " & outFile)
 
 const
-  cmdRst2Html = "nim rst2html --compileonly $1 -o:web/$2.temp web/$2.rst"
+  cmdRst2Html = " rst2html --compileonly $1 -o:web/$2.temp web/$2.rst"
 
 proc buildPage(c: var TConfigData, file, title, rss: string, assetDir = "") =
-  exec(cmdRst2Html % [c.nimArgs, file])
+  exec(findNim() & cmdRst2Html % [c.nimArgs, file])
   var temp = "web" / changeFileExt(file, "temp")
   var content: string
   try: