Comments (6)
I’ve just added a test for this issue, although note that the failure is not visible in the test itself but in the tests console log.
$ swift test
Test Suite 'All tests' started at 2017-02-11 11:35:35.082
Test Suite 'ProcessPackageTests.xctest' started at 2017-02-11 11:35:35.083
Test Suite 'ProcessTests' started at 2017-02-11 11:35:35.083
Test Case '-[ProcessTests.ProcessTests testICanEchoOnlyTheCommand]' started.
Test Case '-[ProcessTests.ProcessTests testICanEchoOnlyTheCommand]' passed (0.001 seconds).
Test Case '-[ProcessTests.ProcessTests testItCanEchoBackNothing]' started.
Test Case '-[ProcessTests.ProcessTests testItCanEchoBackNothing]' passed (0.000 seconds).
Test Case '-[ProcessTests.ProcessTests testItCanEchoBackTheCommandOnly]' started.
Test Case '-[ProcessTests.ProcessTests testItCanEchoBackTheCommandOnly]' passed (0.000 seconds).
Test Case '-[ProcessTests.ProcessTests testItDoesNotEchoIfEmpty]' started.
Test Case '-[ProcessTests.ProcessTests testItDoesNotEchoIfEmpty]' passed (0.000 seconds).
Test Case '-[ProcessTests.ProcessTests testItDryExecutesLS]' started.
Test Case '-[ProcessTests.ProcessTests testItDryExecutesLS]' passed (0.000 seconds).
Test Case '-[ProcessTests.ProcessTests testItEchosBackStdoutAndStderr]' started.
Test Case '-[ProcessTests.ProcessTests testItEchosBackStdoutAndStderr]' passed (0.000 seconds).
Test Case '-[ProcessTests.ProcessTests testItEchosStderrtOnly]' started.
Test Case '-[ProcessTests.ProcessTests testItEchosStderrtOnly]' passed (0.000 seconds).
Test Case '-[ProcessTests.ProcessTests testItEchosStdoOutOnly]' started.
Test Case '-[ProcessTests.ProcessTests testItEchosStdoOutOnly]' passed (0.000 seconds).
Test Case '-[ProcessTests.ProcessTests testItExecuteLS]' started.
Test Case '-[ProcessTests.ProcessTests testItExecuteLS]' passed (0.007 seconds).
Test Case '-[ProcessTests.ProcessTests testItExecutesACommanAndHandlesErrorsdWithDummyExecutor]' started.
Test Case '-[ProcessTests.ProcessTests testItExecutesACommanAndHandlesErrorsdWithDummyExecutor]' passed (0.000 seconds).
Test Case '-[ProcessTests.ProcessTests testItExecutesACommandWithDummyExecutor]' started.
Test Case '-[ProcessTests.ProcessTests testItExecutesACommandWithDummyExecutor]' passed (0.000 seconds).
Test Case '-[ProcessTests.ProcessTests testStrayOutput]' started.
/Users/sas/Projects/GitHub/Process/Tests/ProcessTests/ProcessTests.swift:179: error: -[ProcessTests.ProcessTests testStrayOutput] : XCTAssertEqual failed: ("Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
a���") is not equal to ("Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
") -
Test Case '-[ProcessTests.ProcessTests testStrayOutput]' failed (0.003 seconds).
Test Suite 'ProcessTests' failed at 2017-02-11 11:35:35.096.
Executed 12 tests, with 1 failure (0 unexpected) in 0.012 (0.013) seconds
Test Suite 'RunTests' started at 2017-02-11 11:35:35.096
Test Case '-[ProcessTests.RunTests testExample]' started.
RunResults(exitStatus: 127, stdout: "", stderr: "/bin/sh: rbenv: command not found\nnchd.3muIAnXsE")
Test Case '-[ProcessTests.RunTests testExample]' passed (0.003 seconds).
Test Suite 'RunTests' passed at 2017-02-11 11:35:35.099.
Executed 1 test, with 0 failures (0 unexpected) in 0.003 (0.003) seconds
Test Suite 'ProcessPackageTests.xctest' failed at 2017-02-11 11:35:35.099.
Executed 13 tests, with 1 failure (0 unexpected) in 0.015 (0.016) seconds
Test Suite 'All tests' failed at 2017-02-11 11:35:35.099.
Executed 13 tests, with 1 failure (0 unexpected) in 0.015 (0.017) seconds
Two things to note:
- the failure handler picks up stray characters
a��
- there’s an odd line
RunResults(exitStatus: 127, stdout: "", stderr: "/bin/sh: rbenv: command not found\nnchd.3muIAnXsE”)
in there that only appears when running this test and it’s picking up something from my shell.
from process.
The problem I’m having with this is that it’s not possible to reliably parse command output due to these stray characters appearing in the output.
from process.
@feinstruktur Thanks so much for the failing test, I think I caught the issue.
The string that I tried to read lacked the null termination, which meant String
was not able to figure where to terminate the string.
I am however not able to reproduce the issue on my machine, can you please try to apply the git diff attached here to your branch and see if it fixes it.
Please let me know if this fixes it :)
from process.
Yep, I think that did it and null termination was exactly what this looked like :) I've tried this in my project and I'm not getting the junk anymore.
I still see the stray line RunResults(exitStatus: 127, stdout: "", stderr: "/bin/sh: rbenv: command not found\n")
(now without the junk after the \n
) in the test result output but that might actually be genuine as a result of the forced test failure?
Thank for the quick fix!
from process.
I think that the \n is correct here.
Would you mind opening a PR to fix the issue?
(I could do it but copying the test from your PR looks kinda wrong :D)
from process.
from process.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from process.