Content-Length: 298051 | pFad | https://github.com/starship/starship/issues/4121

44 fix(timings): count time spent on custom on 'when' command failure by majutsushi · Pull Request #4121 · starship/starship · GitHub
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

fix(timings): count time spent on custom on 'when' command failure #4121

Merged
merged 1 commit into from
Jul 8, 2022

Conversation

majutsushi
Copy link
Contributor

@majutsushi majutsushi commented Jun 27, 2022

Description

Return a Module instance with timing information for custom modules even if the when execution returns false.

Motivation and Context

Closes #4093.
Previously the custom module evaluation function would return early if the when execution returned false, but the timing information was only added when returning a module instance at the end of the function. This meant that slow when commands would invisibly slow down the prompt. This change causes the function to not return early in this case and instead return a proper module instance with timing information whether or not the when command indicates that the module should be shown.

How Has This Been Tested?

  • I have tested using MacOS
  • I have tested using Linux
  • I have tested using Windows

I tested this manually with the custom command I described in #4093. I wasn't sure whether I should add a test since it would probably need to have small sleep in it, which isn't ideal for unit tests. I did run the existing tests though.

Checklist:

  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.

@majutsushi
Copy link
Contributor Author

I don't know why the diff looks so weird, I just wrapped the rest of the function in an if which only changed the indentation.

@majutsushi
Copy link
Contributor Author

I had a quick look at testing since I realized that it wouldn't actually be necessary to sleep in a test, but currently the tests are purely based on checking the output, so to be able to verify that a module is returned that contains a duration but no output would require some test refactoring.

@davidkna davidkna changed the title fix: Count time spent on custom 'when' commands fix(timings): count time spent on custom on 'when' command failure Jul 5, 2022
@davidkna davidkna merged commit aae1ed0 into starship:master Jul 8, 2022
@davidkna
Copy link
Member

davidkna commented Jul 8, 2022

Thanks for handling this @majutsushi.

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.

Custom module 'when' execution time not counted if it returns an error
2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/starship/starship/issues/4121

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy