Anonymous avatar Anonymous committed 1f12521

Don't use Program() on some tests that don't need it.

Comments (0)

Files changed (2)

 
 test.subdir('one', 'two', 'three')
 
+test.write('build.py', r"""
+import sys
+contents = open(sys.argv[2], 'r').read()
+file = open(sys.argv[1], 'w')
+file.write(contents)
+file.close()
+""")
+
 test.write(['one', 'SConstruct'], """
-env = Environment()
-env.Program(target = 'foo', source = 'foo.c')
-env.Program(target = 'bar', source = 'bar.c')
-Default('foo')
+B = Builder(name = 'B', action = "python ../build.py %(target)s %(source)s")
+env = Environment(BUILDERS = [B])
+env.B(target = 'foo.out', source = 'foo.in')
+env.B(target = 'bar.out', source = 'bar.in')
+Default('foo.out')
 """)
 
 test.write(['two', 'SConstruct'], """
-env = Environment()
-env.Program(target = 'foo', source = 'foo.c')
-env.Program(target = 'bar', source = 'bar.c')
-Default('foo', 'bar')
+B = Builder(name = 'B', action = "python ../build.py %(target)s %(source)s")
+env = Environment(BUILDERS = [B])
+env.B(target = 'foo.out', source = 'foo.in')
+env.B(target = 'bar.out', source = 'bar.in')
+Default('foo.out', 'bar.out')
 """)
 
 test.write(['three', 'SConstruct'], """
-env = Environment()
-env.Program(target = 'foo', source = 'foo.c')
-env.Program(target = 'bar', source = 'bar.c')
-Default('foo bar')
+B = Builder(name = 'B', action = "python ../build.py %(target)s %(source)s")
+env = Environment(BUILDERS = [B])
+env.B(target = 'foo.out', source = 'foo.in')
+env.B(target = 'bar.out', source = 'bar.in')
+Default('foo.out bar.out')
 """)
 
 for dir in ['one', 'two', 'three']:
 
-    foo_c = os.path.join(dir, 'foo.c')
-    bar_c = os.path.join(dir, 'bar.c')
+    foo_in = os.path.join(dir, 'foo.in')
+    bar_in = os.path.join(dir, 'bar.in')
 
-    test.write(foo_c, """
-int
-main(int argc, char *argv[])
-{
-	argv[argc++] = "--";
-	printf("%s\n");
-	exit (0);
-}
-""" % foo_c)
+    test.write(foo_in, foo_in + "\n");
 
-    test.write(bar_c, """
-int
-main(int argc, char *argv[])
-{
-	argv[argc++] = "--";
-	printf("%s\n");
-	exit (0);
-}
-""" % bar_c)
+    test.write(bar_in, bar_in + "\n");
 
     test.run(chdir = dir)	# no arguments, use the Default
 
-test.run(program = test.workpath('one', 'foo'), stdout = "one/foo.c\n")
+test.fail_test(test.read(test.workpath('one', 'foo.out')) != "one/foo.in\n")
 test.fail_test(os.path.exists(test.workpath('one', 'bar')))
 
-test.run(program = test.workpath('two', 'foo'), stdout = "two/foo.c\n")
-test.run(program = test.workpath('two', 'bar'), stdout = "two/bar.c\n")
+test.fail_test(test.read(test.workpath('two', 'foo.out')) != "two/foo.in\n")
+test.fail_test(test.read(test.workpath('two', 'bar.out')) != "two/bar.in\n")
 
-test.run(program = test.workpath('three', 'foo'), stdout = "three/foo.c\n")
-test.run(program = test.workpath('three', 'bar'), stdout = "three/bar.c\n")
+test.fail_test(test.read(test.workpath('three', 'foo.out')) != "three/foo.in\n")
+test.fail_test(test.read(test.workpath('three', 'bar.out')) != "three/bar.in\n")
 
 test.pass_test()
 
 test.pass_test()	#XXX Short-circuit until this is implemented.
 
-test.write('SConstruct', """
-env = Environment()
-Program(target = 'foo1', source = 'foo1.c')
-Program(target = 'foo2', source = 'foo2.c')
-Program(target = 'foo3', source = 'foo3.c')
+test.write('build.py', r"""
+import sys
+contents = open(sys.argv[2], 'r').read()
+file = open(sys.argv[1], 'w')
+file.write(contents)
+file.close()
 """)
 
-test.write('foo1.c', """
-int
-main(int argc, char *argv[])
-{
-	argv[argc++] = "--";
-	printf("foo1.c\n");
-	exit (0);
-}
+test.write('SConstruct', """
+B = Builder(name = 'B', action = "python ../build.py %(target)s %(source)s")
+env = Environment(BUILDERS = [B])
+env.B(target = 'foo1.out', source = 'foo1.in')
+env.B(target = 'foo2.out', source = 'foo2.in')
+env.B(target = 'foo3.out', source = 'foo3.in')
 """)
 
-test.write('foo2.c', """
-int
-main(int argc, char *argv[])
-{
-	argv[argc++] = "--";
-	printf("foo2.c\n");
-	exit (0);
-}
-""")
+test.write('foo1.in', "foo1.in\n")
 
-test.write('foo3.c', """
-int
-main(int argc, char *argv[])
-{
-	argv[argc++] = "--";
-	printf("foo3.c\n");
-	exit (0);
-}
-""")
+test.write('foo2.in', "foo2.in\n")
 
-test.run(arguments = 'foo1 foo2 foo3')
+test.write('foo3.in', "foo3.in\n")
 
-test.run(program = test.workpath('foo1'), stdout = "foo1.c\n")
-test.run(program = test.workpath('foo2'), stdout = "foo2.c\n")
-test.run(program = test.workpath('foo3'), stdout = "foo3.c\n")
+test.run(arguments = 'foo1.out foo2.out foo3.out')
 
-test.run(arguments = '-c foo1')
+test.fail_test(test.read(test.workpath('foo1.out')) != "foo1.in\n")
+test.fail_test(test.read(test.workpath('foo2.out')) != "foo2.in\n")
+test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n")
 
-test.fail_test(os.path.exists(test.workpath('foo1')))
-test.fail_test(not os.path.exists(test.workpath('foo2')))
-test.fail_test(not os.path.exists(test.workpath('foo3')))
+test.run(arguments = '-c foo1.out')
 
-test.run(arguments = '--clean foo2')
+test.fail_test(os.path.exists(test.workpath('foo1.out')))
+test.fail_test(not os.path.exists(test.workpath('foo2.out')))
+test.fail_test(not os.path.exists(test.workpath('foo3.out')))
 
-test.fail_test(os.path.exists(test.workpath('foo1')))
-test.fail_test(os.path.exists(test.workpath('foo2')))
-test.fail_test(not os.path.exists(test.workpath('foo3')))
+test.run(arguments = '--clean foo2.out')
 
-test.run(arguments = '--remove foo3')
+test.fail_test(os.path.exists(test.workpath('foo1.out')))
+test.fail_test(os.path.exists(test.workpath('foo2.out')))
+test.fail_test(not os.path.exists(test.workpath('foo3.out')))
 
-test.fail_test(os.path.exists(test.workpath('foo1')))
-test.fail_test(os.path.exists(test.workpath('foo2')))
-test.fail_test(os.path.exists(test.workpath('foo3')))
+test.run(arguments = '--remove foo3.out')
 
-test.run(arguments = 'foo1 foo2 foo3')
+test.fail_test(os.path.exists(test.workpath('foo1.out')))
+test.fail_test(os.path.exists(test.workpath('foo2.out')))
+test.fail_test(os.path.exists(test.workpath('foo3.out')))
 
-test.run(program = test.workpath('foo1'), stdout = "foo1.c\n")
-test.run(program = test.workpath('foo2'), stdout = "foo2.c\n")
-test.run(program = test.workpath('foo3'), stdout = "foo3.c\n")
+test.run(arguments = 'foo1.out foo2.out foo3.out')
+
+test.run(program = test.workpath('foo1.out'), stdout = "foo1.in\n")
+test.run(program = test.workpath('foo2.out'), stdout = "foo2.in\n")
+test.run(program = test.workpath('foo3.out'), stdout = "foo3.in\n")
 
 test.run(arguments = '-c .')
 
-test.fail_test(os.path.exists(test.workpath('foo1')))
-test.fail_test(os.path.exists(test.workpath('foo2')))
-test.fail_test(os.path.exists(test.workpath('foo3')))
+test.fail_test(os.path.exists(test.workpath('foo1.out')))
+test.fail_test(os.path.exists(test.workpath('foo2.out')))
+test.fail_test(os.path.exists(test.workpath('foo3.out')))
 
 test.pass_test()
  
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.