Skip to content

fix: Calculate the initial indent correctly in a couple edge cases. #45

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

Merged
merged 5 commits into from
Oct 25, 2024

Conversation

JeffFaer
Copy link
Collaborator

  1. When the first seen line is one of the group_prefixes.
  2. When the first seen line is another keep-sorted directive.

Idempotency output before this change:

$ go test ./...
?       github.com/google/keep-sorted   [no test files]
?       github.com/google/keep-sorted/cmd       [no test files]
--- FAIL: TestGoldens (0.66s)
    --- FAIL: TestGoldens/group (0.00s)
        --- FAIL: TestGoldens/group/group (0.66s)
            golden_test.go:105: keep-sorted diff on keep-sorted output (should be idempotent) (-want +got)
                  (
                        """
                        ... // 180 identical lines
                          case 5:
                          // keep-sorted-test end
                -           return 10
                          case 2:
                -           return 2;
                          case 4:
                +         case 6:
                +           return 10
                +           return 2;
                            return 4;
                -         case 6:
                            return 6;
                          // keep-sorted-test end
                        """
                  )
FAIL
FAIL    github.com/google/keep-sorted/goldens   0.686s
ok      github.com/google/keep-sorted/keepsorted        (cached)
FAIL

Also, check the git history to see how group.out evolved.

1. When the first seen line is one of the `group_prefixes`.
2. When the first seen line is another keep-sorted directive.

Idempotency output before this change:

```
$ go test ./...
?       github.com/google/keep-sorted   [no test files]
?       github.com/google/keep-sorted/cmd       [no test files]
--- FAIL: TestGoldens (0.66s)
    --- FAIL: TestGoldens/group (0.00s)
        --- FAIL: TestGoldens/group/group (0.66s)
            golden_test.go:105: keep-sorted diff on keep-sorted output (should be idempotent) (-want +got)
                  (
                        """
                        ... // 180 identical lines
                          case 5:
                          // keep-sorted-test end
                -           return 10
                          case 2:
                -           return 2;
                          case 4:
                +         case 6:
                +           return 10
                +           return 2;
                            return 4;
                -         case 6:
                            return 6;
                          // keep-sorted-test end
                        """
                  )
FAIL
FAIL    github.com/google/keep-sorted/goldens   0.686s
ok      github.com/google/keep-sorted/keepsorted        (cached)
FAIL
```

Also, check the git history to see how group.out evolved.
Copy link
Member

@KatrinaHoffert KatrinaHoffert left a comment

Choose a reason for hiding this comment

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

Good idea, that idempotency check.

@JeffFaer JeffFaer merged commit 3436ef5 into main Oct 25, 2024
5 checks passed
@JeffFaer JeffFaer deleted the jfaer/group_prefixes branch October 25, 2024 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants