forked from lix-project/lix
SourceExprCommand: swallow EvalError, add tests for this
Completing things that would error would print an ugly error in the middle of your command line. Avoid printing this error.
This commit is contained in:
parent
444af85552
commit
16f1720fd2
|
@ -207,6 +207,7 @@ Strings SourceExprCommand::getDefaultFlakeAttrPathPrefixes()
|
|||
|
||||
void SourceExprCommand::completeInstallable(std::string_view prefix)
|
||||
{
|
||||
try {
|
||||
if (file) {
|
||||
completionType = ctAttrs;
|
||||
|
||||
|
@ -257,6 +258,10 @@ void SourceExprCommand::completeInstallable(std::string_view prefix)
|
|||
getDefaultFlakeAttrPaths(),
|
||||
prefix);
|
||||
}
|
||||
} catch (EvalError& e) {
|
||||
// swallow eval error
|
||||
(void)e;
|
||||
}
|
||||
}
|
||||
|
||||
void completeFlakeRefWithFragment(
|
||||
|
|
|
@ -28,6 +28,10 @@ cat <<EOF > bar/flake.nix
|
|||
};
|
||||
}
|
||||
EOF
|
||||
mkdir -p err
|
||||
cat <<EOF > err/flake.nix
|
||||
throw "error"
|
||||
EOF
|
||||
|
||||
# Test the completion of a subcommand
|
||||
[[ "$(NIX_GET_COMPLETIONS=1 nix buil)" == $'normal\nbuild\t' ]]
|
||||
|
@ -60,3 +64,5 @@ NIX_GET_COMPLETIONS=3 nix build --option allow-import-from | grep -- "allow-impo
|
|||
# Attr path completions
|
||||
[[ "$(NIX_GET_COMPLETIONS=2 nix eval ./foo\#sam)" == $'attrs\n./foo#sampleOutput\t' ]]
|
||||
[[ "$(NIX_GET_COMPLETIONS=4 nix eval --file ./foo/flake.nix outp)" == $'attrs\noutputs\t' ]]
|
||||
[[ "$(NIX_GET_COMPLETIONS=4 nix eval --file ./err/flake.nix outp 2>&1)" == $'attrs' ]]
|
||||
[[ "$(NIX_GET_COMPLETIONS=2 nix eval ./err\# 2>&1)" == $'attrs' ]]
|
||||
|
|
Loading…
Reference in a new issue