Skip to content

Can’t get simple zsh completion to work #6

Closed
@adaszko

Description

@adaszko

Hi 👋

I’m on macOS, trying to write a simple test case. This just outputs a bunch of files from the current directory, not bar, as it should have. When I source the completion script from the shell, it works fine.

    #[test]
    fn completest_reduction() {
        let script = r#"
#compdef foo

_foo () {
    compadd bar
    return 0
}
compdef _foo foo
"#;
        let term = completest::Term::new();
        let mut runtime = completest::ZshRuntime::new(PathBuf::from_str("/opt/homebrew/bin/zsh").unwrap(), PathBuf::from_str("./completest-temporary-directory").unwrap()).unwrap();
        runtime.register("foo", &script).unwrap();
        let output = runtime.complete("foo \t", &term).unwrap();
        dbg!(output);
    }
    Running unittests src/main.rs (target/debug/deps/complgen-fd528e5e370143a6)

running 1 test
[src/zsh.rs:404] output = "adaszko@pryk complgen % foo\nCONTRIBUTING.md                  e2e/                             psql.usage\nCargo.lock                       examples/                        psql.zsh\nCargo.toml                       help.usage                       pytest.ini\nLICENSE                          help.zsh                         run-e2e-tests.bash*\nREADME.md                        lsof.bash                        src/\nassets/                          lsof.zsh                         strace.fish\ncapture_postamble.zsh            my.bash                          strace.usage\ncapture_preamble.zsh             my.fish                          strace.zsh\ncargo.fish                       my.usage                         target/\ncompletest-temporary-directory/  my.zsh                           usage/\ndfa.dot                          pgservice.conf                   venv/\ndfa.svg                          proptest-regressions/"
test zsh::tests::completest_reduction ... ok

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions