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:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
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.
25 __revision__
= "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
32 _python_
= TestSCons
._python
_
34 test
= TestSCons
.TestSCons()
38 test
.write('mygs.py', r
"""
41 outfile = open(sys.argv[1], 'w')
42 infile = open(sys.argv[2], 'r')
43 for l in infile.readlines():
49 test
.write('SConstruct', """
50 env = Environment(GS = r'%(_python_)s mygs.py',
51 GSCOM = r'$GS $TARGET $SOURCE',
53 env.PDF(target = 'test1.pdf', source = 'test1.ps')
54 env.Gs(target = 'test2.pdf', source = 'test1.ps')
57 test
.write('test1.ps', r
"""This is a .ps test.
61 test
.run(arguments
= '.', stderr
= None)
63 test
.must_match('test1.pdf', "This is a .ps test.\n", mode
='r')
64 test
.must_match('test2.pdf', "This is a .ps test.\n", mode
='r')
68 if sys
.platform
== 'win32':
69 gs_executable
= 'gswin32c'
70 elif sys
.platform
== 'os2':
71 gs_executable
= 'gsos2'
74 gs
= test
.where_is(gs_executable
)
77 test
.write("wrapper.py", """\
80 cmd = " ".join(sys.argv[1:])
81 open('%s', 'a').write("%%s\\n" %% cmd)
82 subprocess.run(cmd, shell=True)
83 """ % test
.workpath('wrapper.out').replace('\\', '\\\\'))
85 test
.write('SConstruct', """\
87 foo = Environment(ENV = { 'PATH' : os.environ['PATH'] })
88 gs = foo.Dictionary('GS')
89 bar = Environment(ENV = { 'PATH' : os.environ['PATH'] },
90 GS = r'%(_python_)s wrapper.py ' + gs)
91 foo.PDF(target = 'foo.pdf', source = 'foo.ps')
92 bar.PDF(target = 'bar.pdf', source = 'bar.ps')
97 100 100 moveto /Times-Roman findfont 24 scalefont (Hello, world!) show showpage
100 test
.write('foo.ps', input)
102 test
.write('bar.ps', input)
104 test
.run(arguments
= 'foo.pdf', stderr
= None)
106 test
.fail_test(os
.path
.exists(test
.workpath('wrapper.out')))
108 test
.fail_test(not os
.path
.exists(test
.workpath('foo.pdf')))
110 test
.run(arguments
= 'bar.pdf', stderr
= None)
112 test
.must_match('wrapper.out', "%s -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=bar.pdf bar.ps\n" % gs_executable
, mode
='r')
114 test
.fail_test(not os
.path
.exists(test
.workpath('bar.pdf')))
120 # indent-tabs-mode:nil
122 # vim: set expandtab tabstop=4 shiftwidth=4: