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

Fix path splitting issues on windows #3565

Merged
merged 24 commits into from
Aug 22, 2024
Merged

Fix path splitting issues on windows #3565

merged 24 commits into from
Aug 22, 2024

Conversation

iterion
Copy link
Contributor

@iterion iterion commented Aug 20, 2024

It's not safe to assume files are delimited by /. Instead, electron re-exports the node path lib which we can use for dirname, basename, etc.

I found another occurence of this that must be causing some bugs somewhere in routeLoaders. I've fixed it and verified it still works on linux.

I haven't tested this on windows yet, but everything still functions on linux so it's at least notionally better. I'll work on getting a dev env on my windows machine.

Copy link

qa-wolf bot commented Aug 20, 2024

QA Wolf here! As you write new code it's important that your test coverage is keeping up.
Click here to request test coverage for this PR!

Copy link

vercel bot commented Aug 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
modeling-app ✅ Ready (Inspect) Visit Preview Aug 22, 2024 5:27pm

@iterion iterion force-pushed the iterion/fix-windows branch 2 times, most recently from eb5fd8c to c7a16c4 Compare August 20, 2024 15:04
@jessfraz jessfraz enabled auto-merge (squash) August 20, 2024 17:15
@@ -38,7 +38,7 @@ export async function renameProjectDirectory(

// Make sure the new name does not exist.
const newPath = window.electron.path.join(
projectPath.split('/').slice(0, -1).join('/'),
Copy link
Contributor

Choose a reason for hiding this comment

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

jesus we need a lint for shit like this haha makes me nervous just looking at it

@jessfraz
Copy link
Contributor

@iterion i think you need to run yarn fmt

@iterion
Copy link
Contributor Author

iterion commented Aug 20, 2024

yes, idgaf about that until i'm done lol, editor formats it in a completely different way so I just disable it and format once i'm done.

currentFileName: currentFileName,
currentFilePath: id,
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

can we unit test in the same way as the rust tests were, only becaiuse there were lots of regression tests in those unit tests, aka those little shits are load bearing :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I can unit test as-is, I took a lot of stuff out because it seems unnecessary. Like, the old code was not using half of the function because of a bug with how config was passed in a json, we were just getting lucky before that this worked even with unit tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you know any of the specific functionality regressions I could write e2e tests for those too, to make sure I didn't cut out currently important stuff.

Copy link
Contributor

Choose a reason for hiding this comment

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

mostly files w spaces, either url encoded or not were weird

Copy link
Contributor

Choose a reason for hiding this comment

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

idk if applies here

Copy link

codecov bot commented Aug 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.83%. Comparing base (682099c) to head (1207c65).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3565      +/-   ##
==========================================
- Coverage   87.90%   87.83%   -0.07%     
==========================================
  Files          67       67              
  Lines       26150    25960     -190     
==========================================
- Hits        22986    22803     -183     
+ Misses       3164     3157       -7     
Flag Coverage Δ
wasm-lib 87.83% <ø> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

iterion and others added 14 commits August 22, 2024 09:08
* Fix: on settings close go back to the same file

* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)

* shit aint working yo

* Get that page a-loading

* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest)

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Frank Noirot <frank@kittycad.io>
Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com>
@iterion iterion force-pushed the iterion/fix-windows branch 2 times, most recently from 64fce91 to 2e65211 Compare August 22, 2024 13:17
Comment on lines 5 to 6
// @ts-ignore
global.window = { electron: { path: path } }
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't get cleaned up between runs. I really don't like modifying global. It's easy to make mistakes like this. Here, it introduces test order dependence, and that's a best case scenario. I'd much prefer having abstraction functions. But if we really can't get around it, I think we need to move this to a beforeEach() and in an afterEach(), remove it from global. This way, if there's an exception, it still cleans up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I switched to just injecting path into the function, we can then remove onDesktop as a param as it basically just checks if it's electron, and we know it's electron when window.electron.path is defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ha, that's broken though, not working when I test it. Maybe back to beforeEach for now.

Copy link
Collaborator

@jtran jtran Aug 22, 2024

Choose a reason for hiding this comment

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

we can then remove onDesktop as a param as it basically just checks if it's electron, and we know it's electron when window.electron.path is defined.

I think this makes sense. Then add a local var like this.

const isDesktop = !!pathlib

Copy link
Contributor Author

Choose a reason for hiding this comment

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

False alarm, CI looks pretty good outside of the known flakes. I tested again locally after rebuilding everything and it worked there too.

@iterion iterion force-pushed the iterion/fix-windows branch from 7df09aa to 1207c65 Compare August 22, 2024 17:09
@iterion iterion disabled auto-merge August 22, 2024 17:38
@iterion iterion merged commit a2d8c5a into main Aug 22, 2024
25 of 30 checks passed
@iterion iterion deleted the iterion/fix-windows branch August 22, 2024 17:38
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