File tree Expand file tree Collapse file tree
semanticcpg-tests/src/test/scala/io/shiftleft/semanticcpg/testfixtures Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package io .shiftleft .semanticcpg .testfixtures
2+
3+ import java .io .File
4+
5+ import io .shiftleft .codepropertygraph .Cpg
6+ import io .shiftleft .semanticcpg .layers .{LayerCreatorContext , Scpg }
7+ import io .shiftleft .semanticcpg .testfixtures .LanguageFrontend .FuzzycFrontend
8+ import org .scalatest .BeforeAndAfterAll
9+ import org .scalatest .matchers .should .Matchers
10+ import org .scalatest .wordspec .AnyWordSpec
11+
12+ class CodeDirToCpgFixture extends AnyWordSpec with Matchers with BeforeAndAfterAll {
13+
14+ val dir : java.io.File = null
15+ var cpg : Cpg = _
16+ val frontend : LanguageFrontend = new FuzzycFrontend
17+ def passes (cpg : Cpg ): Unit = createEnhancements(cpg)
18+
19+ override def beforeAll (): Unit = {
20+ buildCpgForDir(dir)
21+ }
22+
23+ def createEnhancements (cpg : Cpg ): Unit = {
24+ val context = new LayerCreatorContext (cpg)
25+ new Scpg ().run(context)
26+ }
27+
28+ private def buildCpgForDir [T ](dir : File ): Unit = {
29+ cpg = frontend.execute(dir)
30+ passes(cpg)
31+ }
32+
33+ override def afterAll (): Unit = {
34+ cpg.close()
35+ }
36+
37+ }
You can’t perform that action at this time.
0 commit comments