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
|
||||
*.swp
|
||||
*.swo
|
||||
*.pyc
|
||||
*.test
|
||||
*.tar.gz
|
||||
ocarina.bin
|
||||
.sconsign.dblite
|
||||
|
|
139
Sconstruct
139
Sconstruct
|
@ -1,72 +1,77 @@
|
|||
#!/usr/bin/python
|
||||
import os, sys
|
||||
import config
|
||||
|
||||
FLAGS = ["-O2"]
|
||||
if config.DEBUG == True:
|
||||
FLAGS = ["-Wall", "-Werror", "-g", "-DDEBUG"]
|
||||
POSTFIX = "-debug"
|
||||
config = SConscript("config")
|
||||
|
||||
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")
|
||||
config.libsaria = SConscript("libsaria/Sconscript")
|
||||
|
||||
ocarina = SConscript("ocarina/Sconscript")
|
||||
newgui = SConscript("newgui/Sconscript")
|
||||
Default(ocarina)
|
||||
|
||||
# Install bin/ and lib/
|
||||
def install_dirs(dirs):
|
||||
res = []
|
||||
for dir in dirs:
|
||||
target = os.path.join(config.PREFIX, dir)
|
||||
for file in os.listdir(dir):
|
||||
source = os.path.join(dir, file)
|
||||
config.env.Install(target, source)
|
||||
res += [target]
|
||||
return res
|
||||
|
||||
dirs = install_dirs(["bin/", "lib/"])
|
||||
config.env.Alias("install", dirs)
|
||||
config.env.Command("uninstall", None, Delete(FindInstalledFiles()))
|
||||
|
||||
# Clean up the build directory
|
||||
clean = Clean(ocarina, ["include/version.h", "bin/", "lib/"])
|
||||
|
||||
# Create a tarball and a PKGBUILD script
|
||||
def prepare_release(target, source, env):
|
||||
import datetime
|
||||
|
||||
ocarina="ocarina-%s" % config.version
|
||||
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()
|
||||
|
||||
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])
|
||||
#import os, sys
|
||||
#import config
|
||||
#
|
||||
#FLAGS = ["-O2"]
|
||||
#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")
|
||||
#config.libsaria = SConscript("libsaria/Sconscript")
|
||||
#
|
||||
#ocarina = SConscript("ocarina/Sconscript")
|
||||
#newgui = SConscript("newgui/Sconscript")
|
||||
#Default(ocarina)
|
||||
#
|
||||
## Install bin/ and lib/
|
||||
#def install_dirs(dirs):
|
||||
# res = []
|
||||
# for dir in dirs:
|
||||
# target = os.path.join(config.PREFIX, dir)
|
||||
# for file in os.listdir(dir):
|
||||
# source = os.path.join(dir, file)
|
||||
# config.env.Install(target, source)
|
||||
# res += [target]
|
||||
# return res
|
||||
#
|
||||
#dirs = install_dirs(["bin/", "lib/"])
|
||||
#config.env.Alias("install", dirs)
|
||||
#config.env.Command("uninstall", None, Delete(FindInstalledFiles()))
|
||||
#
|
||||
## Clean up the build directory
|
||||
#clean = Clean(ocarina, ["include/version.h", "bin/", "lib/"])
|
||||
#
|
||||
## Create a tarball and a PKGBUILD script
|
||||
#def prepare_release(target, source, env):
|
||||
# import datetime
|
||||
#
|
||||
# ocarina="ocarina-%s" % config.version
|
||||
# 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()
|
||||
#
|
||||
# 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