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

Mark require-full-match as experimental #497

Merged
merged 4 commits into from
Jul 7, 2024

Conversation

max-sixty
Copy link
Sponsor Collaborator

@max-sixty max-sixty commented May 29, 2024

I did some more testing. There are some corner-cases where it doesn't work; for example if info is used it fails, because our serializer / deserializer doesn't roundtrip.

For example; from the insta tests, One is Map; the other a Struct:

[insta/src/snapshot.rs:440:20] self.metadata.trim_for_persistence() = MetaData {
    source: None,
    assertion_line: None,
    description: Some(
        "The snapshot is four integers",
    ),
    expression: None,
    info: Some(
        Map(
            [
                (
                    String(
                        "env",
                    ),
                    Map(
                        [
                            (
                                String(
                                    "ENVIRONMENT",
                                ),
                                String(
                                    "production",
                                ),
                            ),
                        ],
                    ),
                ),
                (
                    String(
                        "cmdline",
                    ),
                    Seq(
                        [
                            String(
                                "my-tool",
                            ),
                            String(
                                "run",
                            ),
                        ],
                    ),
                ),
            ],
        ),
    ),
    input_file: None,
}
[insta/src/snapshot.rs:441:24] other.metadata.trim_for_persistence() = MetaData {
    source: None,
    assertion_line: None,
    description: Some(
        "The snapshot is four integers",
    ),
    expression: None,
    info: Some(
        Struct(
            "Info",
            [
                (
                    "env",
                    Map(
                        [
                            (
                                String(
                                    "ENVIRONMENT",
                                ),
                                String(
                                    "production",
                                ),
                            ),
                        ],
                    ),
                ),
                (
                    "cmdline",
                    Seq(
                        [
                            String(
                                "my-tool",
                            ),
                            String(
                                "run",
                            ),
                        ],
                    ),
                ),
            ],
        ),
    ),
    input_file: None,
}

I did some more testing. There are some corner-cases where it doesn't work; for example if `info` is used it fails, because our serializer / deserializer isn't lossless.

For example; from the insta tests, One is `Map`; the other a `Struct`:

```
[insta/src/snapshot.rs:440:20] self.metadata.trim_for_persistence() = MetaData {
    source: None,
    assertion_line: None,
    description: Some(
        "The snapshot is four integers",
    ),
    expression: None,
    info: Some(
        Map(
            [
                (
                    String(
                        "env",
                    ),
                    Map(
                        [
                            (
                                String(
                                    "ENVIRONMENT",
                                ),
                                String(
                                    "production",
                                ),
                            ),
                        ],
                    ),
                ),
                (
                    String(
                        "cmdline",
                    ),
                    Seq(
                        [
                            String(
                                "my-tool",
                            ),
                            String(
                                "run",
                            ),
                        ],
                    ),
                ),
            ],
        ),
    ),
    input_file: None,
}
[insta/src/snapshot.rs:441:24] other.metadata.trim_for_persistence() = MetaData {
    source: None,
    assertion_line: None,
    description: Some(
        "The snapshot is four integers",
    ),
    expression: None,
    info: Some(
        Struct(
            "Info",
            [
                (
                    "env",
                    Map(
                        [
                            (
                                String(
                                    "ENVIRONMENT",
                                ),
                                String(
                                    "production",
                                ),
                            ),
                        ],
                    ),
                ),
                (
                    "cmdline",
                    Seq(
                        [
                            String(
                                "my-tool",
                            ),
                            String(
                                "run",
                            ),
                        ],
                    ),
                ),
            ],
        ),
    ),
    input_file: None,
}
```
@max-sixty max-sixty merged commit 3821022 into mitsuhiko:master Jul 7, 2024
12 checks passed
@max-sixty max-sixty deleted the require-full-match-exp branch July 7, 2024 20:05
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.

1 participant