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: fix input tests with expect not covering false negatives #19518

Merged
merged 7 commits into from
Oct 10, 2023

Conversation

ttytm
Copy link
Member

@ttytm ttytm commented Oct 5, 2023

expect itself doesn't return an exit code based on whether the input is correct or not.
Therefore the current tests for command line input using expect will always return exit_code == 0.

The changes fix and extend the test coverage. They include tests that should fail, update towards being directory independent and using regular V tests.


Additional info that might save some time while testing/reviewing

Example to reproduce the issue locally at current master:

Current related CI for reference:

run: |
./v examples/password
./v examples/password/password_ci.vsh

To simplify the following steps move from your vroot into cd examples/password/ and comment out chdir in password_ci.vsh

// password_ci.vsh

// chdir('examples/password')!  // <- comment out 
assert execute('./correct.expect').exit_code == 0
assert execute('./incorrect.expect').exit_code == 0

Run the test v ./password_ci.vsh -> should pass.

Change an expected value in ./correct.expect. E.g.:

- expect "Enter your password : "
+ expect "Wrong Expect : "

Re-running the test v ./password_ci.vsh will also pass after a short timeout. But it should not pass 🧙🏽‍♂️.

@ttytm ttytm force-pushed the tests/fix-expect-usage branch 7 times, most recently from f93fecc to 70a4b53 Compare October 9, 2023 15:23
@ttytm ttytm changed the title tests: fix input tests with expect not covering false negatives test: fix input tests with expect not covering false negatives Oct 9, 2023
@spytheman spytheman merged commit c4ee940 into vlang:master Oct 10, 2023
28 checks passed
@ttytm ttytm deleted the tests/fix-expect-usage branch November 1, 2023 19:49
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