less_test.js 815 B

1234567891011121314151617181920212223242526
  1. exports.compileLess = function(test){
  2. var grunt = require('grunt'),
  3. fs = require('fs'),
  4. jsdiff = require('diff'),
  5. t = test,
  6. filename = 'select2-bootstrap.css',
  7. patchfile = 'test/support/less.patch',
  8. child = grunt.util.spawn({
  9. cmd: 'lessc',
  10. args: ['--verbose', 'lib/build.less', 'tmp/'+filename]
  11. }, function() {
  12. var readFile = function(name) { return fs.readFileSync(name, {encoding: 'utf8'}) },
  13. orig = readFile(filename),
  14. generated = readFile('tmp/'+filename),
  15. patch = readFile(patchfile),
  16. diff = jsdiff.createPatch(filename, orig, generated);
  17. // Save the output for future tests.
  18. // fs.writeFileSync(patchfile, diff);
  19. t.equal(patch, diff);
  20. t.done();
  21. });
  22. };