From ab36c8c9de0e54021fa29ad3fbcfacfdb588ff42 Mon Sep 17 00:00:00 2001 From: ed Date: Sun, 18 Sep 2022 00:16:40 +0200 Subject: [PATCH] fix tests --- copyparty/__main__.py | 6 +++--- scripts/run-tests.sh | 6 ++++-- tests/util.py | 7 ++++++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 4fe54990..cda4358e 100755 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -20,7 +20,7 @@ import time import traceback from textwrap import dedent -from .__init__ import ANYWIN, CORES, PY2, VT100, WINDOWS, E, unicode +from .__init__ import ANYWIN, CORES, PY2, VT100, WINDOWS, E, EnvParams, unicode from .__version__ import CODENAME, S_BUILD_DT, S_VERSION from .authsrv import re_vol from .svchub import SvcHub @@ -132,7 +132,7 @@ def warn(msg: str) -> None: lprint("\033[1mwarning:\033[0;33m {}\033[0m\n".format(msg)) -def init_E() -> None: +def init_E(E: EnvParams) -> None: # __init__ runs 18 times when oxidized; do expensive stuff here def get_unixdir() -> str: @@ -774,7 +774,7 @@ def main(argv: Optional[list[str]] = None) -> None: if WINDOWS: os.system("rem") # enables colors - init_E() + init_E(E) if argv is None: argv = sys.argv diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh index 1977a55a..90f225dc 100755 --- a/scripts/run-tests.sh +++ b/scripts/run-tests.sh @@ -17,8 +17,10 @@ for py in python{2,3}; do pids+=($!) done -python3 ../scripts/test/smoketest.py & -pids+=($!) +[ "$1" ] || { + python3 ../scripts/test/smoketest.py & + pids+=($!) +} for pid in ${pids[@]}; do wait $pid diff --git a/tests/util.py b/tests/util.py index be158a72..e87786f8 100644 --- a/tests/util.py +++ b/tests/util.py @@ -30,8 +30,12 @@ if MACOS: # 25% faster; until any tests do symlink stuff +from copyparty.__init__ import E +from copyparty.__main__ import init_E from copyparty.util import Unrecv, FHC +init_E(E) + def runcmd(argv): p = sp.Popen(argv, stdout=sp.PIPE, stderr=sp.PIPE) @@ -97,7 +101,7 @@ class Cfg(Namespace): ex = "e2d e2ds e2dsa e2t e2ts e2tsr e2v e2vu e2vp xdev xvol ed emp force_js ihead no_acode no_athumb no_del no_logues no_mv no_readme no_robots no_scandir no_thumb no_vthumb no_zip nid nih nw" ka.update(**{k: False for k in ex.split()}) - ex = "no_rescan no_sendfile no_voldump" + ex = "no_rescan no_sendfile no_voldump plain_ip" ka.update(**{k: True for k in ex.split()}) ex = "css_browser hist js_browser no_hash no_idx no_forget" @@ -113,6 +117,7 @@ class Cfg(Namespace): a=a or [], v=v or [], c=c, + E=E, s_wr_sz=512 * 1024, unpost=600, u2sort="s",