Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify Common Test Fixture Properties (Note Possible API Changes) #4038

Merged
merged 6 commits into from
Jan 11, 2024

Conversation

DavidBakerEffendi
Copy link
Collaborator

Two main groups of properties are commonly duplicated among test fixtures:

  • Dataflow processing with custom semantic definitions
  • Post processing passes

This PR uses a combination of traits and new additions to TestCpg to improve the re-usability and consistency of these among frontend fixtures.

I leave it up to the authors of the frontends to refactor these changes in each test suite.themselves. The result is that all test fixtures include the options for

.withOssDataflow(Boolean)
.withExtraFlows(List[FlowSemantic])
.withPostProcessingPasses(Boolean)

Misc: Added a fix for #4019

Two main groups of properties are commonly duplicated among test fixtures:
* Dataflow processing with custom semantic definitions
* Post processing passes

This PR uses a combination of traits and new additions to `TestCpg` to improve the re-usability and consistency of these among frontend fixtures.

I leave it up to the authors of the frontends to refactor these changes in each test suite.themselves.

Misc: Added a fix for #4019
@DavidBakerEffendi DavidBakerEffendi added infrastructure Modifications to build systems, CI/CD, or design frontends Relates to the shared x2cpg class labels Jan 10, 2024
@DavidBakerEffendi DavidBakerEffendi self-assigned this Jan 10, 2024
@@ -1,6 +1,6 @@
name := "dataflowengineoss"

dependsOn(Projects.semanticcpg, Projects.x2cpg)
dependsOn(Projects.semanticcpg, Projects.x2cpg % "compile->compile;test->test")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dependsOn(Projects.semanticcpg, Projects.x2cpg % "compile->compile;test->test")
dependsOn(Projects.semanticcpg, Projects.x2cpg, Projects.x2cpg % "test->test")

The ; separator led to problems with intellij in the past - splitting them up was the fix back then. Not sure if the problem still exists, but better play it safe.

Just noticed that this occurs in other places again - I'll send a PR for that after this is merged.

@@ -1,6 +1,6 @@
name := "c2cpg"

dependsOn(Projects.semanticcpg, Projects.dataflowengineoss % Test, Projects.x2cpg % "compile->compile;test->test")
dependsOn(Projects.semanticcpg, Projects.dataflowengineoss % "compile->compile;test->test", Projects.x2cpg % "compile->compile;test->test")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, but feel free to keep as is, I'll clean this up after this PR is in

extraFlows: List[FlowSemantic] = List.empty,
enableTypeRecovery: Boolean = false
) extends Code2CpgFixture(() =>
new JavaSrcTestCpg(enableTypeRecovery).withOssDataflow(withOssDataflow).withExtraFlows(extraFlows)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting formatting... did scalafmt come up with that? in that case we need to update our config i guess... :)


implicit val resolver: ICallResolver = NoResolve
implicit lazy val engineContext: EngineContext = EngineContext()
new DefaultTestCpgWithRuby(packageTable, useDeprecatedFrontend)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, strange indentation, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it is pretty strange agreed

@DavidBakerEffendi
Copy link
Collaborator Author

It seems in some frontends, post-processing and data-flow are not commutative, and thus the order of operations need to be specific. The result is that SemanticTestCpg does not override applyPasses anymore and simply exposes applyOssDataflow

@DavidBakerEffendi DavidBakerEffendi linked an issue Jan 11, 2024 that may be closed by this pull request
@DavidBakerEffendi DavidBakerEffendi merged commit 7860be9 into master Jan 11, 2024
5 checks passed
@DavidBakerEffendi DavidBakerEffendi deleted the dave/unify-test-fixtures branch January 11, 2024 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontends Relates to the shared x2cpg class infrastructure Modifications to build systems, CI/CD, or design
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] DotNetAstGen binary gets killed instantly on MacOS
3 participants