-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
60 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
language: node_js | ||
node_js: | ||
- 0.11 | ||
- 0.10 | ||
script: | ||
- npm run lint | ||
- npm run test | ||
- 0.12 | ||
before_install: | ||
- sudo add-apt-repository ppa:ondrej/php5-oldstable --yes | ||
- sudo apt-get update -y | ||
- sudo apt-get install php5 -y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
var assert = require('should'); | ||
var jphps = require('../.'); | ||
var fs = require('fs'); | ||
var util = require('util'); | ||
|
||
/** | ||
* 清除 \r,为兼容 Windows 下的文本换行符 CRLF | ||
*/ | ||
function cleanCRLF(text) { | ||
return String(text).replace(/\r\n?/g, '\n'); | ||
} | ||
|
||
// coverage | ||
jphps.build(); | ||
jphps.build('\r'); | ||
|
||
function fixture(name) { | ||
return fs.readFileSync('test/fixtures/' + name, 'utf8').replace(/\r/g, ''); | ||
} | ||
|
||
describe('fixtures', function() { | ||
var items = fs.readdirSync('test/fixtures').filter(function(item) { | ||
return /\.input\.html$/.test(item); | ||
}).map(function(item) { | ||
return item.replace(/\.input\.html$/, ''); | ||
}); | ||
|
||
items.forEach(function(item) { | ||
var output_php = util.format('test/fixtures/%s.output.php', item); | ||
var text_input_html = cleanCRLF(fs.readFileSync(util.format('test/fixtures/%s.input.html', item))); | ||
var text_output_html = cleanCRLF(fs.readFileSync(util.format('test/fixtures/%s.output.html', item))); | ||
var text_output_php = cleanCRLF(fs.readFileSync(output_php)); | ||
it(item, function() { | ||
assert.equal(text_output_php, jphps.build(text_input_html)); | ||
}); | ||
it(item + ' run()', function(done) { | ||
var exec = require("child_process").exec; | ||
exec(util.format('php "%s"', output_php), function (error, stdout, stderr) { | ||
assert.equal(error, null); | ||
assert.equal(text_output_html, stdout); | ||
done(); | ||
}); | ||
}) | ||
}); | ||
}); |