-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuildverify.nim
71 lines (59 loc) · 1.72 KB
/
buildverify.nim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Copyright (c) 2017, Josh Filstrup
# Licensed under BSD3(see license.md file for details)
#
# A script used by travis to verify a build, including:
# - Build the code
# - Run examples
# - Run tests
# - Generate docs(and diff them against the installed copy)
import os
import system
var
NIMCC = paramStr(1)
ROOTDIR = getCurrentDir()
proc runCmd(rawCmd: string, redirOutput: bool = true) =
var cmd = rawCmd
if redirOutput:
cmd = cmd & " >> " & ROOTDIR & "/build_log.txt 2>&1"
if execShellCmd(cmd) == 0:
echo("✓ " & cmd)
else:
echo("✗ " & cmd)
quit(QuitFailure)
proc banner(msg : string) =
echo("-------------------------------------")
echo(msg)
echo("-------------------------------------")
proc runNimCC(fname : string) =
runCmd(NIMCC & " c " & fname)
runCmd("which " & NIMCC)
banner("Nim compiler found!")
setCurrentDir("src/maybe")
echo(getCurrentDir())
runNimCC("maybe.nim")
setCurrentDir("../examples/")
runNimCC("example.nim")
setCurrentDir("../tests/")
runNimCC("basic.nim")
banner("Compilation ran successfully!")
setCurrentDir("../examples")
runCmd("./example")
banner("Examples ran successfully!")
setCurrentDir("../tests/")
runCmd("./basic")
banner("Tests ran successfully!")
setCurrentDir("../maybe/")
# Clear out the timestamp lines
#runCmd(NIMCC & " doc maybe.nim")
#runCmd("sed \"/Generated:/d\" maybe.html > maybe_.html", false)
#runCmd("diff maybe_.html ../../docs/index.html")
#banner("Docgen ran successfully!")
#
## Cleanup, mostly useful for local runs
#setCurrentDir("../../")
#runCmd("rm ./src/tests/basic")
#runCmd("rm ./src/examples/example")
#runCmd("rm ./src/maybe/maybe")
#runCmd("rm ./src/maybe/maybe.html")
#runCmd("rm ./src/maybe/maybe_.html")
#banner("Cleanup ran successfully!")