coverage-map.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // node-tap test -> src coverage map
  2. // https://node-tap.org/coverage/
  3. export default function map(F) {
  4. let match;
  5. // unit/content/...
  6. match = F.match(/^test\/unit\/content\/(.*)$/);
  7. if (match) {
  8. const f = match[1];
  9. match = f.match(/^dependencies\/(.*)\.js$/);
  10. if (match) {
  11. return `src/content/dependencies/${match[1]}.js`;
  12. }
  13. }
  14. // unit/data/...
  15. match = F.match(/^test\/unit\/data\/(.*)$/);
  16. if (match) {
  17. const f = match[1];
  18. match = f.match(/^composite\/(.*)$/);
  19. if (match) {
  20. return `src/data/composite/${match[1]}`;
  21. }
  22. match = f.match(/^things\/(.*)\.js$/);
  23. if (match) {
  24. return `src/data/things/${match[1]}.js`;
  25. }
  26. match = f.match(/^cacheable-object\.js$/);
  27. if (match) {
  28. return `src/data/things/cacheable-object.js`;
  29. }
  30. match = f.match(/^(templateCompositeFrom|compositeFrom)\.js$/);
  31. if (match) {
  32. return `src/data/things/composite.js`;
  33. }
  34. }
  35. // unit/util/...
  36. match = F.match(/^test\/unit\/util\/(.*)$/);
  37. if (match) {
  38. const f = match[1];
  39. switch (f) {
  40. case 'html.js':
  41. return 'src/util/html.js';
  42. }
  43. }
  44. // snapshot/...
  45. match = F.match(/^test\/snapshot\/(.*)$/);
  46. if (match) {
  47. const f = match[1];
  48. match = f.match(/^(.*)\.js$/);
  49. if (match) {
  50. return `src/content/dependencies/${match[1]}.js`;
  51. }
  52. }
  53. return null;
  54. }