-
Notifications
You must be signed in to change notification settings - Fork 83
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Windows Support - esy + dune config #199
Open
bryphe
wants to merge
19
commits into
jaredly:master
Choose a base branch
from
bryphe:bryphe/windows-esy-fixes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
a6b7556
Initial Windows fixes
bryphe 3564e77
Enable all tests
bryphe f5afe29
Revert changes to State.re
bryphe 1558a42
Fix up whitespace
bryphe 20c99e1
Upgrade esy for Windows
bryphe 0bed757
Factor out 'withCwd' logic
bryphe 0dfbb35
Fix getting '$OCAMLLIB' on Windows
bryphe 6e01742
Fix robustness of path checking
bryphe 20db56f
Fix off-by-one issue
bryphe de1495b
Revert removal of environment detection
bryphe 78042af
Fix esy execution path when detecting using command-env
bryphe 11179c4
Run tests directly from executable
bryphe 99e661a
Check path for ExamplesTests
bryphe 7afcadd
Move files to predictable structure; run tests directly
bryphe 3fa909b
add windows conditional
jaredly 269065c
Merge branch 'master' into bryphe/windows-esy-fixes
jaredly 3412436
fix
jaredly c3fe600
lol
jaredly 2407df0
Merge branch 'master' into bryphe
jaredly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
EXCLUDE_QUERY_DIR | ||
B /Users/jared/clone/tools/reason-language-server/examples/example-esy-dune-project/_esy/default/store/b/hello-bb5af4c3/default/lib/.lib.objs/byte | ||
B C:/Users/User/clone/reason-language-server/examples/example-esy-dune-project/_esy/default/store/b/hello-022fadb7\default/lib/.lib.objs/byte | ||
S . | ||
FLG -open Lib -w -40 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,18 +2,8 @@ | |
|
||
let shellEscape = path => Filename.quote(path); | ||
|
||
let execFull = (~input=?, ~pwd=?, ~env=Unix.environment(), cmd) => { | ||
let cmd = | ||
if (Sys.os_type == "Win32") { | ||
Printf.sprintf("\"%s\"", cmd) | ||
} else { | ||
cmd | ||
} | ||
let env = switch pwd { | ||
| None => env | ||
| Some(pwd) => Array.map(item => String.length(item) > 4 && String.sub(item, 0, 4) == "PWD=" ? "PWD=" ++ pwd : item, env) | ||
}; | ||
let prevCwd = switch pwd { | ||
let withCwd = (~cwd, f) => { | ||
let prevCwd = switch cwd { | ||
| None => None | ||
| Some(pwd) => | ||
let prevCwd = Unix.getcwd(); | ||
|
@@ -24,11 +14,32 @@ let execFull = (~input=?, ~pwd=?, ~env=Unix.environment(), cmd) => { | |
Some(prevCwd) | ||
} | ||
} | ||
let (cmd_out, cmd_in, cmd_err) = Unix.open_process_full(cmd, env); | ||
|
||
let ret = f(); | ||
|
||
switch prevCwd { | ||
| None => () | ||
| Some(prevCwd) => Unix.chdir(prevCwd) | ||
}; | ||
|
||
ret; | ||
}; | ||
|
||
let execFull = (~input=?, ~pwd=?, ~env=Unix.environment(), cmd) => { | ||
let cmd = | ||
if (Sys.os_type == "Win32") { | ||
Printf.sprintf("\"%s\"", cmd) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't use %S it might be more robust with space and other special char ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And use Sys.win32 ? |
||
} else { | ||
cmd | ||
} | ||
let env = switch pwd { | ||
| None => env | ||
| Some(pwd) => Array.map(item => String.length(item) > 4 && String.sub(item, 0, 4) == "PWD=" ? "PWD=" ++ pwd : item, env) | ||
}; | ||
|
||
let (cmd_out, cmd_in, cmd_err) = withCwd(~cwd=pwd, () => { | ||
Unix.open_process_full(cmd, env); | ||
}) | ||
|
||
switch input { | ||
| None => () | ||
|
@@ -104,8 +115,8 @@ let execOption = cmd => { | |
} | ||
}; | ||
|
||
let execResult = cmd => { | ||
let (lines, success) = execSync(cmd); | ||
let execResult = (~cwd=?, cmd) => { | ||
let (lines, success) = withCwd(~cwd, () => execSync(cmd)); | ||
if (success) { | ||
RResult.Ok(String.concat("\n", lines)) | ||
} else { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,4 @@ let maybeConcat = (a, b) => { | |
} | ||
}; | ||
|
||
let (/+) = fileConcat; | ||
let (/+) = fileConcat; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the big diff here! I remove this first block that checks the environment for
esy
environment variables, so it impacted the indentation.This caused problems specifically in our test environment - it would pick up the esy root/target for
reason-language-server
instead of the test case. Theesy command-env --json
strategy seems more reliable, so I just deferred to that. @anmonteiro - let me know if I missed something here!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bryphe checking for the env var is there to support esy named sandboxes, i.e. having
foo.json
instead ofesy.json
and starting your editor withesy @foo code .
. I use them pretty heavily personally and this is the only way we can support them right now.I think this needs to stay there. Can you think of an alternative?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the details @anmonteiro - supporting sandboxes makes sense.
I believe the issue here is limited to our tests - when we run
esy dune exec ExamplesTests
, it picks up thecur__original_root
andcur__target_dir
from the rootreason-language-server
esy config - this causes problems w/ the test.A couple possible options:
cur__original_root
/cur__target_dir
environment via thesetenv
stanza in duneStill looking into this but let me know if you have ideas. I think it's crucial to have a test covering the
esy+dune
scenario here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reverted the change, but as expected
esy
test fails... looking into it...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like
esy
wasn't being launched in the correct spot. I think we'll also have to runExamplesTest.exe
outside the esy sandbox, otherwise the environment gets polluted withcur__original_root
/cur__target_dir
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I think that makes sense. I'm glad the issue seems to be limited only to tests.