]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.2/Lib/distutils/tests/test_build_scripts.py
1 """Tests for distutils.command.build_scripts."""
6 from distutils
.command
.build_scripts
import build_scripts
7 from distutils
.core
import Distribution
10 from distutils
.tests
import support
11 from test
.test_support
import run_unittest
14 class BuildScriptsTestCase(support
.TempdirManager
,
15 support
.LoggingSilencer
,
18 def test_default_settings(self
):
19 cmd
= self
.get_build_scripts_cmd("/foo/bar", [])
20 self
.assertTrue(not cmd
.force
)
21 self
.assertTrue(cmd
.build_dir
is None)
23 cmd
.finalize_options()
25 self
.assertTrue(cmd
.force
)
26 self
.assertEqual(cmd
.build_dir
, "/foo/bar")
29 source
= self
.mkdtemp()
30 target
= self
.mkdtemp()
31 expected
= self
.write_sample_scripts(source
)
33 cmd
= self
.get_build_scripts_cmd(target
,
34 [os
.path
.join(source
, fn
)
36 cmd
.finalize_options()
39 built
= os
.listdir(target
)
41 self
.assertTrue(name
in built
)
43 def get_build_scripts_cmd(self
, target
, scripts
):
46 dist
.scripts
= scripts
47 dist
.command_obj
["build"] = support
.DummyCommand(
50 executable
=sys
.executable
52 return build_scripts(dist
)
54 def write_sample_scripts(self
, dir):
56 expected
.append("script1.py")
57 self
.write_script(dir, "script1.py",
58 ("#! /usr/bin/env python2.3\n"
59 "# bogus script w/ Python sh-bang\n"
61 expected
.append("script2.py")
62 self
.write_script(dir, "script2.py",
63 ("#!/usr/bin/python\n"
64 "# bogus script w/ Python sh-bang\n"
66 expected
.append("shell.sh")
67 self
.write_script(dir, "shell.sh",
69 "# bogus shell script w/ sh-bang\n"
73 def write_script(self
, dir, name
, text
):
74 f
= open(os
.path
.join(dir, name
), "w")
80 def test_version_int(self
):
81 source
= self
.mkdtemp()
82 target
= self
.mkdtemp()
83 expected
= self
.write_sample_scripts(source
)
86 cmd
= self
.get_build_scripts_cmd(target
,
87 [os
.path
.join(source
, fn
)
89 cmd
.finalize_options()
91 # http://bugs.python.org/issue4524
93 # On linux-g++-32 with command line `./configure --enable-ipv6
94 # --with-suffix=3`, python is compiled okay but the build scripts
95 # failed when writing the name of the executable
96 old
= sysconfig
.get_config_vars().get('VERSION')
97 sysconfig
._CONFIG
_VARS
['VERSION'] = 4
102 sysconfig
._CONFIG
_VARS
['VERSION'] = old
104 built
= os
.listdir(target
)
105 for name
in expected
:
106 self
.assertTrue(name
in built
)
109 return unittest
.makeSuite(BuildScriptsTestCase
)
111 if __name__
== "__main__":
112 run_unittest(test_suite())