mirror of
https://github.com/Niko1221/Strata.git
synced 2026-11-07 14:21:06 -10:00
Tests: five terminal tests no longer depend on the box they run on (a system cloudflared, no llama.cpp checkout, Linux library path, the default data folder equal to the typed one)
This commit is contained in:
1 parent
34c0f7dae7
commit
da8c7f4a4f
4 files changed
+14
-7
No files matched your search
@@ -73,6 +73,10 @@ class BundleImports(unittest.TestCase):
|
||||
|
||||
def test_setup_py_and_each_of_its_tools_import_with_tools_limited_to_the_bundle(self):
|
||||
modules = sorted(set(pt.setup_tool_imports(self.root)) | set(pt.INSTALLER_TOOLS))
|
||||
probe = subprocess.run([sys.executable, "-I", "-c", f"import sys; sys.path.insert(0, {str(self.root / 'tools')!r}); import _paths; _paths.gguf_py()"],
|
||||
capture_output=True, text=True, timeout=60, env={**os.environ, "STRATA_CONTROL_INSTALL": "1"})
|
||||
if probe.returncode != 0: # a tool reads llama.cpp's gguf-py when it is imported: a test box without any llama.cpp checkout cannot import it
|
||||
self.skipTest("no llama.cpp gguf-py on this box (set STRATA_GGUF_PY to run this check)")
|
||||
code = ("import sys, os, importlib\n"
|
||||
f"sys.path[:0] = [{str(self.root)!r}, {str(self.root / 'tools')!r}]\n"
|
||||
"import setup\n"
|
||||
|
||||
@@ -45,7 +45,9 @@ class FindOnPath(unittest.TestCase):
|
||||
def test_the_local_bin_folder_is_searched_when_path_misses_it(self):
|
||||
(self.dir / ".local" / "bin").mkdir(parents=True)
|
||||
exe = fake_cloudflared(self.dir / ".local" / "bin")
|
||||
with self.env(PATH=str(self.dir / "empty")), mock.patch.object(Path, "home", return_value=self.dir):
|
||||
places = access._cloudflared_places
|
||||
with self.env(PATH=str(self.dir / "empty")), mock.patch.object(Path, "home", return_value=self.dir), mock.patch.object(access, "_cloudflared_places", # a box with its own system cloudflared (/usr/bin) must not answer first
|
||||
lambda: [p for p in places() if not p.replace("\\", "/").startswith(("/usr/", "/opt/", "/bin/"))]):
|
||||
self.assertEqual(access.find_cloudflared(), str(exe))
|
||||
|
||||
def test_a_too_old_copy_is_passed_over(self):
|
||||
|
||||
@@ -217,8 +217,8 @@ class HipPackageLibraryPath(unittest.TestCase):
|
||||
def test_rocm_bin_comes_after_the_package_folder(self):
|
||||
folder = self.package({"lib_dirs": ["rocm/bin"]})
|
||||
self.assertEqual(dsv41_engine.lib_dirs(folder / EXE), [str(folder), str(folder / "rocm" / "bin")])
|
||||
env = dsv41_engine.start_env(folder / EXE, {"PATH": "C:\\Windows"})
|
||||
first = env["PATH"].split(os.pathsep)[:2]
|
||||
env = dsv41_engine.start_env(folder / EXE, {dsv41_engine.LIB_VAR: "C:\\Windows"}) # PATH on Windows, LD_LIBRARY_PATH elsewhere
|
||||
first = env[dsv41_engine.LIB_VAR].split(os.pathsep)[:2]
|
||||
self.assertEqual(first, [str(folder), str(folder / "rocm" / "bin")])
|
||||
|
||||
def test_a_cuda_package_needs_only_its_folder(self):
|
||||
|
||||
@@ -337,10 +337,11 @@ class FolderStep(Base):
|
||||
self.assertIn("Free space in that folder's drive", t)
|
||||
f = app.screen.query_one("#folderpath")
|
||||
f.value = ""
|
||||
await typed(pilot, str(self.home.base / "Strata-data"))
|
||||
self.assertEqual(f.value, str(self.home.base / "Strata-data"))
|
||||
self.assertNotEqual(str(ctx.default_folder()), str(self.home.base / "Elsewhere-data")) # (on Linux the default is Strata-data under the home: typing it again is no change)
|
||||
await typed(pilot, str(self.home.base / "Elsewhere-data"))
|
||||
self.assertEqual(f.value, str(self.home.base / "Elsewhere-data"))
|
||||
await press(pilot, "enter")
|
||||
self.assertEqual(ctx.settings.data_dir, str(self.home.base / "Strata-data"))
|
||||
self.assertEqual(ctx.settings.data_dir, str(self.home.base / "Elsewhere-data"))
|
||||
self.assertIn("How much text should it remember at once?", text_of(app))
|
||||
self.run_app(case)
|
||||
|
||||
@@ -718,9 +719,9 @@ class AccessStep(Base):
|
||||
self.assertIn("cloudflared is not installed on this computer", t)
|
||||
self.assertIn("quick tunnel", flat(app))
|
||||
await press(pilot, "enter")
|
||||
self.assertTrue(any("cloudflared" in w for w in ctx.warnings())) # inside the mock: a box with a system cloudflared finds one
|
||||
self.assertEqual(ctx.settings.access, "cloudflare")
|
||||
self.assertIn("Save as preset, then launch", text_of(app))
|
||||
self.assertTrue(any("cloudflared" in w for w in ctx.warnings()))
|
||||
self.run_app(case)
|
||||
|
||||
def test_tailscale_found(self):
|
||||
|
||||
Reference in new issue
Block a user