Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
936a00a6
Commit
936a00a6
authored
Oct 15, 2013
by
Matthew Hooker
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #537 from mitchellh/fix507
provisioner/shell: fix EOF detection
parents
336d04cf
104f5049
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
12 deletions
+15
-12
provisioner/shell/unix_reader.go
provisioner/shell/unix_reader.go
+3
-0
provisioner/shell/unix_reader_test.go
provisioner/shell/unix_reader_test.go
+12
-12
No files found.
provisioner/shell/unix_reader.go
View file @
936a00a6
...
...
@@ -54,5 +54,8 @@ func (r *UnixReader) Read(p []byte) (n int, err error) {
// token returned will be "one\n".
func
scanUnixLine
(
data
[]
byte
,
atEOF
bool
)
(
advance
int
,
token
[]
byte
,
err
error
)
{
advance
,
token
,
err
=
bufio
.
ScanLines
(
data
,
atEOF
)
if
advance
==
0
{
return
}
return
advance
,
append
(
token
,
"
\n
"
...
),
err
}
provisioner/shell/unix_reader_test.go
View file @
936a00a6
...
...
@@ -18,24 +18,24 @@ func TestUnixReader(t *testing.T) {
input
:=
"one
\r\n
two
\n\r\n
three
\r\n
"
expected
:=
"one
\n
two
\n\n
three
\n
"
r
:=
&
UnixReader
{
Reader
:
bytes
.
NewReader
([]
byte
(
input
)),
}
result
:=
new
(
bytes
.
Buffer
)
if
_
,
err
:=
io
.
Copy
(
result
,
r
);
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
result
.
String
()
!=
expected
{
t
.
Fatalf
(
"bad: %#v"
,
result
.
String
())
}
unixReaderTest
(
t
,
input
,
expected
)
}
func
TestUnixReader_unixOnly
(
t
*
testing
.
T
)
{
input
:=
"
\n
one
\n\n
two
\n
three
\n\n
"
expected
:=
"
\n
one
\n\n
two
\n
three
\n\n
"
unixReaderTest
(
t
,
input
,
expected
)
}
func
TestUnixReader_readsLastLine
(
t
*
testing
.
T
)
{
input
:=
"one
\n
two"
expected
:=
"one
\n
two
\n
"
unixReaderTest
(
t
,
input
,
expected
)
}
func
unixReaderTest
(
t
*
testing
.
T
,
input
string
,
expected
string
)
{
r
:=
&
UnixReader
{
Reader
:
bytes
.
NewReader
([]
byte
(
input
)),
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment