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

Mock a command that's ran with command? #4

Open
dideler opened this issue Jun 15, 2017 · 2 comments
Open

Mock a command that's ran with command? #4

dideler opened this issue Jun 15, 2017 · 2 comments

Comments

@dideler
Copy link

dideler commented Jun 15, 2017

How would you mock a command that's ran with command?

Given a function that's under test

function foo
  command rm bar
  command ls
end

And you want to mock ls for example.

Doing mock ls 0 "echo foo" doesn't work, and mocking command is not possible because it's blacklisted.

@Markcial
Copy link
Owner

Markcial commented Jun 16, 2017

That is a good question, due to some limitations i am unable to mock some functions or commands, being command one of those.
Also I cannot mock the "runtime" created functions, so if you place a function inside your function in a nested scope, being that nested function the last one, it disables all the others.

I have to add some small features, like the possibility to use a custom function instead of a evaluated string, but other features might be a good call to arms if you want to help. Some help would be really nice.

If you have any idea or want to fiddle around and get in a point further where i did get i would be really grateful.

@dideler
Copy link
Author

dideler commented Jun 20, 2017

I see now why mock has a blacklist, because fish has reserved these names.

In fish 2.5.0 (but not 2.6.0 due to a regression), when you try to override a builtin

function: The name 'command' is reserved,
and can not be used as a function name

I'm not really sure how we can get around this limitation.

There used to be a --shadow-builtin option for functions but it was controversial and short-lived.

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

No branches or pull requests

2 participants