Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
09f3c2f1
Commit
09f3c2f1
authored
Nov 19, 2012
by
Brad Fitzpatrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
doc/articles/wiki: fix racy test
R=golang-dev, r CC=golang-dev
https://golang.org/cl/6853069
parent
e070aeae
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
8 deletions
+15
-8
doc/articles/wiki/get.go
doc/articles/wiki/get.go
+14
-5
doc/articles/wiki/test.bash
doc/articles/wiki/test.bash
+1
-3
No files found.
doc/articles/wiki/get.go
View file @
09f3c2f1
...
...
@@ -13,11 +13,13 @@ import (
"net/http"
"os"
"strings"
"time"
)
var
(
post
=
flag
.
String
(
"post"
,
""
,
"urlencoded form data to POST"
)
addr
=
flag
.
Bool
(
"addr"
,
false
,
"find open address and print to stdout"
)
wait
=
flag
.
Duration
(
"wait_for_port"
,
0
,
"if non-zero, the amount of time to wait for the address to become available"
)
)
func
main
()
{
...
...
@@ -37,12 +39,19 @@ func main() {
}
var
r
*
http
.
Response
var
err
error
loopUntil
:=
time
.
Now
()
.
Add
(
*
wait
)
for
{
if
*
post
!=
""
{
b
:=
strings
.
NewReader
(
*
post
)
r
,
err
=
http
.
Post
(
url
,
"application/x-www-form-urlencoded"
,
b
)
}
else
{
r
,
err
=
http
.
Get
(
url
)
}
if
err
==
nil
||
*
wait
==
0
||
time
.
Now
()
.
After
(
loopUntil
)
{
break
}
time
.
Sleep
(
100
*
time
.
Millisecond
)
}
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
...
...
doc/articles/wiki/test.bash
View file @
09f3c2f1
...
...
@@ -18,9 +18,7 @@ go build -o final-test.bin final-test.go
(
./final-test.bin
)
&
wiki_pid
=
$!
sleep
1
./get.bin http://
$addr
/edit/Test
>
test_edit.out
./get.bin
--wait_for_port
=
5s http://
$addr
/edit/Test
>
test_edit.out
diff
-u
test_edit.out test_edit.good
./get.bin
-post
=
body
=
some%20content http://
$addr
/save/Test
diff
-u
Test.txt test_Test.txt.good
...
...
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