zunit-zsh / zunit

A powerful testing framework for ZSH projects
https://zunit.xyz
MIT License
208 stars 23 forks source link

'Assertion world does not exist' is not empty #107

Closed psprint closed 5 years ago

psprint commented 5 years ago

The CI checks currently fail with error:

✘ Test _zunit_assert_contains match

  'Assertion world does not exist' is not empty

The test that it refers is:

@test 'Test _zunit_assert_contains match' {
  run assert 'hello world' contains 'lo wo'

  assert "$output" is_empty
  assert $state equals 0
}

It seems that somehow the second word of the string "hello world" is taken for a name of the assertion to run. What could be causing this?

psprint commented 5 years ago

Ah, this is the problem with the complex commands patch, I'll take a look into this

psprint commented 5 years ago

The problem was the extendedglob option, which I was setting in ~/.zshenv, and which was missing outside my box.

molovo commented 5 years ago

@psprint do you think it would be worth disabling the option within the ZUnit code before the Eval, and then restore the previous state after the Eval is run? This is quite a common option (I use it myself) so I can see quite a few people running into this issue and it's not very obvious that that is the cause

Thanks for finding it by the way, it's been annoying me for weeks!

molovo commented 5 years ago

@psprint I see you've already done that. Nice job

psprint commented 5 years ago

I didn't do the option saving & restoration before & after eval. It is indeed worth doing. I'm thinking about incorporating zplugin's tracking & unloading code, although in a much simplified form: to restore the state recorded before the eval, not to compare for differences and withdraw them.