Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
yaniswang committed May 1, 2016
1 parent 8560332 commit 11d10aa
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 4 deletions.
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ language: node_js
node_js:
- "0.10"
- "0.12"
- "4.1"

- "4.x"
- "5.x"
- "6.x"

cache:
directories:
- node_modules

matrix:
fast_finish: true

script: "grunt"

after_success: istanbul-coveralls
after_success: istanbul-coveralls
34 changes: 34 additions & 0 deletions test/executable.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var expect = require('expect.js');

var ChildProcess = require('child_process');
var path = require('path');

describe('Executable', function () {
it('should close stream before exit', function (done) {
var c = ChildProcess.spawn('node', [path.resolve(__dirname,'../bin/htmlhint'), '--format', 'json', path.resolve(__dirname,'./html/executable.html')]);
var stdoutEnd = false;
var processEnd = false;
var isDone = 0;

function checkDone() {
isDone++;
if (isDone == 2) {
done();
}
}

c.stdout.on('close', function() {
stdoutEnd = true;
checkDone();
});

c.on('exit', function() {
processEnd = true;
checkDone();
});

c.stdout.on('data', function() {
expect(stdoutEnd || processEnd).to.be(false);
});
});
});
99 changes: 99 additions & 0 deletions test/html/executable.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div bad='' bad=''></div>
<div bad='' bad=''></div>
<div bad='' bad=''></div>
<div bad='' bad=''></div>
<div bad='' bad=''></div>
<div bad='' bad=''></div>
<div bad='' bad=''></div>
<div bad='' bad=''></div>
<div bad='' bad=''></div>
<div bad='' bad=''></div>
<div bad='' bad=''></div>
<div bad='' bad=''></div>
<div bad='' bad=''></div>
<div bad='' bad=''></div>
<div bad='' bad=''></div>
<div bad='' bad=''></div>
<div bad='' bad=''></div>
<input type="text"></input>
<div class"foo">

</div>
</div>
</hello>
</test>
</div>
<test>
<hello>
<div>
<div>
<div>
<div class='' what='' something=''></div>
</div>
</div>
</div>
</hello>
</test>
</div>
<test>
<hello>
<div>
<div>
<div>
<div class='' what='' something=''></div>
</div>
</div>
</div>
</hello>
</test>
</div>
<test>
<hello>
<div>
<div>
<div>
<div class='' what='' something=''></div>
</div>
</div>
</div>
</hello>
</test>
</div>
<test>
<hello>
<div>
<div>
<div>
<div class='' what='' something=''></div>
</div>
</div>
</div>
</hello>
</test>
</div>
</bad>
</bad>
</bad>
</bad>
</bad>
</bad>
</bad>
</bad>
</bad>
</bad>
</bad>
</bad>
</bad>
</bad>
</bad>
</bad>
</bad>
</body>
</html>

0 comments on commit 11d10aa

Please sign in to comment.