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

Add smoke tests #52

Closed
wants to merge 1 commit into from
Closed

Add smoke tests #52

wants to merge 1 commit into from

Conversation

Raigen
Copy link
Contributor

@Raigen Raigen commented Mar 10, 2018

Run babel-upgrade against a couple of repositories.

  • babel-preset-env on a babel 6 branch for babel options in package.json.
  • screeps-flowtype-jest-skeleton for correct flow handling.
  • react-side-effect for mocha.opts handling.

Fixes #22

Run babel-upgrade against a couple of repositories.
* babel-preset-env on a babel 6 branch for babel options in package.json.
* screeps-flowtype-jest-skeleton for correct flow handling.
* react-side-effect for mocha.opts handling.
@Raigen
Copy link
Contributor Author

Raigen commented Mar 10, 2018

I am not sure if we really need or want the full diff. Upgrade methods are handled by seperate tests and some not babel related lines are changed too.
Like this

+@@ -33 +38,3 @@
+-    \\"setupFiles\\": [\\"./etc/jestsetup.js\\"],
++    \\"setupFiles\\": [
++      \\"./etc/jestsetup.js\\"
++    ],

With git diff --raw we would get this snapshot

// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`smoke tests babel-preset-env 1`] = `
":100644 100644 cafdc8a 0000000 M	package.json
"
`;

exports[`smoke tests react-side-effect 1`] = `
":100644 100644 f940c90 0000000 M	.babelrc
:100644 100644 ef1db4c 0000000 M	package.json
:100644 100644 cb6872d 0000000 M	test/mocha.opts
"
`;

exports[`smoke tests screeps-flowtype-jest-skeleton 1`] = `
":100644 100644 5788e0a 0000000 M	.babelrc
:100644 100644 867dd23 0000000 M	package.json
"
`;

const crossSpawn = require('cross-spawn');
const rimraf = require('rimraf');

async function gitCheckout(dir, repo, branch = 'master') {
Copy link
Member

@noahlemen noahlemen Mar 10, 2018

Choose a reason for hiding this comment

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

should we check out a specific commit hash? will the snapshots need updating whenever the remote repo's branches are updated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In case of babel-preset-env we have a specific branch. For the two others I was not able to directly clone from a tag or commit, that is why I fall back to master for now. There is no other branch I could use. I am open to any suggestion making this more reliable.
But clone without --single-branch is taking much longer, so I decided against a full clone and checkout of a tag or commit.

Maybe a specific repo just for this purpose with all cases would be better in the long run.

Copy link
Member

@noahlemen noahlemen Mar 10, 2018

Choose a reason for hiding this comment

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

ohhh i see -- you're saying that we can't clone a specific commit so easily because we would need to first clone the repo before being able to check out the commit, and that takes too long?

could we use the -n flag on the initial clone to prevent the initial checkout, and then run git checkout <some-commit-hash>?

that's my best idea for now at cloning a specific commit efficiently

otherwise, perhaps we could fork the test repos and clone the forks? 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Since this is an upgrade tool it doesn't make sense to have a test against master of a repo unless we cloned or just copy the contents as a fixture and then you wouldn't need to close it anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just figured out that you can provide git clone --branch with a tag too. Would this be sufficient?
We just would need a good flowtype repo with tags and/or branches to clone since the one I use right now does not provide any of those.

@hzoo You mean we copy the files that matter for babel-upgrade into a directory below fixtures? We then would have to git reset --hard that directory after we ran babel-upgrade because we do not want to accidentally commit those changes when running it locally. That could become a problem on itself since you Cannot do hard reset with paths. as git phrases it.
Or we copy them from fixtures into a temporary directory, run the tests there and delete it afterwards like I do right now.

Copy link
Member

Choose a reason for hiding this comment

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

yeah, i think that would be sufficient -- with the caveat that it limits us to testing repos that are using tags, i suppose

agree with @hzoo that perhaps we don't need to bother with cloning at all. maybe this is a case where the proposed "dry run" mode could be justified? #6

alternatively, yes, i think copying them into a temp directory could work

@noahlemen noahlemen added tests enhancement New feature or request labels Mar 10, 2018
@noahlemen noahlemen mentioned this pull request Mar 19, 2018
@Raigen Raigen closed this Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a smoke test
3 participants