Skip to content

Commit 7db5326

Browse files
authored
Merge pull request #39 from tesuji/pure-shells
fix completion tests on github actions
2 parents 32b5da3 + 98bbf70 commit 7db5326

File tree

1 file changed

+12
-2
lines changed
  • crates/completest-pty/src

1 file changed

+12
-2
lines changed

crates/completest-pty/src/lib.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl ZshRuntime {
7474
let config_path = home.join(".zshenv");
7575
let config = "\
7676
fpath=($fpath $ZDOTDIR/zsh)
77-
autoload -U +X compinit && compinit
77+
autoload -U +X compinit && compinit -u # bypass compaudit security checking
7878
precmd_functions=\"\" # avoid the prompt being overwritten
7979
PS1='%% '
8080
PROMPT='%% '
@@ -170,17 +170,22 @@ impl BashRuntime {
170170
std::fs::create_dir_all(&home)?;
171171

172172
let config_path = home.join(".bashrc");
173+
let inputrc_path = home.join(".inputrc");
173174
let config = "\
174175
PS1='% '
175176
. /etc/bash_completion
176177
"
177178
.to_owned();
178179
std::fs::write(config_path, config)?;
180+
// Ignore ~/.inputrc which may set vi edit mode.
181+
std::fs::write(
182+
inputrc_path,
183+
"# expected empty file to disable loading ~/.inputrc\n",
184+
)?;
179185

180186
Self::with_home(bin_root, home)
181187
}
182188

183-
/// Reuse an existing runtime's home
184189
/// Reuse an existing runtime's home
185190
pub fn with_home(bin_root: PathBuf, home: PathBuf) -> std::io::Result<Self> {
186191
let config_path = home.join(".bashrc");
@@ -211,8 +216,10 @@ PS1='% '
211216
/// Get the output from typing `input` into the shell
212217
pub fn complete(&mut self, input: &str, term: &Term) -> std::io::Result<String> {
213218
let mut command = Command::new("bash");
219+
let inputrc_path = self.home.join(".inputrc");
214220
command
215221
.env("PATH", &self.path)
222+
.env("INPUTRC", &inputrc_path)
216223
.args([OsStr::new("--rcfile"), self.config.as_os_str()]);
217224
let echo = !input.contains("\t\t");
218225
comptest(command, echo, input, term, self.timeout)
@@ -311,8 +318,11 @@ end;
311318
/// Get the output from typing `input` into the shell
312319
pub fn complete(&mut self, input: &str, term: &Term) -> std::io::Result<String> {
313320
let mut command = Command::new("fish");
321+
// fish requires TERM to be set.
322+
let env_term = std::env::var_os("TERM").unwrap_or_else(|| "dumb".into());
314323
command
315324
.env("PATH", &self.path)
325+
.env("TERM", &env_term)
316326
.env("XDG_CONFIG_HOME", &self.home);
317327
let echo = false;
318328
comptest(command, echo, input, term, self.timeout)

0 commit comments

Comments
 (0)