|
@@ -25,7 +25,7 @@
|
|
|
import random
|
|
|
import subprocess
|
|
|
import glob
|
|
|
-from typing import Dict, Any, Optional, ContextManager
|
|
|
+from typing import List, Dict, Any, Optional, ContextManager
|
|
|
|
|
|
|
|
|
def isxfile(path: str) -> bool:
|
|
@@ -74,6 +74,21 @@ class TestEnv(ContextManager['TestEnv']):
|
|
|
'CACHEMODE_IS_DEFAULT', 'IMGFMT_GENERIC', 'IMGOPTSSYNTAX',
|
|
|
'IMGKEYSECRET', 'QEMU_DEFAULT_MACHINE', 'MALLOC_PERTURB_']
|
|
|
|
|
|
+ def prepare_subprocess(self, args: List[str]) -> Dict[str, str]:
|
|
|
+ if self.debug:
|
|
|
+ args.append('-d')
|
|
|
+
|
|
|
+ with open(args[0], encoding="utf-8") as f:
|
|
|
+ try:
|
|
|
+ if f.readline().rstrip() == '#!/usr/bin/env python3':
|
|
|
+ args.insert(0, self.python)
|
|
|
+ except UnicodeDecodeError: # binary test? for future.
|
|
|
+ pass
|
|
|
+
|
|
|
+ os_env = os.environ.copy()
|
|
|
+ os_env.update(self.get_env())
|
|
|
+ return os_env
|
|
|
+
|
|
|
def get_env(self) -> Dict[str, str]:
|
|
|
env = {}
|
|
|
for v in self.env_variables:
|