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(amber): normalise line endings between os #377

Merged
merged 14 commits into from
Oct 27, 2020
Merged

Conversation

iamogbz
Copy link
Collaborator

@iamogbz iamogbz commented Oct 14, 2020

Description

  • Run tests on windows

Related Issues

Checklist

  • This PR has sufficient documentation.
  • This PR has sufficient test coverage.
  • This PR title satisfies semantic convention.

Additional Comments

Exposing the windows runner for debugging

  debug:
    name: Debug
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v1
      - name: Set up Python 3.8
        uses: actions/setup-python@v1
        with:
          python-version: 3.8
      - name: Start SSH Session
        uses: luchihoratiu/debug-via-ssh@v1.0
        with:
          NGROK_AUTH_TOKEN: ${{ secrets.DEBUG_NGROK_TOKEN }}
          SSH_PASS: ${{ secrets.DEBUG_SSH_PASSWORD }}

@codecov
Copy link

codecov bot commented Oct 14, 2020

Codecov Report

Merging #377 into master will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #377   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           19        19           
  Lines          992      1005   +13     
=========================================
+ Hits           992      1005   +13     

tasks.py Show resolved Hide resolved
Comment on lines +109 to +112
After serializing, new line control characters are normalised. This is needed
for interoperablity of snapshot matching between systems that do not use the
same new line control characters. Example snapshots generated on windows os
should not break when running the tests on a unix based system and vice versa.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Worth calling out as effectively snapshots will never show a control character mismatch.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm okay with this, however it's a breaking change.

Copy link
Collaborator Author

@iamogbz iamogbz Oct 27, 2020

Choose a reason for hiding this comment

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

Now I'm thinking since it's a breaking change how about we roll our own line end character for amber files; i.e. \r and \n get translated into ambr specific values e.g.

assert "a\rb\r\nc\nd" == snapshot
  '
  a␍
  b␍␤
  c␤
  '

Copy link
Collaborator

Choose a reason for hiding this comment

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

We'd then switch to byte mote for reading/writing the snapshots?

Carriage return vs. Newline doesn't happen too frequently, and I find it does make it a bit harder to read the raw snapshot file that way (mainly due to the introduction of "noise")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This would be a wider sweeping change though, than currently where only a few files need be updated

@iamogbz iamogbz marked this pull request as ready for review October 27, 2020 04:42
@iamogbz iamogbz requested a review from noahnu October 27, 2020 04:42
@iamogbz iamogbz added the infrastructure CI and release pipeline label Oct 27, 2020
.github/workflows/pythonapp.yml Show resolved Hide resolved
src/syrupy/__init__.py Outdated Show resolved Hide resolved
src/syrupy/__init__.py Outdated Show resolved Hide resolved
src/syrupy/__init__.py Outdated Show resolved Hide resolved
src/syrupy/__init__.py Show resolved Hide resolved
src/syrupy/extensions/amber/serializer.py Show resolved Hide resolved
Comment on lines +109 to +112
After serializing, new line control characters are normalised. This is needed
for interoperablity of snapshot matching between systems that do not use the
same new line control characters. Example snapshots generated on windows os
should not break when running the tests on a unix based system and vice versa.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm okay with this, however it's a breaking change.

src/syrupy/extensions/amber/serializer.py Outdated Show resolved Hide resolved
@noahnu
Copy link
Collaborator

noahnu commented Oct 27, 2020

Going to test this out on an internal repo.

LGTM

Copy link
Collaborator

@noahnu noahnu left a comment

Choose a reason for hiding this comment

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

LGTM

Make sure to mark as a breaking change. Might also be worth adding a note to the readme explaining how line endings are handled?

@iamogbz iamogbz changed the title ci: run tests in windows env feat(amber): normalise line endings between os Oct 27, 2020
@iamogbz iamogbz merged commit 82b624d into master Oct 27, 2020
@iamogbz iamogbz deleted the ci-windows-tests branch October 27, 2020 15:27
syrupy-bot pushed a commit that referenced this pull request Oct 27, 2020
# [0.8.0](v0.7.2...v0.8.0) (2020-10-27)

### Features

* **amber:** normalise line endings between operating systems ([#377](#377)) ([82b624d](82b624d))
@syrupy-bot
Copy link
Contributor

🎉 This PR is included in version 0.8.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure CI and release pipeline released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test syrupy in windows environment
3 participants