global_test.go 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package internal_test
  2. import (
  3. "io/ioutil"
  4. "os"
  5. "path"
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. "gopkg.in/src-d/hercules.v10/internal/core"
  9. uast_items "gopkg.in/src-d/hercules.v10/internal/plumbing/uast"
  10. "gopkg.in/src-d/hercules.v10/internal/test"
  11. "gopkg.in/src-d/hercules.v10/leaves"
  12. )
  13. func TestPipelineSerialize(t *testing.T) {
  14. pipeline := core.NewPipeline(test.Repository)
  15. pipeline.SetFeature(uast_items.FeatureUast)
  16. pipeline.DeployItem(&leaves.BurndownAnalysis{})
  17. facts := map[string]interface{}{}
  18. facts[core.ConfigPipelineDryRun] = true
  19. tmpdir, _ := ioutil.TempDir("", "hercules-")
  20. defer os.RemoveAll(tmpdir)
  21. dotpath := path.Join(tmpdir, "graph.dot")
  22. facts[core.ConfigPipelineDAGPath] = dotpath
  23. pipeline.Initialize(facts)
  24. bdot, _ := ioutil.ReadFile(dotpath)
  25. dot := string(bdot)
  26. assert.Equal(t, `digraph Hercules {
  27. "6 BlobCache" -> "7 [blob_cache]"
  28. "9 FileDiff" -> "11 [file_diff]"
  29. "15 FileDiffRefiner" -> "16 Burndown"
  30. "0 IdentityDetector" -> "3 [author]"
  31. "8 RenameAnalysis" -> "16 Burndown"
  32. "8 RenameAnalysis" -> "9 FileDiff"
  33. "8 RenameAnalysis" -> "10 UAST"
  34. "8 RenameAnalysis" -> "13 UASTChanges"
  35. "1 TicksSinceStart" -> "4 [tick]"
  36. "2 TreeDiff" -> "5 [changes]"
  37. "10 UAST" -> "12 [uasts]"
  38. "13 UASTChanges" -> "14 [changed_uasts]"
  39. "3 [author]" -> "16 Burndown"
  40. "7 [blob_cache]" -> "16 Burndown"
  41. "7 [blob_cache]" -> "9 FileDiff"
  42. "7 [blob_cache]" -> "8 RenameAnalysis"
  43. "7 [blob_cache]" -> "10 UAST"
  44. "14 [changed_uasts]" -> "15 FileDiffRefiner"
  45. "5 [changes]" -> "6 BlobCache"
  46. "5 [changes]" -> "8 RenameAnalysis"
  47. "11 [file_diff]" -> "15 FileDiffRefiner"
  48. "4 [tick]" -> "16 Burndown"
  49. "12 [uasts]" -> "13 UASTChanges"
  50. }`, dot)
  51. }
  52. func TestPipelineSerializeNoUast(t *testing.T) {
  53. pipeline := core.NewPipeline(test.Repository)
  54. // pipeline.SetFeature(FeatureUast)
  55. pipeline.DeployItem(&leaves.BurndownAnalysis{})
  56. facts := map[string]interface{}{}
  57. facts[core.ConfigPipelineDryRun] = true
  58. tmpdir, _ := ioutil.TempDir("", "hercules-")
  59. defer os.RemoveAll(tmpdir)
  60. dotpath := path.Join(tmpdir, "graph.dot")
  61. facts[core.ConfigPipelineDAGPath] = dotpath
  62. pipeline.Initialize(facts)
  63. bdot, _ := ioutil.ReadFile(dotpath)
  64. dot := string(bdot)
  65. assert.Equal(t, `digraph Hercules {
  66. "6 BlobCache" -> "7 [blob_cache]"
  67. "9 FileDiff" -> "10 [file_diff]"
  68. "0 IdentityDetector" -> "3 [author]"
  69. "8 RenameAnalysis" -> "11 Burndown"
  70. "8 RenameAnalysis" -> "9 FileDiff"
  71. "1 TicksSinceStart" -> "4 [tick]"
  72. "2 TreeDiff" -> "5 [changes]"
  73. "3 [author]" -> "11 Burndown"
  74. "7 [blob_cache]" -> "11 Burndown"
  75. "7 [blob_cache]" -> "9 FileDiff"
  76. "7 [blob_cache]" -> "8 RenameAnalysis"
  77. "5 [changes]" -> "6 BlobCache"
  78. "5 [changes]" -> "8 RenameAnalysis"
  79. "10 [file_diff]" -> "11 Burndown"
  80. "4 [tick]" -> "11 Burndown"
  81. }`, dot)
  82. }
  83. func TestPipelineResolveIntegration(t *testing.T) {
  84. pipeline := core.NewPipeline(test.Repository)
  85. pipeline.DeployItem(&leaves.BurndownAnalysis{})
  86. pipeline.DeployItem(&leaves.CouplesAnalysis{})
  87. pipeline.Initialize(nil)
  88. }