Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow users to override the timeout #45

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shannmu
Copy link

@shannmu shannmu commented Aug 29, 2024

In a testing environment, exposing the timeout to users allows them to better configure their tests and avoid test failures caused by the built-in timeout being too short.

@epage epage changed the title refactor: Expose timeout setting to user feat: Allow users to override the timeout Aug 29, 2024
crates/completest-nu/src/lib.rs Fixed Show fixed Hide fixed
crates/completest-nu/src/lib.rs Fixed Show fixed Hide fixed
src/lib.rs Outdated
@@ -78,5 +80,5 @@ pub trait Runtime: std::fmt::Debug {
fn register(&mut self, name: &str, content: &str) -> std::io::Result<()>;

/// Get the output from typing `input` into the shell
fn complete(&mut self, input: &str, term: &Term) -> std::io::Result<String>;
fn complete(&mut self, input: &str, term: &Term, timout: Duration) -> std::io::Result<String>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like whether a timeout is needed or not is dependent on the needs of the individual runtime. Should this be a function on them instead?

@@ -164,7 +169,7 @@ pub struct BashRuntime {
path: OsString,
home: PathBuf,
config: PathBuf,
timeout: Duration,
_timeout: Duration,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we keep timeout on complete, why would we keep these timeouts?

@coveralls
Copy link

coveralls commented Aug 29, 2024

Pull Request Test Coverage Report for Build 10631733090

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 0.0%

Totals Coverage Status
Change from base Build 10604503481: 0.0%
Covered Lines: 0
Relevant Lines: 13

💛 - Coveralls

@epage
Copy link
Contributor

epage commented Aug 29, 2024

refactor: Expose timeout setting to user

Please update the name of the commit. A refactor is a restructuring of code and should never have a user-facing aspect to it.

Comment on lines +122 to +131
timeout: Duration,
) -> std::io::Result<String> {
let mut command = Command::new("zsh");
command.arg("--noglobalrcs");
command
.env("PATH", &self.path)
.env("TERM", "xterm")
.env("ZDOTDIR", &self.home);
let echo = false;
comptest(command, echo, input, term, self.timeout)
comptest(command, echo, input, term, timeout)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.timeout should be used

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants