added 'koch testinstall' command; more installer related bugfixes
This commit is contained in:
parent
0ea65a824d
commit
76c8d6164b
7 changed files with 78 additions and 17 deletions
40
koch.nim
40
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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue