bmc / sbt-editsource

EditSource plugin for SBT
http://software.clapper.org/sbt-editsource/
Other
17 stars 4 forks source link

how to make editsource:edit to run before tests #9

Open max8github opened 8 years ago

max8github commented 8 years ago

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).

bmc commented 8 years ago

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

max8github commented 8 years ago

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 commented 8 years ago

(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)

bmc commented 6 years ago

With the latest version, this might work:

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