Skip to content

Commit

Permalink
Upstream fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zakstucke committed Feb 7, 2024
1 parent ab74bfd commit 31fa968
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 19 deletions.
4 changes: 2 additions & 2 deletions py_rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion py_rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
1 change: 1 addition & 0 deletions py_rust/src/config/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
19 changes: 3 additions & 16 deletions py_rust/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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"),
)
Expand All @@ -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",
]
Expand All @@ -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)",
]
}
Expand Down

0 comments on commit 31fa968

Please sign in to comment.