From 04924bbec08a654d7e4ea2cd23cfefc8e260ece0 Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Sun, 15 Aug 2021 20:37:19 +0530 Subject: [PATCH] Fix Xonsh test --- shell.nix | 4 ++-- src/shell.rs | 13 +++++-------- templates/xonsh.txt | 2 +- templates/zsh.txt | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/shell.nix b/shell.nix index 887f6a6..69d93bf 100644 --- a/shell.nix +++ b/shell.nix @@ -1,7 +1,7 @@ let - rust = import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"); + rust = import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/ad311f5bb5c5ef475985f1e0f264e831470a8510.tar.gz"); pkgs = import { overlays = [ rust ]; }; - pkgs-latest = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/94e725d3299cbeb71419758d671dfb0771b8e318.tar.gz") {}; + pkgs-latest = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/1359293549af4f8ca536716d0432f3cdd0afe0c6.tar.gz") {}; pkgs-python = pkgs-latest.python3.withPackages (pkgs: [ pkgs.black pkgs.mypy pkgs.pylint ]); in pkgs.mkShell { diff --git a/src/shell.rs b/src/shell.rs index 19f3ef4..1bb4eb7 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -356,15 +356,12 @@ mod tests { let opts = Opts { cmd, hook, echo, resolve_symlinks }; let source = Xonsh(&opts).render().unwrap(); - // We can't pass the source directly to `xonsh -c` due to - // a bug: + let tempdir = tempfile::tempdir().unwrap(); + let tempdir = tempdir.path().to_str().unwrap(); + Command::new("xonsh") - .args(&[ - "-c", - "import sys; execx(sys.stdin.read(), 'exec', __xonsh__.ctx, filename='zoxide')", - "--no-rc", - ]) - .write_stdin(source.as_bytes()) + .args(&["-c", &source, "--no-rc"]) + .env("HOME", tempdir) .assert() .success() .stdout("") diff --git a/templates/xonsh.txt b/templates/xonsh.txt index 601ae3d..c5fb157 100644 --- a/templates/xonsh.txt +++ b/templates/xonsh.txt @@ -1,7 +1,7 @@ {%- let section = "# =============================================================================\n#" -%} {%- let not_configured = "# -- not configured --" -%} -"""Initialize zoxide on Xonsh.""" +# pylint: disable=missing-module-docstring import builtins # pylint: disable=unused-import import os diff --git a/templates/zsh.txt b/templates/zsh.txt index 96f0ef0..6bee5fd 100644 --- a/templates/zsh.txt +++ b/templates/zsh.txt @@ -59,7 +59,7 @@ function __zoxide_z() { \builtin printf 'zoxide: $OLDPWD is not set' return 1 fi - elif [ "$#" -eq 1 ] && [ -d "$1" ]; then + elif [ "$#" -eq 1 ] && [ -d "$1" ]; then __zoxide_cd "$1" else \builtin local __zoxide_result