Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
fetch
提交
47fc7d5a
F
fetch
项目概览
github
/
fetch
10 个月 前同步成功
通知
30
Star
25765
Fork
3216
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
fetch
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
47fc7d5a
编写于
3月 15, 2015
作者:
J
Joshua Peek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add script runner for saucelabs
上级
40da5ee5
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
197 addition
and
196 deletion
+197
-196
Makefile
Makefile
+1
-1
script/saucelabs
script/saucelabs
+11
-0
test/app.js
test/app.js
+0
-138
test/saucelabs.js
test/saucelabs.js
+46
-54
test/server.js
test/server.js
+139
-3
未找到文件。
Makefile
浏览文件 @
47fc7d5a
...
...
@@ -4,7 +4,7 @@ test: node_modules/ build lint
./script/test
saucelabs
:
build
node ./test/saucelabs.j
s
./script/saucelab
s
travis
:
lint test saucelabs
...
...
script/saucelabs
0 → 100755
浏览文件 @
47fc7d5a
#!/bin/bash
set
-e
port
=
8080
# Spin a test server in the background
node ./test/server.js
$port
&>/dev/null &
server_pid
=
$!
trap
"kill
$server_pid
"
INT EXIT
node ./test/saucelabs.js
"http://localhost:
$port
/test/test.html"
test/app.js
已删除
100755 → 0
浏览文件 @
40da5ee5
var
fs
=
require
(
'
fs
'
)
var
url
=
require
(
'
url
'
);
var
querystring
=
require
(
'
querystring
'
);
var
routes
=
{
'
/request
'
:
function
(
res
,
req
)
{
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
application/json
'
});
var
data
=
''
req
.
on
(
'
data
'
,
function
(
c
)
{
data
+=
c
})
req
.
on
(
'
end
'
,
function
()
{
res
.
end
(
JSON
.
stringify
({
method
:
req
.
method
,
url
:
req
.
url
,
headers
:
req
.
headers
,
data
:
data
}));
})
},
'
/hello
'
:
function
(
res
,
req
)
{
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
text/plain
'
,
'
X-Request-URL
'
:
'
http://
'
+
req
.
headers
.
host
+
req
.
url
});
res
.
end
(
'
hi
'
);
},
'
/hello/utf8
'
:
function
(
res
)
{
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
text/plain; charset=utf-8
'
});
// "hello"
var
buf
=
new
Buffer
([
104
,
101
,
108
,
108
,
111
]);
res
.
end
(
buf
);
},
'
/hello/utf16le
'
:
function
(
res
)
{
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
text/plain; charset=utf-16le
'
});
// "hello"
var
buf
=
new
Buffer
([
104
,
0
,
101
,
0
,
108
,
0
,
108
,
0
,
111
,
0
]);
res
.
end
(
buf
);
},
'
/binary
'
:
function
(
res
)
{
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
application/octet-stream
'
});
var
buf
=
new
Buffer
(
256
);
for
(
var
i
=
0
;
i
<
256
;
i
++
)
{
buf
[
i
]
=
i
;
}
res
.
end
(
buf
);
},
'
/redirect/301
'
:
function
(
res
)
{
res
.
writeHead
(
301
,
{
'
Location
'
:
'
/hello
'
});
res
.
end
();
},
'
/redirect/302
'
:
function
(
res
)
{
res
.
writeHead
(
302
,
{
'
Location
'
:
'
/hello
'
});
res
.
end
();
},
'
/redirect/303
'
:
function
(
res
)
{
res
.
writeHead
(
303
,
{
'
Location
'
:
'
/hello
'
});
res
.
end
();
},
'
/redirect/307
'
:
function
(
res
)
{
res
.
writeHead
(
307
,
{
'
Location
'
:
'
/hello
'
});
res
.
end
();
},
'
/redirect/308
'
:
function
(
res
)
{
res
.
writeHead
(
308
,
{
'
Location
'
:
'
/hello
'
});
res
.
end
();
},
'
/boom
'
:
function
(
res
)
{
res
.
writeHead
(
500
,
{
'
Content-Type
'
:
'
text/plain
'
});
res
.
end
(
'
boom
'
);
},
'
/empty
'
:
function
(
res
)
{
res
.
writeHead
(
204
);
res
.
end
();
},
'
/error
'
:
function
(
res
)
{
res
.
destroy
();
},
'
/form
'
:
function
(
res
)
{
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
text/plain
'
});
res
.
end
(
'
number=1&space=one+two&empty=&encoded=a%2Bb&
'
);
},
'
/json
'
:
function
(
res
)
{
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
application/json
'
});
res
.
end
(
JSON
.
stringify
({
name
:
'
Hubot
'
,
login
:
'
hubot
'
}));
},
'
/json-error
'
:
function
(
res
)
{
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
application/json
'
});
res
.
end
(
'
not json {
'
);
},
'
/cookie
'
:
function
(
res
,
req
)
{
var
setCookie
,
cookie
var
params
=
querystring
.
parse
(
url
.
parse
(
req
.
url
).
query
);
if
(
params
.
name
&&
params
.
value
)
{
setCookie
=
[
params
.
name
,
params
.
value
].
join
(
'
=
'
);
}
if
(
params
.
name
)
{
cookie
=
querystring
.
parse
(
req
.
headers
[
'
cookie
'
],
'
;
'
)[
params
.
name
];
}
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
text/plain
'
,
'
Set-Cookie
'
:
setCookie
});
res
.
end
(
cookie
);
},
'
/headers
'
:
function
(
res
)
{
res
.
writeHead
(
200
,
{
'
Date
'
:
'
Mon, 13 Oct 2014 21:02:27 GMT
'
,
'
Content-Type
'
:
'
text/html; charset=utf-8
'
});
res
.
end
();
}
};
var
types
=
{
js
:
'
application/javascript
'
,
css
:
'
text/css
'
,
html
:
'
text/html
'
,
txt
:
'
text/plain
'
};
module
.
exports
=
function
(
req
,
res
)
{
var
pathname
=
url
.
parse
(
req
.
url
).
pathname
;
var
route
=
routes
[
pathname
];
if
(
route
)
{
route
(
res
,
req
);
}
else
{
fs
.
readFile
(
__dirname
+
'
/..
'
+
pathname
,
function
(
err
,
data
)
{
if
(
err
)
{
res
.
writeHead
(
404
,
{
'
Content-Type
'
:
types
.
txt
});
res
.
end
(
'
Not Found
'
);
}
else
{
var
ext
=
(
pathname
.
match
(
/
\.([^\/]
+
)
$/
)
||
[])[
1
]
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
types
[
ext
]
||
types
.
txt
});
res
.
end
(
data
);
}
});
}
};
test/saucelabs.js
浏览文件 @
47fc7d5a
require
(
'
es6-promise
'
);
var
http
=
require
(
'
http
'
);
var
https
=
require
(
'
https
'
);
var
app
=
require
(
'
./app
'
);
function
fetchJSON
(
options
,
obj
)
{
var
data
=
JSON
.
stringify
(
obj
);
...
...
@@ -35,61 +34,54 @@ function wait(ms) {
});
}
var
server
=
http
.
createServer
(
app
);
server
.
on
(
'
listening
'
,
function
()
{
var
port
=
server
.
address
().
port
;
var
url
=
'
http://localhost:
'
+
port
+
'
/test/test.html
'
;
fetchJSON
({
method
:
'
POST
'
,
hostname
:
'
saucelabs.com
'
,
path
:
'
/rest/v1/
'
+
process
.
env
.
SAUCE_USERNAME
+
'
/js-tests
'
,
headers
:
{},
auth
:
process
.
env
.
SAUCE_USERNAME
+
'
:
'
+
process
.
env
.
SAUCE_ACCESS_KEY
},
{
'
build
'
:
process
.
env
.
TRAVIS_BUILD_NUMBER
,
'
tags
'
:
[
process
.
env
.
TRAVIS_PULL_REQUEST
,
process
.
env
.
TRAVIS_BRANCH
],
'
tunnel-identifier
'
:
process
.
env
.
TRAVIS_JOB_NUMBER
,
'
platforms
'
:
[[
process
.
env
.
SAUCE_PLATFORM
,
process
.
env
.
SAUCE_BROWSER
,
process
.
env
.
SAUCE_VERSION
]],
'
url
'
:
url
,
'
framework
'
:
'
qunit
'
}).
then
(
function
(
obj
)
{
function
check
()
{
return
fetchJSON
({
method
:
'
POST
'
,
hostname
:
'
saucelabs.com
'
,
path
:
'
/rest/v1/
'
+
process
.
env
.
SAUCE_USERNAME
+
'
/js-tests/status
'
,
headers
:
{},
auth
:
process
.
env
.
SAUCE_USERNAME
+
'
:
'
+
process
.
env
.
SAUCE_ACCESS_KEY
},
obj
).
then
(
function
(
obj
)
{
if
(
obj
.
completed
===
true
)
{
return
obj
;
}
else
{
return
wait
(
2
*
1000
).
then
(
check
);
}
});
}
return
Promise
.
race
([
check
(),
timeout
(
180
*
1000
)]);
}).
then
(
function
(
obj
)
{
var
test
=
obj
[
'
js tests
'
][
0
];
fetchJSON
({
method
:
'
POST
'
,
hostname
:
'
saucelabs.com
'
,
path
:
'
/rest/v1/
'
+
process
.
env
.
SAUCE_USERNAME
+
'
/js-tests
'
,
headers
:
{},
auth
:
process
.
env
.
SAUCE_USERNAME
+
'
:
'
+
process
.
env
.
SAUCE_ACCESS_KEY
},
{
'
build
'
:
process
.
env
.
TRAVIS_BUILD_NUMBER
,
'
tags
'
:
[
process
.
env
.
TRAVIS_PULL_REQUEST
,
process
.
env
.
TRAVIS_BRANCH
],
'
tunnel-identifier
'
:
process
.
env
.
TRAVIS_JOB_NUMBER
,
'
platforms
'
:
[[
process
.
env
.
SAUCE_PLATFORM
,
process
.
env
.
SAUCE_BROWSER
,
process
.
env
.
SAUCE_VERSION
]],
'
url
'
:
process
.
argv
[
2
],
'
framework
'
:
'
qunit
'
}).
then
(
function
(
obj
)
{
function
check
()
{
return
fetchJSON
({
method
:
'
POST
'
,
hostname
:
'
saucelabs.com
'
,
path
:
'
/rest/v1/
'
+
process
.
env
.
SAUCE_USERNAME
+
'
/js-tests/status
'
,
headers
:
{},
auth
:
process
.
env
.
SAUCE_USERNAME
+
'
:
'
+
process
.
env
.
SAUCE_ACCESS_KEY
},
obj
).
then
(
function
(
obj
)
{
if
(
obj
.
completed
===
true
)
{
return
obj
;
}
else
{
return
wait
(
2
*
1000
).
then
(
check
);
}
});
}
return
Promise
.
race
([
check
(),
timeout
(
180
*
1000
)]);
}).
then
(
function
(
obj
)
{
var
test
=
obj
[
'
js tests
'
][
0
];
console
.
log
(
test
.
url
);
console
.
log
(
test
.
platform
);
console
.
log
(
test
.
result
);
console
.
log
(
test
.
url
);
console
.
log
(
test
.
platform
);
console
.
log
(
test
.
result
);
var
passed
=
test
.
result
&&
(
typeof
test
.
result
===
'
object
'
)
&&
test
.
result
.
passed
===
test
.
result
.
total
;
var
passed
=
test
.
result
&&
(
typeof
test
.
result
===
'
object
'
)
&&
test
.
result
.
passed
===
test
.
result
.
total
;
if
(
!
passed
)
{
throw
'
tests failed
'
;
}
}).
then
(
function
()
{
server
.
close
();
global
.
process
.
exit
(
0
);
},
function
(
error
)
{
setImmediate
(
function
()
{
throw
error
;
});
if
(
!
passed
)
{
throw
'
tests failed
'
;
}
}).
then
(
function
()
{
server
.
close
();
global
.
process
.
exit
(
0
);
},
function
(
error
)
{
setImmediate
(
function
()
{
throw
error
;
});
});
server
.
listen
(
8080
);
test/server.js
浏览文件 @
47fc7d5a
#!/usr/bin/env node
var
port
=
Number
(
process
.
argv
[
2
]
||
3000
)
var
fs
=
require
(
'
fs
'
)
var
http
=
require
(
'
http
'
);
var
app
=
require
(
'
./app
'
);
var
url
=
require
(
'
url
'
);
var
querystring
=
require
(
'
querystring
'
);
var
routes
=
{
'
/request
'
:
function
(
res
,
req
)
{
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
application/json
'
});
var
data
=
''
req
.
on
(
'
data
'
,
function
(
c
)
{
data
+=
c
})
req
.
on
(
'
end
'
,
function
()
{
res
.
end
(
JSON
.
stringify
({
method
:
req
.
method
,
url
:
req
.
url
,
headers
:
req
.
headers
,
data
:
data
}));
})
},
'
/hello
'
:
function
(
res
,
req
)
{
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
text/plain
'
,
'
X-Request-URL
'
:
'
http://
'
+
req
.
headers
.
host
+
req
.
url
});
res
.
end
(
'
hi
'
);
},
'
/hello/utf8
'
:
function
(
res
)
{
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
text/plain; charset=utf-8
'
});
// "hello"
var
buf
=
new
Buffer
([
104
,
101
,
108
,
108
,
111
]);
res
.
end
(
buf
);
},
'
/hello/utf16le
'
:
function
(
res
)
{
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
text/plain; charset=utf-16le
'
});
// "hello"
var
buf
=
new
Buffer
([
104
,
0
,
101
,
0
,
108
,
0
,
108
,
0
,
111
,
0
]);
res
.
end
(
buf
);
},
'
/binary
'
:
function
(
res
)
{
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
application/octet-stream
'
});
var
buf
=
new
Buffer
(
256
);
for
(
var
i
=
0
;
i
<
256
;
i
++
)
{
buf
[
i
]
=
i
;
}
res
.
end
(
buf
);
},
'
/redirect/301
'
:
function
(
res
)
{
res
.
writeHead
(
301
,
{
'
Location
'
:
'
/hello
'
});
res
.
end
();
},
'
/redirect/302
'
:
function
(
res
)
{
res
.
writeHead
(
302
,
{
'
Location
'
:
'
/hello
'
});
res
.
end
();
},
'
/redirect/303
'
:
function
(
res
)
{
res
.
writeHead
(
303
,
{
'
Location
'
:
'
/hello
'
});
res
.
end
();
},
'
/redirect/307
'
:
function
(
res
)
{
res
.
writeHead
(
307
,
{
'
Location
'
:
'
/hello
'
});
res
.
end
();
},
'
/redirect/308
'
:
function
(
res
)
{
res
.
writeHead
(
308
,
{
'
Location
'
:
'
/hello
'
});
res
.
end
();
},
'
/boom
'
:
function
(
res
)
{
res
.
writeHead
(
500
,
{
'
Content-Type
'
:
'
text/plain
'
});
res
.
end
(
'
boom
'
);
},
'
/empty
'
:
function
(
res
)
{
res
.
writeHead
(
204
);
res
.
end
();
},
'
/error
'
:
function
(
res
)
{
res
.
destroy
();
},
'
/form
'
:
function
(
res
)
{
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
text/plain
'
});
res
.
end
(
'
number=1&space=one+two&empty=&encoded=a%2Bb&
'
);
},
'
/json
'
:
function
(
res
)
{
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
application/json
'
});
res
.
end
(
JSON
.
stringify
({
name
:
'
Hubot
'
,
login
:
'
hubot
'
}));
},
'
/json-error
'
:
function
(
res
)
{
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
application/json
'
});
res
.
end
(
'
not json {
'
);
},
'
/cookie
'
:
function
(
res
,
req
)
{
var
setCookie
,
cookie
var
params
=
querystring
.
parse
(
url
.
parse
(
req
.
url
).
query
);
if
(
params
.
name
&&
params
.
value
)
{
setCookie
=
[
params
.
name
,
params
.
value
].
join
(
'
=
'
);
}
if
(
params
.
name
)
{
cookie
=
querystring
.
parse
(
req
.
headers
[
'
cookie
'
],
'
;
'
)[
params
.
name
];
}
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
text/plain
'
,
'
Set-Cookie
'
:
setCookie
});
res
.
end
(
cookie
);
},
'
/headers
'
:
function
(
res
)
{
res
.
writeHead
(
200
,
{
'
Date
'
:
'
Mon, 13 Oct 2014 21:02:27 GMT
'
,
'
Content-Type
'
:
'
text/html; charset=utf-8
'
});
res
.
end
();
}
};
var
types
=
{
js
:
'
application/javascript
'
,
css
:
'
text/css
'
,
html
:
'
text/html
'
,
txt
:
'
text/plain
'
};
var
port
=
parseInt
(
process
.
argv
[
2
],
10
)
||
3000
;
http
.
createServer
(
app
).
listen
(
port
);
http
.
createServer
(
function
(
req
,
res
)
{
var
pathname
=
url
.
parse
(
req
.
url
).
pathname
;
var
route
=
routes
[
pathname
];
if
(
route
)
{
route
(
res
,
req
);
}
else
{
fs
.
readFile
(
__dirname
+
'
/..
'
+
pathname
,
function
(
err
,
data
)
{
if
(
err
)
{
res
.
writeHead
(
404
,
{
'
Content-Type
'
:
types
.
txt
});
res
.
end
(
'
Not Found
'
);
}
else
{
var
ext
=
(
pathname
.
match
(
/
\.([^\/]
+
)
$/
)
||
[])[
1
]
res
.
writeHead
(
200
,
{
'
Content-Type
'
:
types
[
ext
]
||
types
.
txt
});
res
.
end
(
data
);
}
});
}
}).
listen
(
port
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录