kevoree-modeling / mwDB

Many-World Database repository
Apache License 2.0
11 stars 2 forks source link

Windows failed test #14

Open assaad opened 8 years ago

assaad commented 8 years ago

Failed tests: testReadFilesOnFile(org.mwg.ImporterTest): expected:<[/D:/workspace/mwDB/plugins/importer/target/test-classes/smarthome/]readme.md> but was:<[D:\workspace\mwDB\plugins\importer\target\test-classes\smarthome]readme.md>

gnain commented 8 years ago

So, the test does that:

URL urlFIle = this.getClass().getClassLoader().getResource("smarthome/readme.md");
readFiles(urlFIle.getPath()) [...]
String file = (String) context.result().get(0);
Assert.assertEquals(urlFIle.getPath(), file);

Thing is on windows,

File file = new File(URLDecoder.decode(urlFIle.getPath(), "UTF-8"));
file.getAbsolutePath() != urlFIle.getPath()

urlFIle.getPath() => /C:/Users/[...] file.getAbsolutePath() => C:\Users[...]

@lmouline If the file is resolved shouldn't we put the file object in the result rather than its absolute path ? I guess the user will then create again a new file object anyway ...

lmouline commented 8 years ago

Arf, I will fix the bug.

@gnain The goal of readFiles is to navigate in a folder. (Maybe the name is not really clear). If you want to read it there is readLines action and if you want to write in, I create a write action (not yet pushed). Thus, if you want to combine readLines and readFiles (for example to read some files in a directory) you will resolve the File in readLines actions. I just resolve it in 'readFiles' to check if it exists and get the sub files.

If we want pass the File object from readFiles to readLines, (just to resolve the object once) we also need to create/change a readLines action without parameters that take the previous results.

Because for now, if we do something like this:

readFiles(fildePath)
    .forEach(
         readLines("{{result}}")
         ...
     )

The File.toString() will be called, so we loose the benefit to store the File object.

For "optimization" we can do something like:

readFiles(fildePath)
    .forEach(
         readLines()
         ...
     )

Like that, we only open the File once :)