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

fish_indent reformatting broke my fishtape tests #5399

Closed
edouard-lopez opened this issue Dec 10, 2018 · 2 comments
Closed

fish_indent reformatting broke my fishtape tests #5399

edouard-lopez opened this issue Dec 10, 2018 · 2 comments

Comments

@edouard-lopez
Copy link
Contributor

related: jorgebucaran/fishtape#32, swsnr/vscode-fish-ide#6


I'm using fish_indent through vscode-fish-ide which reformat test file as follows:

 test "set my_var default value"
-  'default_value' = (
+'default_value' = (
     __pure_set_default my_var 'default_value'
     echo $my_var
-  )
+    )
 end

After formatting my tests fails:

❯ fishtape tests/__pure_set_default.test.fish
TAP version 13
not ok 1 set my_var default valuedefault_value
  ---
    operator: fail
    expected: '= or !='
    received: '= default_value '
  ...
not ok 2 skip setting value if default already existsdefault_value
  ---
    operator: fail
    expected: '= or !='
    received: '= default_value '
  ...

Is it possible to extends fish_indent to support fishtape syntax?

@faho
Copy link
Member

faho commented Dec 10, 2018

There's a bit of a problem here. This isn't valid fishscript.

It looks like

test "inject autoloading in config"
    (
        pure::enable_autoloading >/dev/null
        grep -q 'fish_function_path' $HOME/.config/fish/config.fish
    ) $status -eq 0
end

and turns into

fishtape_test  "inject autoloading in config"    (
        pure::enable_autoloading >/dev/null
        grep -q 'fish_function_path' $HOME/.config/fish/config.fish
    ) $status -eq 0

	or set __fishtape_fails (math $__fishtape_fails + 1);    set __fishtape_count (math $__fishtape_count + 1)
fishtape_restore_globals
	if not teardown;        fishtape_error "teardown fail" status 0 $status;        fishtape_cleanup;        exit 1;    end
	if not setup;        fishtape_error "setup fail" status 0 $status;        fishtape_cleanup;        exit 1;    end

via a rather large awk script.

test already has a specific meaning in fish, and it does not start blocks. These files are not valid fish script, even if their names end in ".fish".


Honestly, I'd rather figure out a nicer way to write tests in fish-script than hack something like this, which overloads a rather important fish builtin (which we keyworded for 3.0 - not that it matters for fishtape, because that preprocesses the script using awk).

Our own test harness is probably a bit unwieldy, given that we require a ".in" file that includes the actual script to be run, and a ".out" and ".err" file for its stdout and stderr. We also don't ship it with a fish install, so it's not accessible to users.

@zanchey
Copy link
Member

zanchey commented Dec 11, 2018

To solve your root issue, save your fishtape scripts with a different extension. They aren't valid fish anyway.

@zanchey zanchey closed this as completed Dec 11, 2018
@zanchey zanchey added this to the will-not-implement milestone Dec 11, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants