jonsamwell/dart_gherkin

Feature files not retrieved when they are not within or aside working directory

kchiron opened this issue · 0 comments

Hi,

We are using same feature files for several testing frameworks including dart_gherkins so those files are on a different level than the dart working directory :

- marvelous-project/
        - features/
              - peanut.feature
              - banana.feature
        - dart_testing_fwk_folder
              - dart/
                    - test/
                    - ...
                    - pubspec.yml
        - another_testing_fwk
        - agin_another_testing_fwk

We set the following TestConfiguration:

return TestConfiguration()
    ..features = [Glob( '*.feature')]
    ..featureFileMatcher = IoFeatureFileAccessor(
        workingDirectory: Directory(Directory.current.path + "/../../features"))
    ..featureFileReader = IoFeatureFileAccessor(
        workingDirectory: Directory(Directory.current.path + "/../../features"))

We validated the current directory is dart and not testso the path from dart to features folder is correct.

After investigation, we found out that only the relative path of files matching the featureFileMatcher was stored :

Future<List<String>> _directoryContents(
    Directory directory,
    Pattern pattern,
  ) async {
    [...]
          final match = pattern.matchAsPrefix(relativePath);
          if (match?.group(0) == relativePath) {
            result.add(relativePath);
          }
    [...]
    return result;
  }

So only peanut.feature was returned and not its full path.

I've tried to modify this little line like this and it resolved my issue :

Future<List<String>> _directoryContents(
    Directory directory,
    Pattern pattern,
  ) async {
    [...]
          final match = pattern.matchAsPrefix(relativePath);
          if (match?.group(0) == relativePath) {
            result.add(item.path);
          }
    [...]
    return result;
  }

I've opened a pull request to fix this point :).
Thank you!