Skip to content

Commit 0bf264e

Browse files
committed
minimize tool initialization in tests
1 parent 1535671 commit 0bf264e

File tree

9 files changed

+850
-852
lines changed

9 files changed

+850
-852
lines changed

test/CPPPATH/Dir.py

Lines changed: 85 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,85 @@
1-
#!/usr/bin/env python
2-
#
3-
# __COPYRIGHT__
4-
#
5-
# Permission is hereby granted, free of charge, to any person obtaining
6-
# a copy of this software and associated documentation files (the
7-
# "Software"), to deal in the Software without restriction, including
8-
# without limitation the rights to use, copy, modify, merge, publish,
9-
# distribute, sublicense, and/or sell copies of the Software, and to
10-
# permit persons to whom the Software is furnished to do so, subject to
11-
# the following conditions:
12-
#
13-
# The above copyright notice and this permission notice shall be included
14-
# in all copies or substantial portions of the Software.
15-
#
16-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17-
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18-
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23-
#
24-
25-
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26-
27-
"""
28-
Verify that CPPPATH values with Dir nodes work correctly.
29-
"""
30-
31-
import TestSCons
32-
33-
_exe = TestSCons._exe
34-
35-
test = TestSCons.TestSCons()
36-
37-
test.subdir('inc1', 'inc2', 'inc3', ['inc3', 'subdir'])
38-
39-
test.write('SConstruct', """
40-
env = Environment(CPPPATH = [Dir('inc1'), '$INC2', '$INC3/subdir'],
41-
INC2 = Dir('inc2'),
42-
INC3 = Dir('inc3'))
43-
env.Program('prog.c')
44-
""")
45-
46-
test.write('prog.c', """\
47-
#include <stdio.h>
48-
#include <stdlib.h>
49-
50-
#include "one.h"
51-
#include "two.h"
52-
#include "three.h"
53-
int
54-
main(int argc, char *argv[])
55-
{
56-
printf("%s\\n", ONE);
57-
printf("%s\\n", TWO);
58-
printf("%s\\n", THREE);
59-
return (0);
60-
}
61-
""")
62-
63-
test.write(['inc1', 'one.h'], """\
64-
#define ONE "1"
65-
""")
66-
67-
test.write(['inc2', 'two.h'], """\
68-
#define TWO "2"
69-
""")
70-
71-
test.write(['inc3', 'subdir', 'three.h'], """\
72-
#define THREE "3"
73-
""")
74-
75-
test.run(arguments = '.')
76-
77-
test.run(program = test.workpath('prog' + _exe), stdout = "1\n2\n3\n")
78-
79-
test.pass_test()
80-
81-
# Local Variables:
82-
# tab-width:4
83-
# indent-tabs-mode:nil
84-
# End:
85-
# vim: set expandtab tabstop=4 shiftwidth=4:
1+
#!/usr/bin/env python
2+
#
3+
# MIT License
4+
#
5+
# Copyright The SCons Foundation
6+
#
7+
# Permission is hereby granted, free of charge, to any person obtaining
8+
# a copy of this software and associated documentation files (the
9+
# "Software"), to deal in the Software without restriction, including
10+
# without limitation the rights to use, copy, modify, merge, publish,
11+
# distribute, sublicense, and/or sell copies of the Software, and to
12+
# permit persons to whom the Software is furnished to do so, subject to
13+
# the following conditions:
14+
#
15+
# The above copyright notice and this permission notice shall be included
16+
# in all copies or substantial portions of the Software.
17+
#
18+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19+
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
25+
26+
"""
27+
Verify that CPPPATH values with Dir nodes work correctly.
28+
"""
29+
30+
import TestSCons
31+
32+
_exe = TestSCons._exe
33+
34+
test = TestSCons.TestSCons()
35+
36+
test.subdir('inc1', 'inc2', 'inc3', ['inc3', 'subdir'])
37+
38+
test.write('SConstruct', """
39+
DefaultEnvironment(tools=[])
40+
env = Environment(CPPPATH = [Dir('inc1'), '$INC2', '$INC3/subdir'],
41+
INC2 = Dir('inc2'),
42+
INC3 = Dir('inc3'))
43+
env.Program('prog.c')
44+
""")
45+
46+
test.write('prog.c', """\
47+
#include <stdio.h>
48+
#include <stdlib.h>
49+
50+
#include "one.h"
51+
#include "two.h"
52+
#include "three.h"
53+
int
54+
main(int argc, char *argv[])
55+
{
56+
printf("%s\\n", ONE);
57+
printf("%s\\n", TWO);
58+
printf("%s\\n", THREE);
59+
return (0);
60+
}
61+
""")
62+
63+
test.write(['inc1', 'one.h'], """\
64+
#define ONE "1"
65+
""")
66+
67+
test.write(['inc2', 'two.h'], """\
68+
#define TWO "2"
69+
""")
70+
71+
test.write(['inc3', 'subdir', 'three.h'], """\
72+
#define THREE "3"
73+
""")
74+
75+
test.run(arguments = '.')
76+
77+
test.run(program = test.workpath('prog' + _exe), stdout = "1\n2\n3\n")
78+
79+
test.pass_test()
80+
81+
# Local Variables:
82+
# tab-width:4
83+
# indent-tabs-mode:nil
84+
# End:
85+
# vim: set expandtab tabstop=4 shiftwidth=4:

test/CPPPATH/absolute-path.py

Lines changed: 100 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,100 @@
1-
#!/usr/bin/env python
2-
#
3-
# __COPYRIGHT__
4-
#
5-
# Permission is hereby granted, free of charge, to any person obtaining
6-
# a copy of this software and associated documentation files (the
7-
# "Software"), to deal in the Software without restriction, including
8-
# without limitation the rights to use, copy, modify, merge, publish,
9-
# distribute, sublicense, and/or sell copies of the Software, and to
10-
# permit persons to whom the Software is furnished to do so, subject to
11-
# the following conditions:
12-
#
13-
# The above copyright notice and this permission notice shall be included
14-
# in all copies or substantial portions of the Software.
15-
#
16-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17-
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18-
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23-
#
24-
25-
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26-
27-
"""
28-
Verify the ability to #include a file with an absolute path name. (Which
29-
is not strictly a test of using $CPPPATH, but it's in the ball park...)
30-
"""
31-
32-
import os
33-
34-
import TestSCons
35-
36-
test = TestSCons.TestSCons()
37-
38-
test.subdir('include', 'work')
39-
40-
inc1_h = test.workpath('include', 'inc1.h')
41-
inc2_h = test.workpath('include', 'inc2.h')
42-
does_not_exist_h = test.workpath('include', 'does_not_exist.h')
43-
44-
# Verify that including an absolute path still works even if they
45-
# double the separators in the input file. This can happen especially
46-
# on Windows if they use \\ to represent an escaped backslash.
47-
inc2_h = inc2_h.replace(os.sep, os.sep+os.sep)
48-
49-
test.write(['work', 'SConstruct'], """\
50-
Program('prog.c')
51-
""")
52-
53-
test.write(['work', 'prog.c'], """\
54-
#include <stdio.h>
55-
#include "%(inc1_h)s"
56-
#include "%(inc2_h)s"
57-
#if 0
58-
#include "%(does_not_exist_h)s"
59-
#endif
60-
61-
int
62-
main(int argc, char *argv[])
63-
{
64-
argv[argc++] = "--";
65-
printf("%%s\\n", STRING1);
66-
printf("%%s\\n", STRING2);
67-
return 0;
68-
}
69-
""" % locals())
70-
71-
test.write(['include', 'inc1.h'], """\
72-
#define STRING1 "include/inc1.h A\\n"
73-
""")
74-
75-
test.write(['include', 'inc2.h'], """\
76-
#define STRING2 "include/inc2.h A\\n"
77-
""")
78-
79-
test.run(chdir = 'work', arguments = '.')
80-
81-
test.up_to_date(chdir = 'work', arguments = '.')
82-
83-
test.write(['include', 'inc1.h'], """\
84-
#define STRING1 "include/inc1.h B\\n"
85-
""")
86-
87-
test.not_up_to_date(chdir = 'work', arguments = '.')
88-
89-
test.write(['include', 'inc2.h'], """\
90-
#define STRING2 "include/inc2.h B\\n"
91-
""")
92-
93-
test.not_up_to_date(chdir = 'work', arguments = '.')
94-
95-
test.pass_test()
96-
97-
# Local Variables:
98-
# tab-width:4
99-
# indent-tabs-mode:nil
100-
# End:
101-
# vim: set expandtab tabstop=4 shiftwidth=4:
1+
#!/usr/bin/env python
2+
#
3+
# MIT License
4+
#
5+
# Copyright The SCons Foundation
6+
#
7+
# Permission is hereby granted, free of charge, to any person obtaining
8+
# a copy of this software and associated documentation files (the
9+
# "Software"), to deal in the Software without restriction, including
10+
# without limitation the rights to use, copy, modify, merge, publish,
11+
# distribute, sublicense, and/or sell copies of the Software, and to
12+
# permit persons to whom the Software is furnished to do so, subject to
13+
# the following conditions:
14+
#
15+
# The above copyright notice and this permission notice shall be included
16+
# in all copies or substantial portions of the Software.
17+
#
18+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19+
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
25+
26+
"""
27+
Verify the ability to #include a file with an absolute path name. (Which
28+
is not strictly a test of using $CPPPATH, but it's in the ball park...)
29+
"""
30+
31+
import os
32+
33+
import TestSCons
34+
35+
test = TestSCons.TestSCons()
36+
37+
test.subdir('include', 'work')
38+
39+
inc1_h = test.workpath('include', 'inc1.h')
40+
inc2_h = test.workpath('include', 'inc2.h')
41+
does_not_exist_h = test.workpath('include', 'does_not_exist.h')
42+
43+
# Verify that including an absolute path still works even if they
44+
# double the separators in the input file. This can happen especially
45+
# on Windows if they use \\ to represent an escaped backslash.
46+
inc2_h = inc2_h.replace(os.sep, os.sep+os.sep)
47+
48+
test.write(['work', 'SConstruct'], """\
49+
Program('prog.c')
50+
""")
51+
52+
test.write(['work', 'prog.c'], """\
53+
#include <stdio.h>
54+
#include "%(inc1_h)s"
55+
#include "%(inc2_h)s"
56+
#if 0
57+
#include "%(does_not_exist_h)s"
58+
#endif
59+
60+
int
61+
main(int argc, char *argv[])
62+
{
63+
argv[argc++] = "--";
64+
printf("%%s\\n", STRING1);
65+
printf("%%s\\n", STRING2);
66+
return 0;
67+
}
68+
""" % locals())
69+
70+
test.write(['include', 'inc1.h'], """\
71+
#define STRING1 "include/inc1.h A\\n"
72+
""")
73+
74+
test.write(['include', 'inc2.h'], """\
75+
#define STRING2 "include/inc2.h A\\n"
76+
""")
77+
78+
test.run(chdir = 'work', arguments = '.')
79+
80+
test.up_to_date(chdir = 'work', arguments = '.')
81+
82+
test.write(['include', 'inc1.h'], """\
83+
#define STRING1 "include/inc1.h B\\n"
84+
""")
85+
86+
test.not_up_to_date(chdir = 'work', arguments = '.')
87+
88+
test.write(['include', 'inc2.h'], """\
89+
#define STRING2 "include/inc2.h B\\n"
90+
""")
91+
92+
test.not_up_to_date(chdir = 'work', arguments = '.')
93+
94+
test.pass_test()
95+
96+
# Local Variables:
97+
# tab-width:4
98+
# indent-tabs-mode:nil
99+
# End:
100+
# vim: set expandtab tabstop=4 shiftwidth=4:

0 commit comments

Comments
 (0)