Skip to content

Commit b04d3fc

Browse files
committed
gh-103053: Run tools test_freeze on buildbot
* No longer skip test_tools.test_freeze on buildbots. * test_freeze.py now logs executed commands and directories, and the current directory. * test_freeze.py no longer uses -C options make to change the directory. Use cwd parameter of subprocess instead.
1 parent aaf297c commit b04d3fc

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

Lib/test/test_tools/test_freeze.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
@support.requires_zlib()
1616
@unittest.skipIf(sys.platform.startswith('win'), 'not supported on Windows')
17-
@support.skip_if_buildbot('not all buildbots have enough space')
1817
# gh-103053: Skip test if Python is built with Profile Guided Optimization
1918
# (PGO), since the test is just too slow in this case.
2019
@unittest.skipIf(support.check_cflags_pgo(),

Tools/freeze/test/freeze.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ class UnsupportedError(Exception):
2727
"""The operation isn't supported."""
2828

2929

30-
def _run_quiet(cmd, cwd=None):
31-
#print(f'# {" ".join(shlex.quote(a) for a in cmd)}')
30+
def _run_quiet(cmd, *, cwd=None):
31+
if cwd:
32+
print('+', 'cd', cwd, flush=True)
33+
print('+', shlex.join(cmd), flush=True)
3234
try:
3335
return subprocess.run(
3436
cmd,
@@ -48,8 +50,8 @@ def _run_quiet(cmd, cwd=None):
4850
raise
4951

5052

51-
def _run_stdout(cmd, cwd=None):
52-
proc = _run_quiet(cmd, cwd)
53+
def _run_stdout(cmd):
54+
proc = _run_quiet(cmd)
5355
return proc.stdout.strip()
5456

5557

@@ -91,13 +93,16 @@ def copy_source_tree(newroot, oldroot):
9193

9294
shutil.copytree(oldroot, newroot, ignore=support.copy_python_src_ignore)
9395
if os.path.exists(os.path.join(newroot, 'Makefile')):
94-
_run_quiet([MAKE, 'clean'], newroot)
96+
_run_quiet([MAKE, 'clean'], cwd=newroot)
9597

9698

9799
##################################
98100
# freezing
99101

100102
def prepare(script=None, outdir=None):
103+
print()
104+
print("cwd:", os.getcwd())
105+
101106
if not outdir:
102107
outdir = OUTDIR
103108
os.makedirs(outdir, exist_ok=True)
@@ -125,7 +130,7 @@ def prepare(script=None, outdir=None):
125130
ensure_opt(cmd, 'cache-file', os.path.join(outdir, 'python-config.cache'))
126131
prefix = os.path.join(outdir, 'python-installation')
127132
ensure_opt(cmd, 'prefix', prefix)
128-
_run_quiet(cmd, builddir)
133+
_run_quiet(cmd, cwd=builddir)
129134

130135
if not MAKE:
131136
raise UnsupportedError('make')
@@ -135,20 +140,21 @@ def prepare(script=None, outdir=None):
135140
# this test is most often run as part of the whole suite with a lot
136141
# of other tests running in parallel, from 1-2 vCPU systems up to
137142
# people's NNN core beasts. Don't attempt to use it all.
138-
parallel = f'-j{cores*2//3}'
143+
jobs = cores * 2 // 3
144+
parallel = f'-j{jobs}'
139145
else:
140146
parallel = '-j2'
141147

142148
# Build python.
143149
print(f'building python {parallel=} in {builddir}...')
144150
if os.path.exists(os.path.join(srcdir, 'Makefile')):
145151
# Out-of-tree builds require a clean srcdir.
146-
_run_quiet([MAKE, '-C', srcdir, 'clean'])
147-
_run_quiet([MAKE, '-C', builddir, parallel])
152+
_run_quiet([MAKE, 'clean'], cwd=srcdir)
153+
_run_quiet([MAKE, parallel], cwd=builddir)
148154

149155
# Install the build.
150156
print(f'installing python into {prefix}...')
151-
_run_quiet([MAKE, '-C', builddir, 'install'])
157+
_run_quiet([MAKE, 'install'], cwd=builddir)
152158
python = os.path.join(prefix, 'bin', 'python3')
153159

154160
return outdir, scriptfile, python
@@ -161,8 +167,8 @@ def freeze(python, scriptfile, outdir):
161167
print(f'freezing {scriptfile}...')
162168
os.makedirs(outdir, exist_ok=True)
163169
# Use -E to ignore PYTHONSAFEPATH
164-
_run_quiet([python, '-E', FREEZE, '-o', outdir, scriptfile], outdir)
165-
_run_quiet([MAKE, '-C', os.path.dirname(scriptfile)])
170+
_run_quiet([python, '-E', FREEZE, '-o', outdir, scriptfile], cwd=outdir)
171+
_run_quiet([MAKE], cwd=os.path.dirname(scriptfile))
166172

167173
name = os.path.basename(scriptfile).rpartition('.')[0]
168174
executable = os.path.join(outdir, name)

0 commit comments

Comments
 (0)