Skip to content

Commit

Permalink
Enhance error handling and platform-specific command execution in Pyt…
Browse files Browse the repository at this point in the history
…hon executor
  • Loading branch information
polischuks committed Feb 15, 2025
1 parent e24cd3a commit e33bd7a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ jobs:
fail-fast: false
matrix:
include:
# Ubuntu
- os: ubuntu-latest
python-version: "3.10"
- os: ubuntu-latest
python-version: "3.11"
- os: ubuntu-latest
python-version: "3.12"
# # Ubuntu
# - os: ubuntu-latest
# python-version: "3.10"
# - os: ubuntu-latest
# python-version: "3.11"
# - os: ubuntu-latest
# python-version: "3.12"

# Windows
- os: windows-latest
Expand All @@ -73,13 +73,13 @@ jobs:
- os: windows-latest
python-version: "3.12"

# macOS (arm64)
- os: macos-14
python-version: "3.10"
- os: macos-14
python-version: "3.11"
- os: macos-14
python-version: "3.12"
# # macOS (arm64)
# - os: macos-14
# python-version: "3.10"
# - os: macos-14
# python-version: "3.11"
# - os: macos-14
# python-version: "3.12"
steps:
- uses: actions/checkout@v4
- uses: ./.github/workflows/actions/prepare
Expand Down
7 changes: 5 additions & 2 deletions hstest/testing/execution/process/python_executor.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
from __future__ import annotations

import os
import sys

from hstest.testing.execution.process_executor import ProcessExecutor
from hstest.testing.execution.searcher.python_searcher import PythonSearcher


class PythonExecutor(ProcessExecutor):
def __init__(self, source_name: str | None = None) -> None:
super().__init__(PythonSearcher().find(source_name))
# Set UTF-8 encoding for Python I/O on Windows
if os.name == 'nt':
os.environ['PYTHONIOENCODING'] = 'utf8'

def _execution_command(self, *args: str):
cmd = ["python"]
if sys.platform == "win32":
if os.name == 'nt': # Works on all Windows versions (32/64 bit)
# Set UTF-8 encoding for stdin/stdout on Windows
cmd.extend(["-X", "utf8"])
cmd.extend(["-u", self.runnable.file, *list(args)])
Expand Down

0 comments on commit e33bd7a

Please sign in to comment.