1717import shlex
1818
1919from subprocess import check_output , CalledProcessError , run
20+ from typing import Optional
2021from util import SRC_PATH
2122
2223logger = logging .getLogger (__name__ )
@@ -66,7 +67,7 @@ def run_command(cmd, check_return_code=False, cwd=None):
6667 raise RuntimeError (f"{ cmd } failed" )
6768
6869
69- def test_extension (whl_dir : Path ):
70+ def test_extension (whl_dir : Optional [ Path ] = None ):
7071 for pkg_name , ext_path in ALL_TESTS :
7172 ext_name = ext_path .split ('/' )[- 1 ]
7273 logger .info (f'installing extension: { ext_name } ' )
@@ -88,25 +89,26 @@ def test_extension(whl_dir: Path):
8889 cmd = ['azdev' , 'extension' , 'remove' , ext_name ]
8990 run_command (cmd , check_return_code = True )
9091
91- logger .info (f'installing extension wheel: { ext_name } ' )
92- wheel_path = next (whl_dir .glob (f"{ ext_name } *.whl" ))
93- subprocess .run (
94- f"az extension add -y -s { wheel_path } " .split (" " ),
95- check = True ,
96- )
97- subprocess .run (
98- f"az { ext_name } --help" .split (" " ),
99- check = True ,
100- stdout = subprocess .DEVNULL ,
101- stderr = subprocess .DEVNULL ,
102- )
103- subprocess .run (
104- f"az extension remove -n { ext_name } " .split (" " ),
105- check = True ,
106- )
107-
108-
109- def test_source_wheels (whl_dir : Path ):
92+ if whl_dir is not None :
93+ logger .info (f'installing extension wheel: { ext_name } ' )
94+ wheel_path = next (whl_dir .glob (f"{ ext_name } *.whl" ))
95+ subprocess .run (
96+ f"az extension add -y -s { wheel_path } " .split (" " ),
97+ check = True ,
98+ )
99+ subprocess .run (
100+ f"az { ext_name } --help" .split (" " ),
101+ check = True ,
102+ stdout = subprocess .DEVNULL ,
103+ stderr = subprocess .DEVNULL ,
104+ )
105+ subprocess .run (
106+ f"az extension remove -n { ext_name } " .split (" " ),
107+ check = True ,
108+ )
109+
110+
111+ def test_source_wheels (whl_dir : Optional [Path ] = None ):
110112 # Test we can build all sources into wheels and that metadata from the wheel is valid
111113 built_whl_dir = tempfile .mkdtemp ()
112114 source_extensions = [os .path .join (SRC_PATH , n ) for n in os .listdir (SRC_PATH )
0 commit comments