From bff9dfd00424421407f507330c62ba331339370f Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Mon, 1 Aug 2022 17:37:30 +0530 Subject: [PATCH 1/2] test: Skip asset building & resolving node deps --- bench/tests/test_init.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/bench/tests/test_init.py b/bench/tests/test_init.py index f8b6e038..622ffc87 100755 --- a/bench/tests/test_init.py +++ b/bench/tests/test_init.py @@ -80,7 +80,6 @@ class TestBenchInit(TestBenchBase): site_config_path = os.path.join(site_path, "site_config.json") self.init_bench(bench_name) - exec_cmd("bench setup requirements --node", cwd=bench_path) self.new_site(site_name, bench_name) self.assertTrue(os.path.exists(site_path)) @@ -99,7 +98,7 @@ class TestBenchInit(TestBenchBase): def test_get_app(self): self.init_bench("test-bench") bench_path = os.path.join(self.benches_path, "test-bench") - exec_cmd(f"bench get-app {TEST_FRAPPE_APP}", cwd=bench_path) + exec_cmd(f"bench get-app {TEST_FRAPPE_APP} --skip-assets", cwd=bench_path) self.assertTrue(os.path.exists(os.path.join(bench_path, "apps", TEST_FRAPPE_APP))) app_installed_in_env = TEST_FRAPPE_APP in subprocess.check_output( ["bench", "pip", "freeze"], cwd=bench_path @@ -111,7 +110,7 @@ class TestBenchInit(TestBenchBase): FRAPPE_APP = "healthcare" self.init_bench("test-bench") bench_path = os.path.join(self.benches_path, "test-bench") - exec_cmd(f"bench get-app {FRAPPE_APP} --resolve-deps", cwd=bench_path) + exec_cmd(f"bench get-app {FRAPPE_APP} --resolve-deps --skip-assets", cwd=bench_path) self.assertTrue(os.path.exists(os.path.join(bench_path, "apps", FRAPPE_APP))) states_path = os.path.join(bench_path, "sites", "apps.json") @@ -128,9 +127,9 @@ class TestBenchInit(TestBenchBase): bench_path = os.path.join(self.benches_path, "test-bench") self.init_bench(bench_name) - exec_cmd("bench setup requirements --node", cwd=bench_path) - exec_cmd("bench build", cwd=bench_path) - exec_cmd(f"bench get-app {TEST_FRAPPE_APP} --branch master", cwd=bench_path) + exec_cmd( + f"bench get-app {TEST_FRAPPE_APP} --branch master --skip-assets", cwd=bench_path + ) self.assertTrue(os.path.exists(os.path.join(bench_path, "apps", TEST_FRAPPE_APP))) @@ -158,9 +157,9 @@ class TestBenchInit(TestBenchBase): self.init_bench("test-bench") bench_path = os.path.join(self.benches_path, "test-bench") - exec_cmd("bench setup requirements --node", cwd=bench_path) exec_cmd( - f"bench get-app {TEST_FRAPPE_APP} --branch master --overwrite", cwd=bench_path + f"bench get-app {TEST_FRAPPE_APP} --branch master --overwrite --skip-assets", + cwd=bench_path, ) exec_cmd(f"bench remove-app {TEST_FRAPPE_APP}", cwd=bench_path) From 01b77598ff2ff4cde4c75dad9b3a39526858c685 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Mon, 1 Aug 2022 17:40:37 +0530 Subject: [PATCH 2/2] fix: Pass cwd for cmd subprocess execution Also, use python instead of python3 hardcoded in env --- bench/bench.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/bench/bench.py b/bench/bench.py index 6b5dd3d1..3d286bf1 100644 --- a/bench/bench.py +++ b/bench/bench.py @@ -71,7 +71,7 @@ class Bench(Base, Validator): @property def python(self) -> str: - return get_env_cmd("python3", bench_path=self.name) + return get_env_cmd("python", bench_path=self.name) @property def shallow_clone(self) -> bool: @@ -352,15 +352,18 @@ class BenchSetup(Base): if not os.path.exists(self.bench.python): if virtualenv: - self.run(f"{virtualenv} {quiet_flag} env -p {python}") + self.run(f"{virtualenv} {quiet_flag} env -p {python}", cwd=self.bench.name) else: venv = get_venv_path(verbose=verbose, python=python) - self.run(f"{venv} env") + self.run(f"{venv} env", cwd=self.bench.name) self.pip() if os.path.exists(frappe): - self.run(f"{self.bench.python} -m pip install {quiet_flag} --upgrade -e {frappe}") + self.run( + f"{self.bench.python} -m pip install {quiet_flag} --upgrade -e {frappe}", + cwd=self.bench.name, + ) @step(title="Setting Up Bench Config", success="Bench Config Set Up") def config(self, redis=True, procfile=True): @@ -388,7 +391,9 @@ class BenchSetup(Base): verbose = bench.cli.verbose or verbose quiet_flag = "" if verbose else "--quiet" - return self.run(f"{self.bench.python} -m pip install {quiet_flag} --upgrade pip") + return self.run( + f"{self.bench.python} -m pip install {quiet_flag} --upgrade pip", cwd=self.bench.name + ) def logging(self): from bench.utils import setup_logging