mirror of
https://github.com/Llewellynvdm/zoxide.git
synced 2024-11-10 15:20:55 +00:00
Use Nix for testing
This commit is contained in:
parent
58bcbef7aa
commit
e6e67b16bc
32
.github/workflows/cargo-test.yml
vendored
32
.github/workflows/cargo-test.yml
vendored
@ -5,29 +5,21 @@ on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test-linux:
|
||||
runs-on: ubuntu-18.04
|
||||
test-unix:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
steps:
|
||||
- run: sudo apt update
|
||||
- run: sudo apt install wget apt-transport-https
|
||||
- run: wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
|
||||
- run: sudo dpkg -i packages-microsoft-prod.deb
|
||||
- run: sudo apt update
|
||||
- run: sudo add-apt-repository universe
|
||||
- run: sudo apt install bash dash fish powershell python3 python3-pip shellcheck xonsh zsh
|
||||
- run: sudo snap install shfmt
|
||||
- run: sudo pip3 install --upgrade pip setuptools
|
||||
- run: sudo pip3 install --upgrade black mypy pylint
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions-rs/toolchain@v1
|
||||
- uses: cachix/install-nix-action@v12
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --all-features --no-fail-fast
|
||||
nix_path: nixpkgs=channel:nixos-unstable
|
||||
# - uses: cachix/cachix-action@v8
|
||||
# with:
|
||||
# name: zoxide
|
||||
# authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
- run: nix-shell --run "cargo test --no-fail-fast"
|
||||
test-windows:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
|
34
shell.nix
Normal file
34
shell.nix
Normal file
@ -0,0 +1,34 @@
|
||||
{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/20.09.tar.gz") {} }:
|
||||
|
||||
let
|
||||
my-python3-pkgs = python3-pkgs: with python3-pkgs; [
|
||||
black
|
||||
mypy
|
||||
pylint
|
||||
];
|
||||
my-python3 = pkgs.python3.withPackages my-python3-pkgs;
|
||||
in
|
||||
|
||||
pkgs.mkShell {
|
||||
name = "env";
|
||||
nativeBuildInputs = [
|
||||
pkgs.rustc
|
||||
pkgs.cargo
|
||||
];
|
||||
buildInputs = [
|
||||
pkgs.bash
|
||||
pkgs.dash
|
||||
pkgs.fish
|
||||
pkgs.fzf
|
||||
pkgs.git
|
||||
pkgs.powershell
|
||||
pkgs.shellcheck
|
||||
pkgs.shfmt
|
||||
pkgs.xonsh
|
||||
pkgs.zsh
|
||||
my-python3
|
||||
];
|
||||
|
||||
# Set Environment Variables
|
||||
RUST_BACKTRACE = 1;
|
||||
}
|
@ -73,11 +73,10 @@ enum Shell {
|
||||
fn env_help() -> &'static str {
|
||||
static ENV_HELP: OnceCell<String> = OnceCell::new();
|
||||
ENV_HELP.get_or_init(|| {
|
||||
const PATH_SPLIT_SEPARATOR: u8 = if cfg!(any(target_os = "redox", target_os = "windows")) {
|
||||
b';'
|
||||
} else {
|
||||
b':'
|
||||
};
|
||||
#[cfg(unix)]
|
||||
const PATH_SPLIT_SEPARATOR: u8 = b':';
|
||||
#[cfg(any(target_os = "redox", target_os = "windows"))]
|
||||
const PATH_SPLIT_SEPARATOR: u8 = b'\\';
|
||||
|
||||
format!(
|
||||
"\
|
||||
|
@ -9,7 +9,10 @@ pub struct Opts<'a> {
|
||||
}
|
||||
|
||||
impl Opts<'_> {
|
||||
pub const DEVNULL: &'static str = if cfg!(windows) { "NUL" } else { "/dev/null" };
|
||||
#[cfg(unix)]
|
||||
pub const DEVNULL: &'static str = "/dev/null";
|
||||
#[cfg(windows)]
|
||||
pub const DEVNULL: &'static str = "NUL";
|
||||
}
|
||||
|
||||
macro_rules! make_template {
|
||||
@ -113,7 +116,7 @@ mod tests {
|
||||
let opts = dbg!(&opts()[i]);
|
||||
let source = Bash(opts).render().unwrap();
|
||||
Command::new("shellcheck")
|
||||
.args(&["--shell", "bash", "-"])
|
||||
.args(&["--enable", "all", "--shell", "bash", "-"])
|
||||
.write_stdin(source)
|
||||
.assert()
|
||||
.success()
|
||||
@ -186,7 +189,7 @@ mod tests {
|
||||
let opts = dbg!(&opts()[i]);
|
||||
let source = Posix(opts).render().unwrap();
|
||||
Command::new("shellcheck")
|
||||
.args(&["--shell", "sh", "-"])
|
||||
.args(&["--enable", "all", "--shell", "sh", "-"])
|
||||
.write_stdin(source)
|
||||
.assert()
|
||||
.success()
|
||||
|
@ -37,11 +37,11 @@ function __zoxide_hook() {
|
||||
{%- when Hook::Pwd %}
|
||||
function __zoxide_hook() {
|
||||
local -r __zoxide_pwd_tmp="$(__zoxide_pwd)"
|
||||
if [ -z "$__zoxide_pwd_old" ]; then
|
||||
__zoxide_pwd_old="$__zoxide_pwd_tmp"
|
||||
elif [ "$__zoxide_pwd_old" != "$__zoxide_pwd_tmp" ]; then
|
||||
__zoxide_pwd_old="$__zoxide_pwd_tmp"
|
||||
zoxide add "$__zoxide_pwd_old"
|
||||
if [ -z "${__zoxide_pwd_old}" ]; then
|
||||
__zoxide_pwd_old="${__zoxide_pwd_tmp}"
|
||||
elif [ "${__zoxide_pwd_old}" != "${__zoxide_pwd_tmp}" ]; then
|
||||
__zoxide_pwd_old="${__zoxide_pwd_tmp}"
|
||||
zoxide add "${__zoxide_pwd_old}"
|
||||
fi
|
||||
}
|
||||
{%- endmatch %}
|
||||
@ -51,7 +51,7 @@ function __zoxide_hook() {
|
||||
{{ NOT_CONFIGURED }}
|
||||
|
||||
{%- else %}
|
||||
case "$PROMPT_COMMAND" in
|
||||
case "${PROMPT_COMMAND}" in
|
||||
*__zoxide_hook*) ;;
|
||||
*) PROMPT_COMMAND="${PROMPT_COMMAND:+${PROMPT_COMMAND};}__zoxide_hook" ;;
|
||||
esac
|
||||
@ -68,24 +68,25 @@ function __zoxide_z() {
|
||||
if [ "$#" -eq 0 ]; then
|
||||
__zoxide_cd ~
|
||||
elif [ "$#" -eq 1 ] && [ "$1" = '-' ]; then
|
||||
if [ -n "$OLDPWD" ]; then
|
||||
__zoxide_cd "$OLDPWD"
|
||||
if [ -n "${OLDPWD}" ]; then
|
||||
__zoxide_cd "${OLDPWD}"
|
||||
else
|
||||
echo "zoxide: \\$OLDPWD is not set"
|
||||
# shellcheck disable=SC2016
|
||||
echo 'zoxide: $OLDPWD is not set'
|
||||
return 1
|
||||
fi
|
||||
elif [ "$#" -eq 1 ] && [ -d "$1" ]; then
|
||||
__zoxide_cd "$1"
|
||||
else
|
||||
local __zoxide_result
|
||||
__zoxide_result="$(zoxide query -- "$@")" && __zoxide_cd "$__zoxide_result"
|
||||
__zoxide_result="$(zoxide query -- "$@")" && __zoxide_cd "${__zoxide_result}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Jump to a directory using interactive search.
|
||||
function __zoxide_zi() {
|
||||
local __zoxide_result
|
||||
__zoxide_result="$(zoxide query -i -- "$@")" && __zoxide_cd "$__zoxide_result"
|
||||
__zoxide_result="$(zoxide query -i -- "$@")" && __zoxide_cd "${__zoxide_result}"
|
||||
}
|
||||
|
||||
# Add a new entry to the database.
|
||||
|
@ -52,7 +52,7 @@ __zoxide_hook() {
|
||||
{{ NOT_CONFIGURED }}
|
||||
|
||||
{%- when Hook::Prompt %}
|
||||
case "$PS1" in
|
||||
case "${PS1}" in
|
||||
*\$\(__zoxide_hook\)*) ;;
|
||||
*) PS1="${PS1}\$(__zoxide_hook)" ;;
|
||||
esac
|
||||
@ -72,22 +72,23 @@ __zoxide_z() {
|
||||
if [ "$#" -eq 0 ]; then
|
||||
__zoxide_cd ~
|
||||
elif [ "$#" -eq 1 ] && [ "$1" = '-' ]; then
|
||||
if [ -n "$OLDPWD" ]; then
|
||||
__zoxide_cd "$OLDPWD"
|
||||
if [ -n "${OLDPWD}" ]; then
|
||||
__zoxide_cd "${OLDPWD}"
|
||||
else
|
||||
echo "zoxide: \\$OLDPWD is not set"
|
||||
# shellcheck disable=SC2016
|
||||
echo 'zoxide: $OLDPWD is not set'
|
||||
return 1
|
||||
fi
|
||||
elif [ "$#" -eq 1 ] && [ -d "$1" ]; then
|
||||
__zoxide_cd "$1"
|
||||
else
|
||||
__zoxide_result="$(zoxide query -- "$@")" && __zoxide_cd "$__zoxide_result"
|
||||
__zoxide_result="$(zoxide query -- "$@")" && __zoxide_cd "${__zoxide_result}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Jump to a directory using interactive search.
|
||||
__zoxide_zi() {
|
||||
__zoxide_result="$(zoxide query -i -- "$@")" && __zoxide_cd "$__zoxide_result"
|
||||
__zoxide_result="$(zoxide query -i -- "$@")" && __zoxide_cd "${__zoxide_result}"
|
||||
}
|
||||
|
||||
# Add a new entry to the database.
|
||||
|
Loading…
Reference in New Issue
Block a user