зеркало из https://github.com/Azure/iisnode.git
functional test framework and first test
This commit is contained in:
Родитель
eec89e505b
Коммит
57a29c13bd
|
@ -6,4 +6,6 @@
|
|||
ipch/
|
||||
*.sln.cache
|
||||
*.suo
|
||||
*.user
|
||||
*.user
|
||||
log.out
|
||||
*.js.logs
|
|
@ -0,0 +1,58 @@
|
|||
@echo off
|
||||
|
||||
set appcmd=%systemroot%\system32\inetsrv\appcmd.exe
|
||||
set apppool=iisnodetest
|
||||
set site=iisnodetest
|
||||
set port=31415
|
||||
set node=%systemdrive%\node\node.exe
|
||||
set www=
|
||||
for /F %%I in ('dir /b /s %~dp0..\test.bat') do set www=%%~dI%%~pIwww
|
||||
if "%log%" equ "" set log="%~dp0log.out"
|
||||
|
||||
if not exist %node% (
|
||||
echo FAILED. The node.exe was not found at %node%. Download a copy from http://nodejs.org.
|
||||
exit /b -1
|
||||
)
|
||||
|
||||
if not exist %appcmd% (
|
||||
echo FAILED. The appcmd.exe IIS management tool was not found at %appcmd%. Make sure you have both IIS7 as well as IIS7 Management Tools installed.
|
||||
exit /b -1
|
||||
)
|
||||
|
||||
%appcmd% delete site %site% >> %log%
|
||||
if %ERRORLEVEL% neq 0 if %ERRORLEVEL% neq 1168 (
|
||||
echo FAILED. Cannot delete site %site%.
|
||||
exit /b -1
|
||||
)
|
||||
|
||||
%appcmd% delete apppool %apppool% >> %log%
|
||||
if %ERRORLEVEL% neq 0 if %ERRORLEVEL% neq 1168 (
|
||||
echo FAILED. Cannot delete application pool %apppool%.
|
||||
exit /b -1
|
||||
)
|
||||
|
||||
%appcmd% add apppool /name:%apppool% >> %log%
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo FAILED. Cannot create application pool %apppool%.
|
||||
exit /b -1
|
||||
)
|
||||
|
||||
%appcmd% add site /name:%site% /physicalPath:"%www%" /bindings:http/*:%port%: >> %log%
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo FAILED. Cannot create site %site%.
|
||||
exit /b -1
|
||||
)
|
||||
|
||||
%appcmd% set site %site% /[path='/'].applicationPool:%apppool% >> %log%
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo FAILED. Cannot configure site %site%.
|
||||
exit /b -1
|
||||
)
|
||||
|
||||
%appcmd% start site %site% >> %log%
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo FAILED. Cannot start site %site%.
|
||||
exit /b -1
|
||||
)
|
||||
|
||||
exit /b 0
|
|
@ -0,0 +1,74 @@
|
|||
@echo off
|
||||
setlocal
|
||||
|
||||
set log="%~dp0log.out"
|
||||
|
||||
date /T
|
||||
time /T
|
||||
date /T > %log%
|
||||
time /T >> %log%
|
||||
|
||||
call %~dp0scripts\setup.bat
|
||||
if %ERRORLEVEL% neq 0 exit /b -1
|
||||
|
||||
set testFilter=*
|
||||
if "%1" neq "" set testFilter=%1
|
||||
|
||||
dir /b %~dp0tests\%testFilter%.* 2> nul > nul
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo No tests names match the filter %testFilter%.
|
||||
exit /b -1
|
||||
)
|
||||
|
||||
set success=0
|
||||
set failure=0
|
||||
|
||||
for /f %%I in ('dir /b /a-d %~dp0tests\%testFilter%.*') do call :run_one %%I %%~xI
|
||||
|
||||
echo Total passed: %success%
|
||||
echo Total failed: %failure%
|
||||
echo ------------------------ >> %log%
|
||||
echo Total passed: %success% >> %log%
|
||||
echo Total failed: %failure% >> %log%
|
||||
|
||||
date /T
|
||||
time /T
|
||||
date /T >> %log%
|
||||
time /T >> %log%
|
||||
|
||||
if %failure% neq 0 exit /b -1
|
||||
|
||||
exit /b 0
|
||||
|
||||
:run_one
|
||||
|
||||
echo Running: %1...
|
||||
echo ------------------------ Running %1 >> %log%
|
||||
if "%2" equ ".js" (
|
||||
call :run_node_test %1
|
||||
) else (
|
||||
call "%~dp0tests\%1" >> %log% 2>>&1
|
||||
)
|
||||
|
||||
if %ERRORLEVEL% equ 0 (
|
||||
set /A success=success+1
|
||||
echo Passed: %1
|
||||
echo Passed: %1 >> %log%
|
||||
) else (
|
||||
set /A failure=failure+1
|
||||
echo Failed: %1
|
||||
echo Failed: %1 >> %log%
|
||||
)
|
||||
|
||||
exit /b 0
|
||||
|
||||
:run_node_test
|
||||
|
||||
%node% "%~dp0tests\%1" >> %log% 2>"%~dp0tests\%1.err"
|
||||
type "%~dp0tests\%1.err" >> %log%
|
||||
for /F %%A IN ('dir /s /b "%~dp0tests\%1.err"') do set size=%%~zA
|
||||
del /q "%~dp0tests\%1.err"
|
||||
if "%size%" neq "0" exit /b -1
|
||||
exit /b 0
|
||||
|
||||
endlocal
|
|
@ -0,0 +1,3 @@
|
|||
var iisnodeassert = require("iisnodeassert");
|
||||
|
||||
iisnodeassert.get("/100_helloworld/hello.js", 200, "Hello, world!");
|
|
@ -0,0 +1,47 @@
|
|||
var http = require("http");
|
||||
var assert = require("assert");
|
||||
|
||||
process.on('uncaughtException', function (err) {
|
||||
console.error(err);
|
||||
console.stdout.flush();
|
||||
console.stderr.flush();
|
||||
process.kill(process.pid);
|
||||
});
|
||||
|
||||
exports.get = function (path, expectedStatusCode, expectedBody) {
|
||||
var options = {
|
||||
host: "localhost",
|
||||
port: 31415,
|
||||
method: "GET",
|
||||
path: path,
|
||||
};
|
||||
|
||||
console.log("request options: " + JSON.stringify(options));
|
||||
|
||||
var request = http.request(options, function(res) {
|
||||
console.log("response status: " + res.statusCode);
|
||||
console.log("response headers: " + JSON.stringify(res.headers));
|
||||
|
||||
assert.equal(res.statusCode, expectedStatusCode, "response status code matches the expected response status code");
|
||||
|
||||
res.setEncoding("utf8");
|
||||
var body = "";
|
||||
res.on("data", function(chunk) {
|
||||
console.log("response body chunk: " + chunk);
|
||||
body += chunk;
|
||||
});
|
||||
res.on("end", function() {
|
||||
console.log("end of response");
|
||||
|
||||
assert.equal(body, expectedBody, "response body matches the expected response body");
|
||||
});
|
||||
});
|
||||
|
||||
request.on("error", function (e) {
|
||||
console.log("problem with request: " + e.message);
|
||||
|
||||
assert.ok(false, "response finished successfully");
|
||||
});
|
||||
|
||||
request.end();
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
var http = require('http');
|
||||
|
||||
http.createServer(function (req, res) {
|
||||
res.writeHead(200, {'Content-Type': 'text/plain'});
|
||||
res.end('Hello, world!');
|
||||
}).listen(process.env.PORT);
|
|
@ -0,0 +1,7 @@
|
|||
<configuration>
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="iisnode" path="hello.js" verb="*" modules="iisnode" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
|
@ -0,0 +1 @@
|
|||
pong
|
Загрузка…
Ссылка в новой задаче