sbt-editsource icon indicating copy to clipboard operation
sbt-editsource copied to clipboard

how to make editsource:edit to run before tests

Open max8github opened this issue 8 years ago • 4 comments

After trying and re-trying , was not able to use this plugin to do token substitution before unit tests are run.

Maybe i am not using sbt well enough, but i was trying something as easy as:

test <<= (test in Test) dependsOn (edit in EditSource)

to make tests do their work after token resolution, but it does not work. Maybe i am missing something obvious, but it would still be great if this were in the instructions, i think, which i could add myself if so desired.

Please note that when i run sbt editsource:edit it does work: files under target are resolved.

But when i run sbt test, my unit tests fail: if i look into the target dir, the files that were correctly resolved by editsource:edit are now unresolved (they contain ${baseDirectory} strings inside them).

max8github avatar Apr 05 '16 23:04 max8github

I'll have to look into this one. I never intended this to be used during testing, but it's a reasonable request.

bmc avatar Apr 06 '16 00:04 bmc

Yes, that would be nice. I wish i could help right away, actually, but still have to learn a bit more on how to code sbt plugins and all.

(BTW, if i may ask: if you could share a tentative, rough and uncommitted time on when you could possibly get to it, please let me know: that will help me plan how to get over this problem in the short-medium term)

max8github avatar Apr 07 '16 17:04 max8github

(To give context to this, if you are interested, this is about setting up unit tests with an in-memory database like h2 or hsqldb. In either case, when i create a Connection object in unit tests, the url cannot contain a relative file path: Connection requires it to be absolute. So, if i want to save the url string in application.conf under source control, i must use ${baseDirectory} in it)

max8github avatar Apr 07 '16 17:04 max8github

With the latest version, this might work:

test in Test := ((test in Test) dependsOn (edit in EditSource)).value

bmc avatar Jan 07 '18 22:01 bmc