tests: Add a basic test
This test checks for the version.h file and then compiles it with and without debugging enabled. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
101648dc0a
commit
f75ba5a2b8
|
@ -1,6 +1,8 @@
|
||||||
*.o
|
*.o
|
||||||
*.swp
|
*.swp
|
||||||
|
*.swo
|
||||||
*.pyc
|
*.pyc
|
||||||
|
*.test
|
||||||
*.tar.gz
|
*.tar.gz
|
||||||
ocarina.bin
|
ocarina.bin
|
||||||
.sconsign.dblite
|
.sconsign.dblite
|
||||||
|
|
139
Sconstruct
139
Sconstruct
|
@ -1,72 +1,77 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import os, sys
|
|
||||||
import config
|
|
||||||
|
|
||||||
FLAGS = ["-O2"]
|
config = SConscript("config")
|
||||||
if config.DEBUG == True:
|
|
||||||
FLAGS = ["-Wall", "-Werror", "-g", "-DDEBUG"]
|
|
||||||
POSTFIX = "-debug"
|
|
||||||
|
|
||||||
config.env = Environment(CCFLAGS = FLAGS)
|
|
||||||
if ARGUMENTS.get('VERBOSE') != "1":
|
|
||||||
config.env.Append(CXXCOMSTR = "C++ $TARGET")
|
|
||||||
config.env.Append(LINKCOMSTR = "Linking $TARGET")
|
|
||||||
|
|
||||||
# Make sure these directories exist before doing anything
|
|
||||||
if not os.path.exists("bin"):
|
|
||||||
os.mkdir("bin")
|
|
||||||
if not os.path.exists("lib"):
|
|
||||||
os.mkdir("lib")
|
|
||||||
|
|
||||||
config.include = SConscript("include/Sconscript")
|
#import os, sys
|
||||||
config.libsaria = SConscript("libsaria/Sconscript")
|
#import config
|
||||||
|
#
|
||||||
ocarina = SConscript("ocarina/Sconscript")
|
#FLAGS = ["-O2"]
|
||||||
newgui = SConscript("newgui/Sconscript")
|
#if config.DEBUG == True:
|
||||||
Default(ocarina)
|
# FLAGS = ["-Wall", "-Werror", "-g", "-DDEBUG"]
|
||||||
|
# POSTFIX = "-debug"
|
||||||
# Install bin/ and lib/
|
#
|
||||||
def install_dirs(dirs):
|
#config.env = Environment(CCFLAGS = FLAGS)
|
||||||
res = []
|
#if ARGUMENTS.get('VERBOSE') != "1":
|
||||||
for dir in dirs:
|
# config.env.Append(CXXCOMSTR = "C++ $TARGET")
|
||||||
target = os.path.join(config.PREFIX, dir)
|
# config.env.Append(LINKCOMSTR = "Linking $TARGET")
|
||||||
for file in os.listdir(dir):
|
#
|
||||||
source = os.path.join(dir, file)
|
## Make sure these directories exist before doing anything
|
||||||
config.env.Install(target, source)
|
#if not os.path.exists("bin"):
|
||||||
res += [target]
|
# os.mkdir("bin")
|
||||||
return res
|
#if not os.path.exists("lib"):
|
||||||
|
# os.mkdir("lib")
|
||||||
dirs = install_dirs(["bin/", "lib/"])
|
#
|
||||||
config.env.Alias("install", dirs)
|
#config.include = SConscript("include/Sconscript")
|
||||||
config.env.Command("uninstall", None, Delete(FindInstalledFiles()))
|
#config.libsaria = SConscript("libsaria/Sconscript")
|
||||||
|
#
|
||||||
# Clean up the build directory
|
#ocarina = SConscript("ocarina/Sconscript")
|
||||||
clean = Clean(ocarina, ["include/version.h", "bin/", "lib/"])
|
#newgui = SConscript("newgui/Sconscript")
|
||||||
|
#Default(ocarina)
|
||||||
# Create a tarball and a PKGBUILD script
|
#
|
||||||
def prepare_release(target, source, env):
|
## Install bin/ and lib/
|
||||||
import datetime
|
#def install_dirs(dirs):
|
||||||
|
# res = []
|
||||||
ocarina="ocarina-%s" % config.version
|
# for dir in dirs:
|
||||||
os.popen("git archive --prefix=%s/ -o %s.tar.gz HEAD" % (ocarina, ocarina))
|
# target = os.path.join(config.PREFIX, dir)
|
||||||
md5 = os.popen("md5sum %s.tar.gz | awk '{print $1}'" % ocarina).read().strip()
|
# for file in os.listdir(dir):
|
||||||
|
# source = os.path.join(dir, file)
|
||||||
now = datetime.datetime.now()
|
# config.env.Install(target, source)
|
||||||
year = str(now.year)
|
# res += [target]
|
||||||
month = str(now.month)
|
# return res
|
||||||
if (len(month) == 1):
|
#
|
||||||
month = "0" + month
|
#dirs = install_dirs(["bin/", "lib/"])
|
||||||
|
#config.env.Alias("install", dirs)
|
||||||
f = open("PKGBUILD", "w")
|
#config.env.Command("uninstall", None, Delete(FindInstalledFiles()))
|
||||||
for line in open("PKGBUILD.tmpl"):
|
#
|
||||||
if config.BUG == 0:
|
## Clean up the build directory
|
||||||
line = line.replace("pkgver=", "pkgver=%s.%s" % (config.MAJOR, config.MINOR))
|
#clean = Clean(ocarina, ["include/version.h", "bin/", "lib/"])
|
||||||
else:
|
#
|
||||||
line = line.replace("pkgver=", "pkgver=%s.%s.%s" % (config.MAJOR, config.MINOR, config.BUG))
|
## Create a tarball and a PKGBUILD script
|
||||||
line = line.replace("md5sums=", "md5sums=('%s')" % md5)
|
#def prepare_release(target, source, env):
|
||||||
line = line.replace("YEAR", year)
|
# import datetime
|
||||||
line = line.replace("MONTH", month)
|
#
|
||||||
f.write(line)
|
# ocarina="ocarina-%s" % config.version
|
||||||
f.close()
|
# os.popen("git archive --prefix=%s/ -o %s.tar.gz HEAD" % (ocarina, ocarina))
|
||||||
|
# md5 = os.popen("md5sum %s.tar.gz | awk '{print $1}'" % ocarina).read().strip()
|
||||||
config.env.Command("release", None, [prepare_release])
|
#
|
||||||
|
# now = datetime.datetime.now()
|
||||||
|
# year = str(now.year)
|
||||||
|
# month = str(now.month)
|
||||||
|
# if (len(month) == 1):
|
||||||
|
# month = "0" + month
|
||||||
|
#
|
||||||
|
# f = open("PKGBUILD", "w")
|
||||||
|
# for line in open("PKGBUILD.tmpl"):
|
||||||
|
# if config.BUG == 0:
|
||||||
|
# line = line.replace("pkgver=", "pkgver=%s.%s" % (config.MAJOR, config.MINOR))
|
||||||
|
# else:
|
||||||
|
# line = line.replace("pkgver=", "pkgver=%s.%s.%s" % (config.MAJOR, config.MINOR, config.BUG))
|
||||||
|
# line = line.replace("md5sums=", "md5sums=('%s')" % md5)
|
||||||
|
# line = line.replace("YEAR", year)
|
||||||
|
# line = line.replace("MONTH", month)
|
||||||
|
# f.write(line)
|
||||||
|
# f.close()
|
||||||
|
#
|
||||||
|
#config.env.Command("release", None, [prepare_release])
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
import os
|
||||||
|
|
||||||
|
VERSION = 6.0
|
||||||
|
DEBUG = True
|
||||||
|
|
||||||
|
Export("VERSION", "DEBUG")
|
||||||
|
|
||||||
|
|
||||||
|
# Set up default environments
|
||||||
|
def get_env(flags):
|
||||||
|
e = Environment(CCFLAGS = flags)
|
||||||
|
e.Append(CPPPATH = os.path.abspath("include"))
|
||||||
|
e.Append(CXXCOMSTR = "C++ $TARGET")
|
||||||
|
e.Append(LINKCOMSTR = "Linking $TARGET")
|
||||||
|
return e
|
||||||
|
|
||||||
|
release = get_env([ "-O2" ])
|
||||||
|
debug = get_env([ "-Wall", "-Werror", "-g", "-DDEBUG" ])
|
||||||
|
|
||||||
|
env = release
|
||||||
|
if DEBUG == True:
|
||||||
|
env = debug
|
||||||
|
Export("release", "debug", "env")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Import SConscript files
|
||||||
|
include = SConscript("include/Sconscript")
|
||||||
|
tests = SConscript("tests/Sconscript")
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
Import("VERSION", "DEBUG")
|
||||||
|
|
||||||
|
text = [ "#ifndef OCARINA_VERSION_H",
|
||||||
|
"#define OCARINA_VERSION_H",
|
||||||
|
"#endif /* OCARINA_VERSION_H */"
|
||||||
|
]
|
||||||
|
|
||||||
|
f = open("version.h", 'w')
|
||||||
|
for line in text:
|
||||||
|
f.write("%s\n" % line)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
Clean(True, "version.h")
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
Import("release", "debug")
|
||||||
|
|
||||||
|
def make_test(env, name, src):
|
||||||
|
o = env.StaticObject(name, src)
|
||||||
|
p = env.Program("%s.test" % name, o)
|
||||||
|
|
||||||
|
def make_tests(tests):
|
||||||
|
for src in tests:
|
||||||
|
name, extension = src.rsplit(".", 1)
|
||||||
|
make_test(release, name, src)
|
||||||
|
make_test(debug, "%s-debug" % name, src)
|
||||||
|
|
||||||
|
Export("make_tests")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Read SConscript files
|
||||||
|
basic = SConscript("basic/Sconscript")
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
tests = [ "print.cpp" ]
|
||||||
|
|
||||||
|
Import("make_tests")
|
||||||
|
make_tests(tests)
|
|
@ -0,0 +1,10 @@
|
||||||
|
/*
|
||||||
|
* Prints version info to the screen when compiled in debug mode
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <version.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue