summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Blevins <wblevins001@gmail.com>2016-09-21 20:47:35 -0400
committerWilliam Blevins <wblevins001@gmail.com>2016-09-21 20:47:35 -0400
commitf90425f82c480eb4289520c41ae9eba90b8c3c48 (patch)
treed5758880a84cd3c2e72e409c6d62783d01edec0e
parent2fe52474b77f27b53da92d950eee0a7d444bc3e5 (diff)
downloadscons-f90425f82c480eb4289520c41ae9eba90b8c3c48.tar.gz
Fixed the YACC tests.
-rw-r--r--test/YACC/YACC-fixture/.exclude_tests1
-rw-r--r--test/YACC/YACC-fixture/aaa.y2
-rw-r--r--test/YACC/YACC-fixture/bbb.yacc2
-rw-r--r--test/YACC/YACC-fixture/ccc.yy2
-rw-r--r--test/YACC/YACC-fixture/ddd.ym2
-rw-r--r--test/YACC/YACC-fixture/myyacc.py13
-rw-r--r--test/YACC/YACC.py25
-rw-r--r--test/YACC/YACCCOM-fixture/.exclude_tests1
-rw-r--r--test/YACC/YACCCOM-fixture/myyacc.py7
-rw-r--r--test/YACC/YACCCOM.py16
-rw-r--r--test/YACC/YACCCOMSTR.py16
-rw-r--r--test/YACC/YACCFLAGS-fixture/.exclude_tests1
-rw-r--r--test/YACC/YACCFLAGS-fixture/myyacc.py17
-rw-r--r--test/YACC/YACCFLAGS.py22
-rw-r--r--test/YACC/YACCHFILESUFFIX.py4
-rw-r--r--test/YACC/YACCHXXFILESUFFIX.py4
-rw-r--r--test/YACC/YACCVCGFILESUFFIX.py4
-rw-r--r--test/YACC/shared-fixture/.exclude_tests1
-rw-r--r--test/YACC/shared-fixture/aaa.y2
-rw-r--r--test/YACC/shared-fixture/bbb.yacc2
20 files changed, 65 insertions, 79 deletions
diff --git a/test/YACC/YACC-fixture/.exclude_tests b/test/YACC/YACC-fixture/.exclude_tests
new file mode 100644
index 00000000..f12c4d0a
--- /dev/null
+++ b/test/YACC/YACC-fixture/.exclude_tests
@@ -0,0 +1 @@
+myyacc.py
diff --git a/test/YACC/YACC-fixture/aaa.y b/test/YACC/YACC-fixture/aaa.y
new file mode 100644
index 00000000..dab6e401
--- /dev/null
+++ b/test/YACC/YACC-fixture/aaa.y
@@ -0,0 +1,2 @@
+aaa.y
+YACC
diff --git a/test/YACC/YACC-fixture/bbb.yacc b/test/YACC/YACC-fixture/bbb.yacc
new file mode 100644
index 00000000..ca4ab73c
--- /dev/null
+++ b/test/YACC/YACC-fixture/bbb.yacc
@@ -0,0 +1,2 @@
+bbb.yacc
+YACC
diff --git a/test/YACC/YACC-fixture/ccc.yy b/test/YACC/YACC-fixture/ccc.yy
new file mode 100644
index 00000000..c7ec5520
--- /dev/null
+++ b/test/YACC/YACC-fixture/ccc.yy
@@ -0,0 +1,2 @@
+ccc.yacc
+YACC
diff --git a/test/YACC/YACC-fixture/ddd.ym b/test/YACC/YACC-fixture/ddd.ym
new file mode 100644
index 00000000..c8962be9
--- /dev/null
+++ b/test/YACC/YACC-fixture/ddd.ym
@@ -0,0 +1,2 @@
+ddd.yacc
+YACC
diff --git a/test/YACC/YACC-fixture/myyacc.py b/test/YACC/YACC-fixture/myyacc.py
new file mode 100644
index 00000000..c2e1abf1
--- /dev/null
+++ b/test/YACC/YACC-fixture/myyacc.py
@@ -0,0 +1,13 @@
+import getopt
+import sys
+cmd_opts, args = getopt.getopt(sys.argv[1:], 'o:', [])
+output = None
+opt_string = ''
+for opt, arg in cmd_opts:
+ if opt == '-o': output = open(arg, 'wb')
+ else: opt_string = opt_string + ' ' + opt
+for a in args:
+ contents = open(a, 'rb').read()
+ output.write(contents.replace(b'YACC', b'myyacc.py'))
+output.close()
+sys.exit(0)
diff --git a/test/YACC/YACC.py b/test/YACC/YACC.py
index 59067f31..3fc1f7c2 100644
--- a/test/YACC/YACC.py
+++ b/test/YACC/YACC.py
@@ -41,25 +41,7 @@ else:
test = TestSCons.TestSCons()
-
-
-test.write('myyacc.py', """
-import getopt
-import sys
-cmd_opts, args = getopt.getopt(sys.argv[1:], 'o:', [])
-output = None
-opt_string = ''
-for opt, arg in cmd_opts:
- if opt == '-o': output = open(arg, 'wb')
- else: opt_string = opt_string + ' ' + opt
-for a in args:
- contents = open(a, 'rb').read()
- output.write(contents.replace('YACC', 'myyacc.py'))
-output.close()
-sys.exit(0)
-""")
-
-
+test.dir_fixture('YACC-fixture')
test.write('SConstruct', """
env = Environment(YACC = r'%(_python_)s myyacc.py', tools=['default', 'yacc'])
@@ -69,11 +51,6 @@ env.CXXFile(target = 'ccc', source = 'ccc.yy')
env.CFile(target = 'ddd', source = 'ddd.ym')
""" % locals())
-test.write('aaa.y', "aaa.y\nYACC\n")
-test.write('bbb.yacc', "bbb.yacc\nYACC\n")
-test.write('ccc.yy', "ccc.yacc\nYACC\n")
-test.write('ddd.ym', "ddd.yacc\nYACC\n")
-
test.run(arguments = '.', stderr = None)
test.must_match('aaa.c', "aaa.y\nmyyacc.py\n")
diff --git a/test/YACC/YACCCOM-fixture/.exclude_tests b/test/YACC/YACCCOM-fixture/.exclude_tests
new file mode 100644
index 00000000..f12c4d0a
--- /dev/null
+++ b/test/YACC/YACCCOM-fixture/.exclude_tests
@@ -0,0 +1 @@
+myyacc.py
diff --git a/test/YACC/YACCCOM-fixture/myyacc.py b/test/YACC/YACCCOM-fixture/myyacc.py
new file mode 100644
index 00000000..15028007
--- /dev/null
+++ b/test/YACC/YACCCOM-fixture/myyacc.py
@@ -0,0 +1,7 @@
+import sys
+outfile = open(sys.argv[1], 'wb')
+for f in sys.argv[2:]:
+ infile = open(f, 'rb')
+ for l in [l for l in infile.readlines() if l != b'/*yacc*/\n']:
+ outfile.write(l)
+sys.exit(0)
diff --git a/test/YACC/YACCCOM.py b/test/YACC/YACCCOM.py
index 4e43676d..70ffa72b 100644
--- a/test/YACC/YACCCOM.py
+++ b/test/YACC/YACCCOM.py
@@ -34,17 +34,8 @@ _python_ = TestSCons._python_
test = TestSCons.TestSCons()
-
-
-test.write('myyacc.py', """
-import sys
-outfile = open(sys.argv[1], 'wb')
-for f in sys.argv[2:]:
- infile = open(f, 'rb')
- for l in [l for l in infile.readlines() if l != '/*yacc*/\\n']:
- outfile.write(l)
-sys.exit(0)
-""")
+test.dir_fixture('shared-fixture')
+test.dir_fixture('YACCCOM-fixture')
test.write('SConstruct', """
env = Environment(tools=['default', 'yacc'],
@@ -53,9 +44,6 @@ env.CFile(target = 'aaa', source = 'aaa.y')
env.CFile(target = 'bbb', source = 'bbb.yacc')
""" % locals())
-test.write('aaa.y', "aaa.y\n/*yacc*/\n")
-test.write('bbb.yacc', "bbb.yacc\n/*yacc*/\n")
-
test.run(arguments = '.')
test.must_match('aaa.c', "aaa.y\n")
diff --git a/test/YACC/YACCCOMSTR.py b/test/YACC/YACCCOMSTR.py
index eaf3fded..344b7154 100644
--- a/test/YACC/YACCCOMSTR.py
+++ b/test/YACC/YACCCOMSTR.py
@@ -35,17 +35,8 @@ _python_ = TestSCons._python_
test = TestSCons.TestSCons()
-
-
-test.write('myyacc.py', """
-import sys
-outfile = open(sys.argv[1], 'wb')
-for f in sys.argv[2:]:
- infile = open(f, 'rb')
- for l in [l for l in infile.readlines() if l != '/*yacc*/\\n']:
- outfile.write(l)
-sys.exit(0)
-""")
+test.dir_fixture('shared-fixture')
+test.dir_fixture('YACCCOM-fixture')
test.write('SConstruct', """
env = Environment(tools=['default', 'yacc'],
@@ -55,9 +46,6 @@ env.CFile(target = 'aaa', source = 'aaa.y')
env.CFile(target = 'bbb', source = 'bbb.yacc')
""" % locals())
-test.write('aaa.y', "aaa.y\n/*yacc*/\n")
-test.write('bbb.yacc', "bbb.yacc\n/*yacc*/\n")
-
test.run(stdout = test.wrap_stdout("""\
Yaccing aaa.c from aaa.y
Yaccing bbb.c from bbb.yacc
diff --git a/test/YACC/YACCFLAGS-fixture/.exclude_tests b/test/YACC/YACCFLAGS-fixture/.exclude_tests
new file mode 100644
index 00000000..f12c4d0a
--- /dev/null
+++ b/test/YACC/YACCFLAGS-fixture/.exclude_tests
@@ -0,0 +1 @@
+myyacc.py
diff --git a/test/YACC/YACCFLAGS-fixture/myyacc.py b/test/YACC/YACCFLAGS-fixture/myyacc.py
new file mode 100644
index 00000000..ffd90318
--- /dev/null
+++ b/test/YACC/YACCFLAGS-fixture/myyacc.py
@@ -0,0 +1,17 @@
+import getopt
+import sys
+cmd_opts, args = getopt.getopt(sys.argv[1:], 'o:I:x', [])
+output = None
+opt_string = ''
+i_arguments = ''
+for opt, arg in cmd_opts:
+ if opt == '-o': output = open(arg, 'wb')
+ elif opt == '-I': i_arguments = i_arguments + ' ' + arg
+ else: opt_string = opt_string + ' ' + opt
+for a in args:
+ contents = open(a, 'rb').read()
+ contents = contents.replace(b'YACCFLAGS', opt_string.encode())
+ contents = contents.replace(b'I_ARGS', i_arguments.encode())
+ output.write(contents)
+output.close()
+sys.exit(0)
diff --git a/test/YACC/YACCFLAGS.py b/test/YACC/YACCFLAGS.py
index f0b698bf..b3f86fe1 100644
--- a/test/YACC/YACCFLAGS.py
+++ b/test/YACC/YACCFLAGS.py
@@ -43,27 +43,7 @@ test = TestSCons.TestSCons()
test.subdir('in')
-
-
-test.write('myyacc.py', """
-import getopt
-import sys
-cmd_opts, args = getopt.getopt(sys.argv[1:], 'o:I:x', [])
-output = None
-opt_string = ''
-i_arguments = ''
-for opt, arg in cmd_opts:
- if opt == '-o': output = open(arg, 'wb')
- elif opt == '-I': i_arguments = i_arguments + ' ' + arg
- else: opt_string = opt_string + ' ' + opt
-for a in args:
- contents = open(a, 'rb').read()
- contents = contents.replace('YACCFLAGS', opt_string)
- contents = contents.replace('I_ARGS', i_arguments)
- output.write(contents)
-output.close()
-sys.exit(0)
-""")
+test.dir_fixture('YACCFLAGS-fixture')
test.write('SConstruct', """
env = Environment(YACC = r'%(_python_)s myyacc.py',
diff --git a/test/YACC/YACCHFILESUFFIX.py b/test/YACC/YACCHFILESUFFIX.py
index 8801aea7..f2054733 100644
--- a/test/YACC/YACCHFILESUFFIX.py
+++ b/test/YACC/YACCHFILESUFFIX.py
@@ -47,11 +47,11 @@ for o, a in opts:
outfile = open(a, 'wb')
for f in args:
infile = open(f, 'rb')
- for l in [l for l in infile.readlines() if l != '/*yacc*/\\n']:
+ for l in [l for l in infile.readlines() if l != b'/*yacc*/\\n']:
outfile.write(l)
outfile.close()
base, ext = os.path.splitext(args[0])
-open(base+'.hsuffix', 'wb').write(" ".join(sys.argv)+'\\n')
+open(base+'.hsuffix', 'wb').write((" ".join(sys.argv)+'\\n').encode())
sys.exit(0)
""")
diff --git a/test/YACC/YACCHXXFILESUFFIX.py b/test/YACC/YACCHXXFILESUFFIX.py
index 6664356e..64181894 100644
--- a/test/YACC/YACCHXXFILESUFFIX.py
+++ b/test/YACC/YACCHXXFILESUFFIX.py
@@ -47,11 +47,11 @@ for o, a in opts:
outfile = open(a, 'wb')
for f in args:
infile = open(f, 'rb')
- for l in [l for l in infile.readlines() if l != '/*yacc*/\\n']:
+ for l in [l for l in infile.readlines() if l != b'/*yacc*/\\n']:
outfile.write(l)
outfile.close()
base, ext = os.path.splitext(args[0])
-open(base+'.hxxsuffix', 'wb').write(" ".join(sys.argv)+'\\n')
+open(base+'.hxxsuffix', 'wb').write((" ".join(sys.argv)+'\\n').encode())
sys.exit(0)
""")
diff --git a/test/YACC/YACCVCGFILESUFFIX.py b/test/YACC/YACCVCGFILESUFFIX.py
index 0327d8a2..5306076b 100644
--- a/test/YACC/YACCVCGFILESUFFIX.py
+++ b/test/YACC/YACCVCGFILESUFFIX.py
@@ -49,12 +49,12 @@ for o, a in opts:
outfile = open(a, 'wb')
for f in args:
infile = open(f, 'rb')
- for l in [l for l in infile.readlines() if l != '/*yacc*/\\n']:
+ for l in [l for l in infile.readlines() if l != b'/*yacc*/\\n']:
outfile.write(l)
outfile.close()
if vcg:
base, ext = os.path.splitext(args[0])
- open(base+'.vcgsuffix', 'wb').write(" ".join(sys.argv)+'\\n')
+ open(base+'.vcgsuffix', 'wb').write((" ".join(sys.argv)+'\\n').encode())
sys.exit(0)
""")
diff --git a/test/YACC/shared-fixture/.exclude_tests b/test/YACC/shared-fixture/.exclude_tests
new file mode 100644
index 00000000..f12c4d0a
--- /dev/null
+++ b/test/YACC/shared-fixture/.exclude_tests
@@ -0,0 +1 @@
+myyacc.py
diff --git a/test/YACC/shared-fixture/aaa.y b/test/YACC/shared-fixture/aaa.y
new file mode 100644
index 00000000..f7f4cc79
--- /dev/null
+++ b/test/YACC/shared-fixture/aaa.y
@@ -0,0 +1,2 @@
+aaa.y
+/*yacc*/
diff --git a/test/YACC/shared-fixture/bbb.yacc b/test/YACC/shared-fixture/bbb.yacc
new file mode 100644
index 00000000..b3c856fd
--- /dev/null
+++ b/test/YACC/shared-fixture/bbb.yacc
@@ -0,0 +1,2 @@
+bbb.yacc
+/*yacc*/