From 31fa968472972b3f07ef940811c2181e56992ab6 Mon Sep 17 00:00:00 2001 From: Zak Stucke Date: Thu, 8 Feb 2024 00:07:32 +0200 Subject: [PATCH] Upstream fix --- py_rust/Cargo.lock | 4 ++-- py_rust/Cargo.toml | 2 +- py_rust/src/config/tasks.rs | 1 + py_rust/tests/test_tasks.py | 19 +++---------------- 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/py_rust/Cargo.lock b/py_rust/Cargo.lock index e3d7066..aaa051d 100644 --- a/py_rust/Cargo.lock +++ b/py_rust/Cargo.lock @@ -155,9 +155,9 @@ checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" [[package]] name = "bitbazaar" -version = "0.0.27" +version = "0.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40f2b354b49260662f72c32df6ec3ab0f1243ef54526547a996d8dc760bb9ff8" +checksum = "7fa6a913a8716b25a10922db990d607c9d230e329ccd11a49eca54500f22c29b" dependencies = [ "chrono", "clap", diff --git a/py_rust/Cargo.toml b/py_rust/Cargo.toml index e992aae..c2aeaa7 100644 --- a/py_rust/Cargo.toml +++ b/py_rust/Cargo.toml @@ -19,7 +19,7 @@ valico = '4.0.0' [dependencies.bitbazaar] features = ['cli'] -version = '0.0.27' +version = '0.0.28' [dependencies.clap] features = ['derive', 'string'] diff --git a/py_rust/src/config/tasks.rs b/py_rust/src/config/tasks.rs index fcef53a..fd4844d 100644 --- a/py_rust/src/config/tasks.rs +++ b/py_rust/src/config/tasks.rs @@ -49,6 +49,7 @@ impl Task { })?; // Create the bash environment: + error!("CONFIG DIR: {}", config_dir.display()); let mut bash = Bash::new().chdir(config_dir); bash = bash.env(IN_TASK_ENV_VAR, "1"); if let Some(cached_config_loc) = cached_config_loc { diff --git a/py_rust/tests/test_tasks.py b/py_rust/tests/test_tasks.py index d450f94..a3d0a29 100644 --- a/py_rust/tests/test_tasks.py +++ b/py_rust/tests/test_tasks.py @@ -9,19 +9,6 @@ from .helpers.types import InputConfig, Task -def create_file_cmd(filepath: str, content: str) -> str: - """Create a command that creates the file with given contents if missing, if already exists exits with code 1.""" - content = content.replace('"', '\\"') - - # If windows: - if os.name == "nt": - return ( - f'cmd.exe /c "IF EXIST {filepath} ( EXIT /B 1 ) ELSE ( ECHO "{content}" > {filepath} )"' - ) - else: - return f"bash -c \"[ -e {filepath} ] && exit 1 || echo '{content}' > {filepath}\"" - - def check_file(filepath: str, content: str): with open(filepath, "r") as file: assert file.read().strip() == content.strip() @@ -35,7 +22,7 @@ def check_file(filepath: str, content: str): ( f"basic_{typ}", typ, - [{"commands": [create_file_cmd("file.txt", "hello")]}], + [{"commands": ["echo hello > file.txt"]}], {}, lambda man: lambda: check_file(os.path.join(man.root_dir, "file.txt"), "hello"), ) @@ -49,7 +36,7 @@ def check_file(filepath: str, content: str): [ { "commands": [ - create_file_cmd("file.json", '{"ree": "bar"}'), + 'echo \'{"ree": "bar"}\' > file.json', "zetch put file.json value $(zetch read file.json ree)", "zetch del file.json ree", ] @@ -69,7 +56,7 @@ def check_file(filepath: str, content: str): [ { "commands": [ - create_file_cmd("file.json", "{}"), + 'echo "{}" > file.json', "zetch put file.json value $(zetch var FOO)", ] }