fix test logic

This commit is contained in:
blueloveTH 2024-04-14 13:35:49 +08:00
parent 5d4294b457
commit 348b071c1e
4 changed files with 5 additions and 14 deletions

View File

@ -6,6 +6,8 @@ except ImportError:
import sys
is_pkpy = not hasattr(sys, 'getrefcount')
os.chdir('benchmarks')
if is_pkpy:
try:
import cjson as json

View File

@ -3,6 +3,8 @@ try:
except ImportError:
exit(0)
os.chdir('benchmarks')
import json
_2489KB = 'WorldMap_GridVania_layout.ldtk'

View File

@ -3,22 +3,10 @@ import sys
import time
import subprocess
class WorkDir:
def __init__(self, next):
self.prev = os.getcwd()
self.next = next
def __enter__(self):
os.chdir(self.next)
def __exit__(self, *args, **kwargs):
os.chdir(self.prev)
def test_file(filepath, cpython=False):
if cpython:
x, y = os.path.split(filepath)
with WorkDir(x):
return os.system("python " + y) == 0
return os.system("python " + filepath) == 0
if sys.platform == 'win32':
return os.system("main.exe " + filepath) == 0
else:

View File

@ -3,7 +3,6 @@ try:
except ImportError:
exit(0)
# test import
os.chdir('tests')
import test1