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

Support conditional test #36

Closed
edouard-lopez opened this issue Jan 11, 2019 · 7 comments
Closed

Support conditional test #36

edouard-lopez opened this issue Jan 11, 2019 · 7 comments
Labels
enhancement New feature or request

Comments

@edouard-lopez
Copy link
Contributor

edouard-lopez commented Jan 11, 2019

Pure support several version of fish (2.5 to 3.0.0). However some of our tests are only meaningful on some version of the platform.

To manage this we wrap those tests in a if…end block, e.g. _pure_prompt_ssh_host.test.fish:

if fish_version_at_least '3.0.0'
test "_pure_prompt_ssh_host: use native \$hostname"
    (
        set pure_color_ssh_host (set_color grey)

        _pure_prompt_ssh_host > /dev/null
    ) $status -eq 0
end
end

This work as expected but look messy, a decorator would be a lot more elegant, e.g.:

# fish_version_at_least 3.0.0
test "_pure_prompt_ssh_host: use native \$hostname"end
@jorgebucaran
Copy link
Owner

@edouard-lopez Is this related to #34?

@edouard-lopez
Copy link
Contributor Author

Nope, but that a feature request for next release 😛

@jorgebucaran
Copy link
Owner

@edouard-lopez Sure it isn't related? Why can't you do this:

if fish_version_at_least '3.0.0'
  test "_pure_prompt_ssh_host: use native \$hostname"
    (
        set pure_color_ssh_host (set_color grey)

        _pure_prompt_ssh_host > /dev/null
    ) $status -eq 0
  end
end

@edouard-lopez
Copy link
Contributor Author

That's what I do but I would prefer a decorator

@jorgebucaran
Copy link
Owner

@edouard-lopez I think I get it now. You are asking for a pre-processor feature to sieve out tests if they are above or below a specific fish version (or based on the status code after running some arbitrary function) and the proposed syntax is a comment.

@edouard-lopez
Copy link
Contributor Author

Correct.

@jorgebucaran
Copy link
Owner

jorgebucaran commented Jan 31, 2019

@edouard-lopez I don't think writing conditional tests like are commonplace enough to justify adding a new feature to Fishtape. Instead of adding a special feature for this, I suggest we use regular fish code:

if fish_version_equals_or_is_above 3.0.0
    @test "something" (
        actual operator expected
    )
end

@jorgebucaran jorgebucaran added Discussion enhancement New feature or request labels Jan 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants