Skip to content

Commit 832793f

Browse files
committed
Fix extension installation with recent func CLI
1 parent da4f85d commit 832793f

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

azure/functions_worker/testutils.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import os
1616
import queue
1717
import pathlib
18+
import platform
19+
import shutil
1820
import socket
1921
import subprocess
2022
import sys
@@ -40,6 +42,7 @@
4042
FUNCS_PATH = TESTS_ROOT / 'http_functions'
4143
WORKER_PATH = pathlib.Path(__file__).parent.parent.parent
4244
WORKER_CONFIG = WORKER_PATH / '.testconfig'
45+
ON_WINDOWS = platform.system() == 'Windows'
4346

4447
SECRETS_TEMPLATE = """\
4548
{
@@ -133,8 +136,14 @@ def setUpClass(cls):
133136
if not extensions.exists():
134137
if extensions.is_symlink():
135138
extensions.unlink()
136-
137-
extensions.symlink_to(EXTENSIONS_PATH, target_is_directory=True)
139+
elif extensions.exists():
140+
shutil.rmtree(str(extensions))
141+
142+
if ON_WINDOWS:
143+
shutil.copytree(EXTENSIONS_PATH, str(extensions))
144+
else:
145+
extensions.symlink_to(
146+
EXTENSIONS_PATH, target_is_directory=True)
138147
cls.linked_extensions = True
139148
else:
140149
cls.linked_extensions = False
@@ -153,7 +162,10 @@ def tearDownClass(cls):
153162

154163
if cls.linked_extensions:
155164
extensions = TESTS_ROOT / cls.get_script_dir() / 'bin'
156-
extensions.unlink()
165+
if ON_WINDOWS:
166+
shutil.rmtree(extensions)
167+
else:
168+
extensions.unlink()
157169

158170
def _run_test(self, test, *args, **kwargs):
159171
if self.host_stdout is None:

setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ def _install_extensions(self):
148148
if not self.extensions_dir.exists():
149149
os.makedirs(self.extensions_dir, exist_ok=True)
150150

151+
if not (self.extensions_dir / 'host.json').exists():
152+
with open(self.extensions_dir / 'host.json', 'w') as f:
153+
print(r'{}', file=f)
154+
151155
env = os.environ.copy()
152156
env['TERM'] = 'xterm' # ncurses 6.1 workaround
153157

0 commit comments

Comments
 (0)