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 a command to use master version of elm-explorations/test #592

Merged
merged 23 commits into from
Jun 6, 2022
Merged

Add a command to use master version of elm-explorations/test #592

merged 23 commits into from
Jun 6, 2022

Conversation

Janiczek
Copy link
Contributor

@Janiczek Janiczek commented May 10, 2022

This is based on a discussion in the Incremental Elm #elm-test Discord channel.

The intent is to allow people to help us beta-test the elm-explorations/test 2.0.0 release and use the master version of elm-explorations/test on their codebases (masqueraded as the 1.2.2 version).

cc @harrysarson

vid.mp4

@Janiczek
Copy link
Contributor Author

From Discord:

I think we should use a different elm home but is not a strong feeling

I think there's a lot of other small things to think about, like more alerting color for the warning, and cross-compatible ways to do the shell commands, description of the flag, etc...

@gampleman
Copy link
Contributor

I wonder if this could even take an argument, so that it could be used to test locally other branches?

@Janiczek
Copy link
Contributor Author

@gampleman My initial assumption when hearing @harrysarson's idea was that this would later be reverted, and not a long-term flag. If it was to be longterm, I agree customizing it could be a nice addition.

lib/Install.js Outdated Show resolved Hide resolved
lib/Install.js Outdated Show resolved Hide resolved
lib/Install.js Outdated Show resolved Hide resolved
@Janiczek
Copy link
Contributor Author

Janiczek commented May 11, 2022

I've incorporated your feedback @lydell although I'm sure my implementation will need some more improvements. It works on my Mac machine but I haven't tried the tar "Windows" path.

Copy link
Collaborator

@lydell lydell left a comment

Choose a reason for hiding this comment

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

TODO:

  • Make CI pass
  • Test manually on Windows (I think spawn.sync throws an error rather than returning a non-zero exit code if unzip does not exist). EDIT: No, the approach with the exit codes works, at least on macOS. So it’s just about verifying that it works on Windows.

lib/Install.js Outdated Show resolved Hide resolved
lib/elm-test.js Outdated Show resolved Hide resolved
lib/elm-test.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@harrysarson harrysarson left a comment

Choose a reason for hiding this comment

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

I am happy to delegate detail review to others, the shape of this PR looks great!

Given this is a tool to test the new elm-explorations which should be uniform across platforms (its elm) I would think we need windows support (although it would obviously be cool to have).

@harrysarson
Copy link
Collaborator

I wonder if this could even take an argument, so that it could be used to test locally other branches?
@Janiczek Janiczek commented 4 days ago
@gampleman My initial assumption when hearing @harrysarson's idea was that this would later be reverted, and not a long-term flag. If it was to be longterm, I agree customizing it could be a nice addition.

I was thinking of this being something we revert, but if we end up liking I could see us building it out

lib/elm-test.js Outdated Show resolved Hide resolved
lib/Install.js Outdated Show resolved Hide resolved
lib/Install.js Outdated Show resolved Hide resolved
@lydell
Copy link
Collaborator

lydell commented May 16, 2022

@Janiczek Let me know if you need help getting flow, eslint or prettier to pass.

@Janiczek
Copy link
Contributor Author

Hey @lydell, thanks for the review and your offer! I was a bit swamped with other work, didn't even notice your last few comments 😅 I hope to take a look at this tomorrow and get the PR into shape.

@Janiczek Janiczek requested a review from lydell May 26, 2022 20:09
@Janiczek
Copy link
Contributor Author

This now works via a pair of commands:

  • elm-test install-unstable-test-master
  • elm-test uninstall-unstable-test-master

@Janiczek Janiczek changed the title Add a flag to use master version of elm-explorations/test Add a command to use master version of elm-explorations/test May 26, 2022
@lydell
Copy link
Collaborator

lydell commented May 28, 2022

@Janiczek I fixed the CI failure, but since you used your master branch I don’t seem to be able to push it…

Edit: I made a pull request to your pull request: https://github.com/Janiczek/node-test-runner/pull/1

lib/Install.js Outdated Show resolved Hide resolved
@lydell
Copy link
Collaborator

lydell commented May 28, 2022

This is looking really good now!

I finally tested on Windows, and unfortunately I ran into an error:

PS C:\Users\Simon\stuff\node-test-runner\example-application> node ..\bin\elm-test install-unstable-test-master
Using the master version of elm-explorations/test in place of 1.2.2.
Note: You will need to use the `elm-test uninstall-unstable-test-master` command afterwards to get back to the 1.2.2 version.
Removing C:\Users\Simon\stuff\node-test-runner\example-application\elm-stuff\generated-code\elm-community\elm-test\0.19.1-revision7
Removing C:\Users\Simon\AppData\Roaming\elm\0.19.1\packages\elm-explorations\test\1.2.2
Downloading https://codeload.github.com/elm-explorations/test/zip/refs/heads/master
Unzipping C:\Users\Simon\stuff\node-test-runner\example-application\elm-stuff\generated-code\elm-community\elm-test\0.19.1-revision7\elm-explorations-test.zip
Moving to ELM_HOME: C:\Users\Simon\AppData\Roaming\elm\0.19.1\packages\elm-explorations\test\1.2.2
EPERM: operation not permitted, rename 'C:\Users\Simon\stuff\node-test-runner\example-application\elm-stuff\generated-code\elm-community\elm-test\0.19.1-revision7\test-master' -> 'C:\Users\Simon\AppData\Roaming\elm\0.19.1\packages\elm-explorations\test\1.2.2'
PS C:\Users\Simon\stuff\node-test-runner\example-application>

Not sure why that happens yet.

@lydell
Copy link
Collaborator

lydell commented May 28, 2022

I figured it out! Made another PR here: https://github.com/Janiczek/node-test-runner/pull/2/files

lib/Install.js Outdated
});

// The destination stream is ended by the time it's called
file.on('finish', () => resolve(fileInfo));
Copy link
Collaborator

Choose a reason for hiding this comment

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

We seem to resolve the promise with some data we never use here.

lib/Install.js Outdated
@@ -117,6 +124,122 @@ function install(
return 'SuccessfullyInstalled';
}

async function downloadFileNative(url, filePath) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we should add type annotations to all new functions in this file – for parameters and return types.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Went ahead and did the last final touches: https://github.com/Janiczek/node-test-runner/pull/3

@lydell
Copy link
Collaborator

lydell commented May 28, 2022

One final final question 😅 What way is the easiest to verify that:

  • I actually get the master version.
  • I was able to back to the published version.

@lydell
Copy link
Collaborator

lydell commented May 29, 2022

Replying to myself, I figured out an easy way to test: I added Debug.log "a" Fuzz.andThen and checked if the tests resulted in a compilation error or a print. It works!

However, I first thought it didn’t work, because I tried with example-application/ in this repo, and it used elm-test 1.2.0 so nothing happened. Is it worth doing anything about that? Checking the version in elm.json (sounds annoying to code). Wait – I just noticed our prints do mention that we’re only replacing version 1.2.2 so maybe that’s good enough? Especially since 1.2.2 was released June 29, 2019 so all real tests out there probably use the latest version anyway?

Here’s where 1.2.2 is mentioned multiple times:
❯ ../bin/elm-test install-unstable-test-master
Using the master version of elm-explorations/test in place of 1.2.2.
Note: You will need to use the `elm-test uninstall-unstable-test-master` command afterwards to get back to the 1.2.2 version.
Removing /Users/lydell/forks/node-test-runner/example-application/elm-stuff/generated-code/elm-community/elm-test/0.19.1-revision7
Removing /Users/lydell/.elm/0.19.1/packages/elm-explorations/test/1.2.2
Downloading https://codeload.github.com/elm-explorations/test/zip/refs/heads/master
Unzipping /Users/lydell/forks/node-test-runner/example-application/elm-stuff/generated-code/elm-community/elm-test/0.19.1-revision7/elm-explorations-test.zip
Moving to ELM_HOME: /Users/lydell/.elm/0.19.1/packages/elm-explorations/test/1.2.2
Removing /Users/lydell/forks/node-test-runner/example-application/elm-stuff/generated-code/elm-community/elm-test/0.19.1-revision7/elm-explorations-test.zip

EDIT: Added a check in https://github.com/Janiczek/node-test-runner/pull/3. It was easy enough.

@lydell lydell mentioned this pull request May 29, 2022
5 tasks
@Janiczek
Copy link
Contributor Author

Janiczek commented May 29, 2022

Good to see you figured how to test this out:

What way is the easiest to verify that:
I actually get the master version.
I was able to back to the published version.

But anyways just to post my way of testing this, I've simply ran this local version of elm-test in one of my repos that had Shrink.noShrink in its tests/ files.

  • 1.2.2 will show no error
  • master will say the Shrink module doesn't exist

So it's usually fine to do something like

cd ~/Localhost/elm/elm-secret-sharing
../../cloned/node-test-runner/bin/elm-test # 1.2.2, works
../../cloned/node-test-runner/bin/elm-test install-unstable-test-master
../../cloned/node-test-runner/bin/elm-test # master, doesn't work
../../cloned/node-test-runner/bin/elm-test uninstall-unstable-test-master
../../cloned/node-test-runner/bin/elm-test # 1.2.2, works

@lydell
Copy link
Collaborator

lydell commented May 30, 2022

I noticed that the intellij-elm plugin does not like when I run elm-test install-unstable-test-master. It asks me to “re-attach elm.json”, and when I do it gives an error. Is that something you’ve noticed as well?

@Janiczek
Copy link
Contributor Author

I noticed that the intellij-elm plugin does not like

I don't use that one (I'm pretty light on Elm editor plugins) so I didn't notice 😬
I don't suppose intellij-elm checks hashes / redownloads archives, so perhaps this is just a matter of stale cache? Would the File | Invalidate Caches button help?

@lydell
Copy link
Collaborator

lydell commented Jun 6, 2022

Found the issue and made a PR: https://github.com/Janiczek/node-test-runner/pull/4

@Janiczek Janiczek closed this Jun 6, 2022
@Janiczek Janiczek reopened this Jun 6, 2022
@Janiczek
Copy link
Contributor Author

Janiczek commented Jun 6, 2022

Those auto-close comments are treacherous 😁

@lydell lydell merged commit 768ab12 into rtfeldman:master Jun 6, 2022
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.

4 participants