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

(BKR-1656) Fixes for cat and file_exist? on PSWindows #1654

Merged
merged 1 commit into from
Jun 3, 2020

Conversation

sebastian-miclea
Copy link
Contributor

@sebastian-miclea sebastian-miclea commented May 29, 2020

These changes are needed in order to have the same output when these methods are used on different platforms. The implementation for unix is slightly different and had a different return values.
Having the same return values for both unix and windows implementation will reduce the need to check which os you're running on when writing beaker tests.

file_exist? had a different output compared to the unix implementation (which returns bool). It actually returned the position of where it found the the match.

2.5.3 :001 > "true" =~ /true/
 => 0
2.5.3 :002 > "true" =~ /rue/
 => 1

cat had different output due to the fact that execute does not wrap the output in an Response object, but exec does.

@mihaibuzgau
Copy link
Contributor

Not taking into consideration the exit code of if exists seems that it does not impact the functionality.
Tests:
With directory that exists:

C:\Users\mitza>if exist C:\users echo true
true

C:\Users\mitza>echo %errorlevel%
0

With file that exists:

C:\Users\mitza>if exist C:\users\desktop.ini echo true
true

C:\Users\mitza>echo %errorlevel%
0

With directory or file that does not exist:

C:\Users\mitza>if exist C:\notexists echo true

C:\Users\mitza>echo %errorlevel%
0

relative path:

C:\Users\mitza>if exist notexists echo true

C:\Users\mitza>echo %errorlevel%
0

Characters that are not allowed in windows paths:

C:\Users\mitza>if exist <invalidwinpath echo true
< was unexpected at this time.

C:\Users\mitza>echo %errorlevel%
0

@mihaibuzgau mihaibuzgau merged commit d7c991f into voxpupuli:master Jun 3, 2020
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