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

[test/spec] Add test cases for unset, localvar and tempenv. #718

Merged
merged 2 commits into from
Apr 18, 2020

Conversation

akinomyoga
Copy link
Collaborator

Test cases for #706

@andychu
Copy link
Contributor

andychu commented Apr 18, 2020

Wow this is very comprehensive. I was thinking this file is more for idioms in real code, not synthetic test cases, but if you think it will come in handy it's OK.

However I did notice some failures on ash? Do you have this version?

andy@lisa:~/git/oilshell/oil2$ _deps/spec-bin/busybox 
BusyBox v1.31.1 (2020-04-18 02:00:51 PDT) multi-call binary.
BusyBox is copyrighted by many authors between 1998-2015.
Licensed under GPLv2. See source distribution for detailed
copyright notices.

The errors are in cases 14 and 15:

$ test/spec.sh ble-idioms -r 13-16
ble-idioms.test.sh
case    line    bash    zsh     mksh    ash     dash    yash    osh
 13     257     pass    ok      ok      ok      ok      pass    pass    [bash_unset] local-unset / dynamic-unset for tempenv
 14     290     BUG     ok      ok      FAIL    ok      ok      ok      [bash_unset] function call with tempenv vs tempenv-eval
 15     404     pass    ok      ok      FAIL    ok      ok      ok      [bash_unset] localvar-inherit from tempenv
 16     486     pass    pass    ok      ok      ok      ok      pass    [bash_unset] nested context by tempenv-eval

@andychu
Copy link
Contributor

andychu commented Apr 18, 2020

For case 14 it says this:

case: 14
[ash stdout] Expected '[global] v: global\n[global,local] v: (unset)\n[global,local+unset] v: (unset)\n[global,local+unlocal] v: (unset)\n[global,tempenv] v: tempenv\n[global,tempenv,local] v: tempenv\n[global,tempenv,local+unset] v: (uns
et)\n[global,tempenv,local+unlocal] v: (unset)\n[global,tempenv,(eval)] v: tempenv\n[global,tempenv,(eval),local] v: (unset)\n[global,tempenv,(eval),local+unset] v: (unset)\n[global,tempenv,(eval),local+unlocal] v: (unset)\n', got '[globa
l] v: global\n[global,local] v: global\n[global,local+unset] v: (unset)\n[global,local+unlocal] v: (unset)\n[global,tempenv] v: tempenv\n[global,tempenv,local] v: tempenv\n[global,tempenv,local+unset] v: (unset)\n[global,tempenv,local+unl
ocal] v: (unset)\n[global,tempenv,(eval)] v: tempenv\n[global,tempenv,(eval),local] v: tempenv\n[global,tempenv,(eval),local+unset] v: (unset)\n[global,tempenv,(eval),local+unlocal] v: (unset)\n'
ash stdout:
[global] v: global
[global,local] v: global
[global,local+unset] v: (unset)
[global,local+unlocal] v: (unset)
[global,tempenv] v: tempenv
[global,tempenv,local] v: tempenv
[global,tempenv,local+unset] v: (unset)
[global,tempenv,local+unlocal] v: (unset)
[global,tempenv,(eval)] v: tempenv
[global,tempenv,(eval),local] v: tempenv
[global,tempenv,(eval),local+unset] v: (unset)
[global,tempenv,(eval),local+unlocal] v: (unset)

@akinomyoga
Copy link
Collaborator Author

However I did notice some failures on ash? Do you have this version?

Oh, really. I'm using the same version...

[murase@chatoyancy 1 oilshell.oil]$ _deps/spec-bin/busybox
BusyBox v1.31.1 (2020-03-19 18:41:37 JST) multi-call binary.
BusyBox is copyrighted by many authors between 1998-2015.
Licensed under GPLv2. See source distribution for detailed
copyright notices.

(snip)

The output of test case 14 from my ash:

[global] v: global
[global,local] v: (unset)
[global,local+unset] v: (unset)
[global,local+unlocal] v: (unset)
[global,tempenv] v: tempenv
[global,tempenv,local] v: tempenv
[global,tempenv,local+unset] v: (unset)
[global,tempenv,local+unlocal] v: (unset)
[global,tempenv,(eval)] v: tempenv
[global,tempenv,(eval),local] v: (unset)
[global,tempenv,(eval),local+unset] v: (unset)
[global,tempenv,(eval),local+unlocal] v: (unset)

The output of test case 15 from my ash:

[global,(local)] v: (unset)
[global,tempenv,(local)] v: tempenv
[xglobal,(local)] v: (unset)
[global,(func),(local)] v: (unset)
[global,tempenv,(func),(local)] v: (unset)
[xglobal,(func),(local)] v: (unset)
[global,local,(func),(local)] v: (unset)

Can you test the following command?

$ _deps/spec-bin/busybox sh -c 'fn() { local v; echo "v: ${v-(unset)}"; }; v=global; fn'
v: (unset)

My system is Fedora 30

[murase@chatoyancy 1 oilshell.oil]$ uname -a
Linux chatoyancy 5.1.20-300.fc30.x86_64 #1 SMP Fri Jul 26 15:03:11 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
[murase@chatoyancy 1 oilshell.oil]$ cat /etc/redhat-release
Fedora release 30 (Thirty)

@akinomyoga
Copy link
Collaborator Author

I was thinking this file is more for idioms in real code, not synthetic test cases, but if you think it will come in handy it's OK.

OK! I created spec/ble-features.test.sh as suggested in #653 (comment) and moved these tests to that file!


I tried this command also with Linux busybox 1.28.3, Cygwin busybox 1.23.2, FreeBSD busybox 1.31.0 where the same result v: (unset) is reproduced.

$ busybox sh -c 'fn() { local v; echo "v: ${v-(unset)}"; }; v=global; fn'
v: (unset)

@andychu andychu merged commit cf98611 into oils-for-unix:master Apr 18, 2020
@andychu
Copy link
Contributor

andychu commented Apr 18, 2020

Ah OK there was a bug in the environment, leading me to run the wrong ash:

4e0002e

Passes now:

http://travis-ci.oilshell.org/jobs/2020-04-18__19-07-12.wwz/_tmp/spec/ble-features.html

Thanks!

@andychu
Copy link
Contributor

andychu commented Apr 19, 2020

OK no problem! I fixed it: 5753cba

@akinomyoga
Copy link
Collaborator Author

Thank you!

@akinomyoga akinomyoga deleted the tests-for-unset-tempenv branch April 19, 2020 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants