22"""Exercise configured staging recipes and real Automake/libtool installation."""
33import os
44from pathlib import Path
5+ import platform
56import shlex
67import shutil
78import subprocess
@@ -23,6 +24,13 @@ def setUpClass(cls):
2324 cls .build = Path (cls .temporary .name ).resolve ()
2425 cls .environment = {key : value for key , value in os .environ .items ()
2526 if key not in ('MAKEFLAGS' , 'MFLAGS' , 'MAKELEVEL' )}
27+ cls .shell = 'sh'
28+ if platform .system () == 'Windows' :
29+ # Bypass Windows system-shell lookup and use the selected MSYS tools.
30+ shell = shutil .which ('bash' , path = cls .environment .get ('PATH' , '' ))
31+ if not shell :
32+ raise RuntimeError ('bash is unavailable on the selected PATH' )
33+ cls .shell = str (Path (shell ).resolve ())
2634 for tool in ('install' , 'ranlib' ):
2735 boundary = cls .build / f'native-{ tool } -boundary.sh'
2836 boundary .write_text (
@@ -33,12 +41,12 @@ def setUpClass(cls):
3341 f' /*[a-zA-Z]:/*) echo "native { tool } rejects embedded drive: $destination" >&2; exit 1 ;;\n '
3442 'esac\n '
3543 f'printf "%s\\ n" "$destination" >> { tool } -destinations.log\n '
36- f'exec { shlex .quote (Path (shutil .which (tool )). as_posix ( ))} "$@"\n ' )
44+ f'exec { shlex .quote (cls . shell_path ( Path (shutil .which (tool ))))} "$@"\n ' )
3745 boundary .chmod (0o755 )
3846 result = subprocess .run (
39- ['sh' , (SOURCE / 'configure' ). as_posix ( ), '--disable-v3-tls' ,
47+ [cls . shell , cls . shell_path (SOURCE / 'configure' ), '--disable-v3-tls' ,
4048 '--disable-examples' , '--prefix=D:/ci/prefix' ,
41- 'RANLIB=' + (cls .build / 'native-ranlib-boundary.sh' ). as_posix ( )], cwd = cls .build ,
49+ 'RANLIB=' + cls . shell_path (cls .build / 'native-ranlib-boundary.sh' )], cwd = cls .build ,
4250 env = cls .environment , stdout = subprocess .PIPE , stderr = subprocess .STDOUT , text = True )
4351 if result .returncode :
4452 raise RuntimeError (result .stdout )
@@ -53,12 +61,21 @@ def setUpClass(cls):
5361 ['--mode=compile' ] + compiler + ['-c' , 'stagefixture.cpp' , '-o' , 'stagefixture.lo' ],
5462 ['--mode=link' ] + compiler + ['-o' , 'libstagefixture.la' , 'stagefixture.lo' ,
5563 '-rpath' , '/stagefixture' , '-no-undefined' ]]:
56- result = subprocess .run (['sh' , '../libtool' , '--tag=CXX' ] + arguments ,
64+ result = subprocess .run ([cls . shell , '../libtool' , '--tag=CXX' ] + arguments ,
5765 cwd = cls .build / 'src' , env = cls .environment , stdout = subprocess .PIPE ,
5866 stderr = subprocess .STDOUT , text = True )
5967 if result .returncode :
6068 raise RuntimeError (result .stdout )
6169
70+ @classmethod
71+ def shell_path (cls , path ):
72+ if platform .system () != 'Windows' :
73+ return path .as_posix ()
74+ # Autoconf's ':'-separated source search requires MSYS drive notation.
75+ return subprocess .check_output (
76+ [cls .shell , '-c' , 'cygpath -u "$1"' , 'stage-path' , path .as_posix ()],
77+ cwd = cls .build , env = cls .environment , text = True ).strip ()
78+
6279 def setUp (self ):
6380 for name in ('.hygiene-stage' , '.install-stage' , '.shared-check-stage' , 'missing-stage' ):
6481 shutil .rmtree (self .build / name , ignore_errors = True )
@@ -70,7 +87,7 @@ def make(self, target, *variables, shared=False):
7087 # Only the fixture archive replaces the unrelated protocol engines.
7188 command = [MAKE , '--no-print-directory' , target ,
7289 'lib_LTLIBRARIES=libstagefixture.la' , 'noinst_LTLIBRARIES=' , 'noinst_PROGRAMS=' ,
73- 'INSTALL=' + self .installer . as_posix ( )]
90+ 'INSTALL=' + self .shell_path ( self . installer )]
7491 if shared :
7592 # Only check-local's staged-install body is under test here.
7693 text = (SOURCE / 'Makefile.am' ).read_text ()
0 commit comments