Skip to content

Commit af775c2

Browse files
committed
Test remote patches on windows
1 parent d126b21 commit af775c2

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

graalpython/com.oracle.graal.python.test/src/runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ def parse_config(cls, config_path: Path):
899899
if config_tags_dir := settings.get('tags_dir'):
900900
tags_dir = (config_path.parent / config_tags_dir).resolve()
901901
# Temporary hack for Bytecode DSL development in master branch:
902-
if IS_GRAALPY and __graalpython__.is_bytecode_dsl_interpreter and tags_dir:
902+
if IS_GRAALPY and getattr(__graalpython__, 'is_bytecode_dsl_interpreter', False) and tags_dir:
903903
new_tags_dir = (config_path.parent / (config_tags_dir + '_bytecode_dsl')).resolve()
904904
if new_tags_dir.exists():
905905
tags_dir = new_tags_dir

graalpython/com.oracle.graal.python.test/src/tests/conftest.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ partial_splits_individual_tests = true
2222
exclude_on = ['win32']
2323
selector = [
2424
"test_multiprocessing_graalpy.py", # import _winapi
25-
"test_patched_pip.py",
2625
"test_pathlib.py",
2726
"test_posix.py", # import posix
2827
"test_pyio.py", # pyio imports msvcrt

graalpython/com.oracle.graal.python.test/src/tests/test_patched_pip.py

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3737
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3838
# SOFTWARE.
39+
import io
3940
import os
4041
import re
4142
import shutil
@@ -87,7 +88,10 @@ class PipPatchingTest(unittest.TestCase):
8788
def setUpClass(cls):
8889
cls.venv_dir = Path(tempfile.mkdtemp()).resolve()
8990
subprocess.check_output([sys.executable, "-m", "venv", str(cls.venv_dir)])
90-
cls.venv_python = str(cls.venv_dir / 'bin' / 'python')
91+
if sys.platform != 'win32':
92+
cls.venv_python = str(cls.venv_dir / 'bin' / 'python')
93+
else:
94+
cls.venv_python = str(cls.venv_dir / 'Scripts' / 'python.exe')
9195
subprocess.check_output([cls.venv_python, '-m', 'pip', 'install', 'wheel', 'setuptools'])
9296
cls.venv_template_dir = f'{cls.venv_dir}.template'
9397
cls.venv_dir.rename(cls.venv_template_dir)
@@ -157,11 +161,12 @@ def run_venv_pip_install(self, package, extra_env=None, assert_stderr_matches=No
157161
env.update(extra_env)
158162
proc = subprocess.run(
159163
[
160-
str(self.venv_dir / 'bin' / 'pip'),
164+
str(self.venv_python),
165+
'-m', 'pip',
161166
'--isolated',
162167
'install',
163168
'--force-reinstall',
164-
'--find-links', self.index_dir,
169+
'--find-links', str(self.index_dir),
165170
'--no-index',
166171
'--no-cache-dir',
167172
package,
@@ -171,6 +176,7 @@ def run_venv_pip_install(self, package, extra_env=None, assert_stderr_matches=No
171176
env=env,
172177
universal_newlines=True,
173178
)
179+
print(proc.stdout)
174180
print(proc.stderr)
175181
assert 'Applying GraalPy patch failed for' not in proc.stderr
176182
if assert_stderr_matches:
@@ -423,19 +429,31 @@ def test_broken_patches_path(self):
423429
def test_patches_file_url(self):
424430
self.check_installing_with_patch_repo(urljoin('file:', pathname2url(str(self.patch_dir.absolute()))))
425431

426-
@unittest.skipIf(
427-
__graalpython__.posix_module_backend() == 'java',
428-
"Server doesn't work properly under Java posix backend"
429-
)
430432
def test_patches_http_url(self):
431433
patch_dir = self.patch_dir
432434

433435
class Handler(SimpleHTTPRequestHandler):
434436
def __init__(self, *args, **kwargs):
435437
super().__init__(*args, directory=str(patch_dir), **kwargs)
436438

439+
def do_GET(self):
440+
f = self.send_head()
441+
if f:
442+
try:
443+
input_file = io.TextIOWrapper(f)
444+
# Always serve UTF-8 with unix line endings regardless of platform
445+
# to emulate what GitHub would serve from a patch branch
446+
output_file = io.TextIOWrapper(self.wfile, encoding='utf-8', newline='\n')
447+
shutil.copyfileobj(input_file, output_file)
448+
output_file.flush()
449+
finally:
450+
f.close()
451+
437452
try:
438453
with HTTPServer(('localhost', 0), Handler) as server:
454+
if not server.server_port:
455+
# Workaround for java posix backend limitation
456+
server.server_port = server.socket.getsockname()[1]
439457
thread = threading.Thread(target=server.serve_forever)
440458
thread.start()
441459
try:

0 commit comments

Comments
 (0)