phil-rice / cddcore

Constraint Driven Development
1 stars 0 forks source link

Home directory on MacOS #1

Open ahepworth opened 9 years ago

ahepworth commented 9 years ago

On initial run the JUnit directory created is placed in /Users/name/workspace/project/Users/name/.cdd/JUnit rather than /Users/name/.cdd (i.e. the tilde used to pick up user home directory is being appended to the pwd rather than replacing it).

phil-rice commented 9 years ago

The relevant lines are in org.cddcore.tests.CddRunner:

val userHome = System.getProperty("user.home"); var directory = new File(userHome, ".cdd")

So what was happening is that the java/mac integration decided that 'user.home' was in the place you specify

I've decided to change the default location to target/cdd from the 'current directory'. This seems in line with how SBT does things like this.

val userHome = System.getProperty("user.home"); var directory = new File("target", "cdd")

As I don't use a Mac could you check it works for you?

The new release is v 2.1.3.

ahepworth commented 9 years ago

Not fixed. And nothing to do with Java/Mac integration - it's a "proper" *nix platform after all...

It's the code in htmlRenderer that's not working. The URL created (and it should go via URI as toURL is deprecated) is file:/Users/name/workspace/project/target, but you strip "file:/" such that the filename is then missing it's preceding "/" so fails to be an absolute reference - hence I'm getting the html created in /Users/name/workspace/project/Users/name/workspace/project/target/cdd/JUnit/*.html but the individual URI references therein also appear to be absolute and perhaps shouldn't be and also appears to have a constructor problem (the double slash before JUnit) which could be avoided by relative references.

I'm guessing this is because windows constructs file URLs - incorrectly IMHO - as file:/C:\path\file which would clearly work when stripping the above because windows assumes drive: to be a root identifier, but wouldn't on any *nix platform.

(e.g. file:///Users/name/workspace/project/target/cdd//JUnit/Check_what_colour_to_make_the_car.EngineDescription.html could become "./Check_what_colour_to_make_the_car.EngineDescription.html which is simpler)

class FileReportWriter in htmlRendering/Report.scala is (I believe) the culprit. I'm happy with target being the created directory though as that seems the appropriate place. There's also userHome that can now be deleted to tidy things up too.

There's also quite a lot of image loading from remote internet sites which should be avoided - can we inline the images? I'll do a pull request and fix if you want, but you best understand the htmlRenderer.