PRL-PRG / scalafix-rule-workshop

A framework repository to create and test scalafix rules
2 stars 0 forks source link

Add support for differentiating test and compile paths #56

Closed blorente closed 6 years ago

blorente commented 6 years ago

This extension to the pipeline adds two new commands, to be able to determine whether a file belongs to a test or compile artifact:

Implementation

It takes advantage of SBT's configurable source paths, requesting both test and compile paths, like so:

// At workshop
> show test:scalaSource
[info] coreutils/test:scalaSource
[info]  /home/borja/work/scala/workshop/core/src/test/scala
[info] macros/test:scalaSource
[info]  /home/borja/work/scala/workshop/macros/src/test/scala
[info] queries/test:scalaSource
[info]  /home/borja/work/scala/workshop/queries/src/test/scala
[info] implicitExtractor/test:scalaSource
[info]  /home/borja/work/scala/workshop/extractor/src/test/scala
[info] root/test:scalaSource
[info]  /home/borja/work/scala/workshop/src/test/scala

Then it uses a function to create an AWK script that will output the correct thing.

Possible changes

We might want to include all these metadata generations (sloc counts, classpath, this one...) in the same command as create_project_info, just for convenience. It may make things faster too, since we might save some SBT spinups.

We might want to separate paths by SBT projects. That can be done, and in fact, the first commits did it, but it didn't work in all cases and I ditched it for simplicity since we don't consider separate SBT projects anywhere else.