Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/test-dart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,17 @@ jobs:
- name: Install dependencies
run: dart pub get --enforce-lockfile

- name: Install coverage tools
run: dart pub global activate coverage 1.15.0

- name: Verify formatting
run: dart format --output=none --set-exit-if-changed .

- name: Analyze
run: dart analyze

- name: Test
run: dart test
- name: Test & validate coverage
run: dart pub global run coverage:test_with_coverage --fail-under 60

- name: Run acceptance tests
run: make acceptance
Expand Down
4 changes: 4 additions & 0 deletions dart/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ acceptance/

# Directory created by dartdoc
doc/api/

# Directory created by dart test --coverage
coverage/

*.iml
1 change: 1 addition & 0 deletions dart/dialects_builtin.g.dart.jq
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def dialect_body:

"// GENERATED FILE - DO NOT MODIFY BY HAND\n"
+ "// dart format off\n"
+ "// coverage:ignore-file\n"
+ "\n"
+ "import 'package:cucumber_gherkin/src/language/gherkin_language_keywords.dart';\n"
+ "\n"
Expand Down
1 change: 1 addition & 0 deletions dart/gherkin-dart.razor
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
// [Berp](https://github.com/gasparnagy/berp) using the shared `../gherkin.berp`
// grammar.
// dart format off
// coverage:ignore-file
import 'dart:collection';

import 'package:cucumber_gherkin/src/exceptions/exceptions.dart';
Expand Down
23 changes: 8 additions & 15 deletions dart/lib/src/compile_pickles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ messages.PickleStep _pickleStep(
return messages.PickleStep(
id: idGenerator(),
text: _interpolate(step.text, variableCells, valueCells),
type: _pickleStepType(keywordType),
type: _pickleStepTypes[keywordType],
argument: _pickleStepArgument(step, variableCells, valueCells),
astNodeIds: astNodeIds,
);
Expand Down Expand Up @@ -290,17 +290,10 @@ messages.StepKeywordType _effectiveKeywordType(
return current;
}

messages.PickleStepType? _pickleStepType(messages.StepKeywordType keywordType) {
switch (keywordType) {
case messages.StepKeywordType.context:
return messages.PickleStepType.context;
case messages.StepKeywordType.action:
return messages.PickleStepType.action;
case messages.StepKeywordType.outcome:
return messages.PickleStepType.outcome;
case messages.StepKeywordType.unknown:
return messages.PickleStepType.unknown;
case messages.StepKeywordType.conjunction:
return null;
}
}
const Map<messages.StepKeywordType, messages.PickleStepType> _pickleStepTypes =
<messages.StepKeywordType, messages.PickleStepType>{
messages.StepKeywordType.context: messages.PickleStepType.context,
messages.StepKeywordType.action: messages.PickleStepType.action,
messages.StepKeywordType.outcome: messages.PickleStepType.outcome,
messages.StepKeywordType.unknown: messages.PickleStepType.unknown,
};
3 changes: 0 additions & 3 deletions dart/lib/src/generate_messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ List<messages.Envelope> generateMessages(
e.errors.map((error) => _parseErrorEnvelope(error, source.uri)),
);
return result;
} on ParserException catch (e) {
result.add(_parseErrorEnvelope(e, source.uri));
return result;
}

final gherkinDocumentWithUri = messages.GherkinDocument(
Expand Down
1 change: 1 addition & 0 deletions dart/lib/src/language/dialects_builtin.g.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// GENERATED FILE - DO NOT MODIFY BY HAND
// dart format off
// coverage:ignore-file

import 'package:cucumber_gherkin/src/language/gherkin_language_keywords.dart';

Expand Down
1 change: 1 addition & 0 deletions dart/lib/src/parser/parser.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// [Berp](https://github.com/gasparnagy/berp) using the shared `../gherkin.berp`
// grammar.
// dart format off
// coverage:ignore-file
import 'dart:collection';

import 'package:cucumber_gherkin/src/exceptions/exceptions.dart';
Expand Down
31 changes: 31 additions & 0 deletions dart/test/generate_messages_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,35 @@ void main() {
expect(envelopes.single.parseError, isNotNull);
expect(envelopes.single.parseError!.source.uri, 'broken.feature');
});

test('maps several parser errors onto individual parseError envelopes', () {
final envelopes = generateMessages(
'oops one\n'
'\n'
'Feature: f\n'
'\n'
' Scenario: s\n'
' Given a step\n'
'\n'
'oops two\n',
'multi.feature',
const GherkinOptions(includeSource: false),
);

expect(envelopes.length, greaterThan(1));
expect(envelopes.every((envelope) => envelope.parseError != null), isTrue);
expect(envelopes.first.parseError!.source.uri, 'multi.feature');
});

test('preserves comments in a document without a feature', () {
final envelopes = generateMessages(
'# a standalone comment\n',
'empty.feature',
);

expect(envelopes, hasLength(2));
final document = envelopes.last.gherkinDocument!;
expect(document.feature, isNull);
expect(document.comments.single.text, '# a standalone comment');
});
}