index.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. var fs = require('fs'),
  2. join = require('path').join,
  3. spec = join(__dirname, '..', 'fixtures', 'spec', 'spec');
  4. /**
  5. * Normalize CSS
  6. *
  7. * @param {String} css
  8. * @api public
  9. */
  10. module.exports.normalize = function(str) {
  11. return str.replace(/\s+/g, '').replace('{', '{\n').replace(';', ';\n');
  12. };
  13. /**
  14. * Get test suites
  15. *
  16. * @api public
  17. */
  18. module.exports.getSuites = function() {
  19. var ret = {};
  20. var suites = fs.readdirSync(spec);
  21. var ignoreSuites = [
  22. 'libsass-todo-issues',
  23. 'libsass-todo-tests'
  24. ];
  25. suites.forEach(function(suite) {
  26. if (ignoreSuites.indexOf(suite) !== -1) {
  27. return;
  28. }
  29. var suitePath = join(spec, suite);
  30. var tests = fs.readdirSync(suitePath);
  31. ret[suite] = {};
  32. tests.forEach(function(test) {
  33. var testPath = join(suitePath, test);
  34. ret[suite][test] = {};
  35. ret[suite][test].src = join(testPath, 'input.scss');
  36. ret[suite][test].expected = join(testPath, 'expected_output.css');
  37. ret[suite][test].paths = [
  38. testPath,
  39. join(testPath, 'sub')
  40. ];
  41. });
  42. });
  43. return ret;
  44. };