Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: test file generator #11

Merged
merged 7 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feat: comment out puzzle tests at the start
avoid false negatives
  • Loading branch information
S-ecki committed Dec 2, 2023
commit c8189ab17c6f7c3cf8cd34f94227a243d4f7e737
9 changes: 6 additions & 3 deletions day_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,14 @@ import '../solutions/day$day.dart';

// *******************************************************************
// Fill out the variables below according to the puzzle description!
// The test code should usually not need to be changed.
// The test code should usually not need to be changed, apart from uncommenting
// the puzzle tests for regression testing.
// *******************************************************************

/// Paste in the small example that is given for the FIRST PART of the puzzle.
/// It will be evaluated again the `_exampleSolutionPart1` below.
/// Make sure to respect the multiline string format to avoid additional
/// newlines at the end.
const _exampleInput1 = \'''
\''';

Expand Down Expand Up @@ -174,8 +177,8 @@ void main() {
'Day $day - Puzzle Input',
() {
final day = Day$day();
test('Part 1', () => expect(day.solvePart1(), _puzzleSolutionPart1));
test('Part 2', () => expect(day.solvePart2(), _puzzleSolutionPart2));
// test('Part 1', () => expect(day.solvePart1(), _puzzleSolutionPart1));
// test('Part 2', () => expect(day.solvePart2(), _puzzleSolutionPart2));
},
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep the Puzzle Input group commented out by default to prevent the tests from failing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Else the test suite would still fail until you provide the _puzzleSolutionPart1 and _puzzleSolutionPart2 variables and make it less clear that your solution worked.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point! Pushed the changes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could be a bit more "smart" about it and skip the test if the solution hasn't been filled in:

const _puzzleSolutionPart1 = null;
const _puzzleSolutionPart2 = null;

group(
    'Day 01 - Puzzle Input',
    () {
      final day = Day01();
      test(
        'Part 1',
        skip: _puzzleSolutionPart1 == null
            ? 'Skipped because _puzzleSolutionPart1 is null'
            : false,
        () => expect(day.solvePart1(), _puzzleSolutionPart1),
      );
      test(
        'Part 1',
        skip: _puzzleSolutionPart2 == null
            ? 'Skipped because _puzzleSolutionPart2 is null'
            : false,
        () => expect(day.solvePart1(), _puzzleSolutionPart2),
      );
    },
  );

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is perfect! I will add and commit it! 🚀
Was also thinking about skipping the tests without touching the actual test code, but stopped at the thought of a shouldTest boolean set by the user 😅
Thanks a lot! 💙

}
Expand Down
3 changes: 1 addition & 2 deletions utils/input_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ class InputUtil {
/// xtwone3four
/// 4nineeightseven2
/// zoneight234
/// 7pqrstsixteen
/// ''');
/// 7pqrstsixteen''');
/// final lines = input.getPerLine();
InputUtil.fromMultiLineString(String input)
: _inputAsString = input,
Expand Down