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

Missing $DIRNAME in fishtape 2.0.0 #39

Closed
edouard-lopez opened this issue Feb 8, 2019 · 6 comments
Closed

Missing $DIRNAME in fishtape 2.0.0 #39

edouard-lopez opened this issue Feb 8, 2019 · 6 comments
Labels
enhancement New feature or request

Comments

@edouard-lopez
Copy link
Contributor

edouard-lopez commented Feb 8, 2019

related: 2.0.0, #38


Thanks for the new release, I haven't made the switch yet, but look forward to it.

In the release note for 2.0.0 you mention removing $DIRNAME variable. That annoying, cause I'm using it a on every test files for pure to import function under test, like:

source $DIRNAME/../functions/_pure_prompt_first_line.fish

Sure it's possible to use $filename however such a name is prone to conflict and makes code a less readable:

source (dirname $filename)/../functions/_pure_prompt_first_line.fish

BATS as a series of special variables prefixed by $BATS_TEST_ (e.g. $BATS_TEST_DIRNAME).

I reckon namespacing is a must have, and would love to see dirname come back ❤️

Some namespace ideas:

$fishtape_test_dirname
$ft_test_dirname
$_test_dirname
@jorgebucaran
Copy link
Owner

jorgebucaran commented Feb 8, 2019

@edouard-lopez I disagree on code readability, but I'm curious to know how $filename is prone to conflicts? Recall that tests run in their own subshell.

Your source trick will not work, because $filename is really just the name, not the full path, so I'm positive about adding $dirname back.

$dirname/Users/foo/bar
$filenametest.fish

What about also?

$pathname/Users/foo/bar/test.fish

Too much? :)

@jorgebucaran jorgebucaran added the enhancement New feature or request label Feb 8, 2019
@edouard-lopez
Copy link
Contributor Author

Readability is not that bad indeed.

In several scripts I wrote, I rename files and use $filename as the variable name that contains the filename extracted from a path. Sure the subshell might prevent conflict, but shouldn't we know it's a fishtape variable and not one from our script?

I tend to prefer $filepath over $pathname.
To have both $dirname, $filename and $pathname seem a bit redundant.

@jorgebucaran
Copy link
Owner

@edouard-lopez Like this?

  • $fishtape_dirname/Users/foo/bar
  • $fishtape_filenametest.fish

Any ideas for more variables?

@edouard-lopez
Copy link
Contributor Author

LGTM.

No other requirement for me at the moment.

jorgebucaran added a commit that referenced this issue Feb 12, 2019
- Add new $current_dirname (and rename $filename to $current_file) #39
- Add ability to get the abutesol path from a given file, but without
  following symlinks (similar behavior as fish >=2.3 `realpath` and
  can eventually use that instead)
- Improve `@test` so it can be used to check if two array are equal
  or not (the downside is that test descriptions are now required)
- Reset $status to 0 after running `setup` function hook
@jorgebucaran
Copy link
Owner

Added in b195bc1 (here).

In the end I went with$current_dirname and $current_filename instead.

Release notes coming up later! 👋

@jorgebucaran
Copy link
Owner

Release Notes

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