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 71 72 73 74
|
# Part of the A-A-P recipe executive: Testing of :program
# Copyright (C) 2002-2003 Stichting NLnet Labs
# Permission to copy and use this file is specified in the file COPYING.
# If this file is missing you can find it here: http://www.a-a-p.org/COPYING
import sys, os, stat, shutil, string, glob
def runaap(args):
res = os.system("%s ..%sMain.py %s" % (sys.argv[1], os.sep, args))
if res:
print "Aap exited with error value %d" % res
return res
os.chdir("rectest")
# Create three recipes to test whether the rule scope is handled correctly.
rec1 = "rectest1.aap"
prog = "foo"
src1 = "foo.c"
src2 = "bar.c"
out = "rectest.aap.out"
def cleanup():
for n in [ rec1, prog, src1, src2, out ]:
try:
os.remove(n)
except:
pass
try:
for dir in glob.glob('build-*'):
shutil.rmtree(dir)
except:
pass
cleanup()
f = open(rec1, "w")
f.write("""
:program %s : %s $BDIR/bar$OBJSUF
""" % (prog, src1))
f.close()
f = open(src1, "w")
f.write("""
#include <stdio.h>
extern char *msg;
int main() { printf(msg); return 0;}
""")
f.close()
f = open(src2, "w")
f.write("""
char *msg = "It works!\\n";
""")
f.close()
# The first time running should result in two files being copied.
res = runaap("-f %s" % rec1)
res = res + os.system(".%s%s > %s" % (os.sep, prog, out))
f = open(out)
actual = f.read()
f.close()
failed = (actual != "It works!\n")
cleanup()
sys.exit(failed)
# vim: set sw=4 et sts=4 tw=79 fo+=l:
|