Skip to content

Commit d23b646

Browse files
committed
[ test ] Trying to figure out what happened on Windows
1 parent 2fb379b commit d23b646

File tree

11 files changed

+95
-60
lines changed

11 files changed

+95
-60
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ jobs:
2121
runs-on: ${{ matrix.os }}
2222
strategy:
2323
matrix:
24-
os: [windows-latest, ubuntu-latest, macos-latest]
25-
agda: ["Agda-2.6.3", "Agda-2.6.4", "Agda-2.7.0"]
24+
# os: [windows-latest, ubuntu-latest, macos-latest]
25+
os: [windows-latest]
26+
# agda: ["Agda-2.6.3", "Agda-2.6.4", "Agda-2.7.0"]
27+
agda: ["Agda-2.7.0"]
2628
fail-fast: false
2729

2830
# Steps represent a sequence of tasks that will be executed as part of the job

lib/js/src/Connection/Connection.bs.js

Lines changed: 12 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/js/src/Connection/Endpoint/Connection__Endpoint__Agda.bs.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/js/src/Connection/Transport/Connection__Transport__Process.bs.js

Lines changed: 18 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/js/test/tests/Test__Auto.bs.js

Lines changed: 12 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/js/test/tests/Test__Util.bs.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Connection/Connection.res

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,39 +109,43 @@ module Module: Module = {
109109
}
110110

111111
// see if it's a Agda executable or a language server
112-
let probeFilepath = async path =>
112+
let probeFilepath = async path => {
113+
Js.log("[ LOG ][ Connection.probeFilepath ] Input path: " ++ path)
113114
switch URI.parse(path) {
114115
| Connection__URI.LspURI(_) => Error(Error.Probe.CannotHandleURLsAtTheMoment)
115116
| FileURI(_, vscodeUri) =>
116-
let path = VSCode.Uri.fsPath(vscodeUri)
117-
let result = await Connection__Process__Exec.run(path, ["--version"], ~timeout=3000)
117+
let fsPath = VSCode.Uri.fsPath(vscodeUri)
118+
Js.log("[ LOG ][ Connection.probeFilepath ] VSCode.Uri.fsPath result: " ++ fsPath)
119+
let result = await Connection__Process__Exec.run(fsPath, ["--version"], ~timeout=3000)
118120
switch result {
119121
| Ok(output) =>
120122
// try Agda
121123
switch String.match(output, %re("/Agda version (.*)/")) {
122-
| Some([_, Some(version)]) => Ok(path, Ok(version))
124+
| Some([_, Some(version)]) => Ok(fsPath, Ok(version))
123125
| _ =>
124126
// try ALS
125127
switch String.match(output, %re("/Agda v(.*) Language Server v(.*)/")) {
126128
| Some([_, Some(agdaVersion), Some(alsVersion)]) =>
127-
let lspOptions = switch await checkForPrebuiltDataDirectory(path) {
129+
let lspOptions = switch await checkForPrebuiltDataDirectory(fsPath) {
128130
| Some(assetPath) =>
129131
let env = Dict.fromArray([("Agda_datadir", assetPath)])
130132
Some({Connection__Protocol__LSP__Binding.env: env})
131133
| None => None
132134
}
133-
Ok(path, Error(alsVersion, agdaVersion, lspOptions))
135+
Ok(fsPath, Error(alsVersion, agdaVersion, lspOptions))
134136
| _ => Error(Error.Probe.NotAgdaOrALS(output))
135137
}
136138
}
137139
| Error(error) => Error(Error.Probe.CannotDetermineAgdaOrALS(error))
138140
}
139-
}
141+
}}
140142

141143
let makeWithRawPath = async (rawpath: string): result<t, Error.Establish.t> => {
144+
Js.log("[ LOG ][ Connection.makeWithRawPath ] Input rawpath: " ++ rawpath)
142145
switch await probeFilepath(rawpath) {
143146
| Ok(path, Ok(agdaVersion)) =>
144-
let connection = await Agda.make(rawpath, agdaVersion)
147+
Js.log("[ LOG ][ Connection.makeWithRawPath ] Passing to Agda.make: " ++ path)
148+
let connection = await Agda.make(path, agdaVersion)
145149
Ok(Agda(connection, path, agdaVersion))
146150
| Ok(path, Error(alsVersion, agdaVersion, lspOptions)) =>
147151
switch await ALS.make(
@@ -322,9 +326,11 @@ module Module: Module = {
322326
}
323327

324328
let sendRequest = async (connection, document, request, handler) => {
329+
Js.log("[ LOG ] Sending request: " ++ Request.toString(request))
325330
// encode the Request to some string
326331
let encodeRequest = (document, version) => {
327332
let filepath = document->VSCode.TextDocument.fileName->Parser.filepath
333+
Js.log("[ LOG ] original filepath: " ++ filepath)
328334
let libraryPath = Config.getLibraryPath()
329335
let highlightingMethod = Config.Highlighting.getHighlightingMethod()
330336
let backend = Config.getBackend()

src/Connection/Endpoint/Connection__Endpoint__Agda.res

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ module Module: Module = {
8989
}
9090

9191
let make = async (path, version) => {
92+
Js.log("[ LOG ][ Agda.make ] Received path: " ++ path)
9293
let args = Array.concat(["--interaction"], Config.Connection.getCommandLineOptions())
9394
let conn = {
9495
process: Process.make(path, args),

src/Connection/Transport/Connection__Transport__Process.res

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ module Module: Module = {
5858
}
5959

6060
let make = (path, args) => {
61+
Js.log("[ LOG ][ Process.make ] About to spawn process with path: " ++ path)
6162
let chan = Chan.make()
6263
let stderr = ref("")
6364
// spawn the child process
@@ -69,6 +70,7 @@ module Module: Module = {
6970
->Option.forEach(stream =>
7071
stream
7172
->NodeJs.Stream.onData(chunk => {
73+
Js.log("[ LOG ][ " ++ path ++ "] Process stdout: " ++ NodeJs.Buffer.toString(chunk))
7274
chan->Chan.emit(Stdout(NodeJs.Buffer.toString(chunk)))
7375
})
7476
->ignore
@@ -80,6 +82,7 @@ module Module: Module = {
8082
->Option.forEach(stream =>
8183
stream
8284
->NodeJs.Stream.onData(chunk => {
85+
Js.log("[ LOG ][ " ++ path ++ "] Process stderr: " ++ NodeJs.Buffer.toString(chunk))
8386
chan->Chan.emit(Stderr(NodeJs.Buffer.toString(chunk)))
8487
// store the latest message from stderr
8588
stderr := stderr.contents ++ NodeJs.Buffer.toString(chunk)
@@ -89,6 +92,7 @@ module Module: Module = {
8992

9093
// on `close` from `stdin` or `process`
9194
let promiseOnClose = Promise.make((resolve, _) => {
95+
Js.log("[ LOG ][ " ++ path ++ "] Process.onClose: Waiting for process to close")
9296
process
9397
->NodeJs.ChildProcess.stdin
9498
->Option.forEach(stream =>
@@ -104,21 +108,26 @@ module Module: Module = {
104108

105109
// on errors and anomalies
106110
let promiseOnExit = Promise.make((resolve, _) => {
111+
Js.log("[ LOG ][ " ++ path ++ "] Process.onExit: Waiting for process to exit")
107112
process
108113
->NodeJs.ChildProcess.onExit(code => resolve(code))
109114
->ignore
110115
})
111116

112117
process
113-
->NodeJs.ChildProcess.onDisconnect(() => chan->Chan.emit(Event(OnDestroyed)))
114-
->NodeJs.ChildProcess.onError(exn =>
118+
->NodeJs.ChildProcess.onDisconnect(() => {
119+
Js.log("[ LOG ][ " ++ path ++ "] Process.onDisconnect: Process disconnected")
120+
chan->Chan.emit(Event(OnDestroyed))})
121+
->NodeJs.ChildProcess.onError(exn =>{
122+
Js.log("[ LOG ][ " ++ path ++ "] Process.onError: Process error: " ++ Util.JsError.toString(exn))
115123
chan->Chan.emit(Event(OnError(Util.JsError.toString(exn))))
116-
)
124+
})
117125
->ignore
118126

119127
// emit `OnExit` when either `close` or `exit` was received
120128
Promise.race([promiseOnExit, promiseOnClose])
121129
->Promise.thenResolve(exitCode => {
130+
Js.log("[ LOG ][ " ++ path ++ "] Process.onExit: Process exited with code " ++ string_of_int(exitCode))
122131
chan->Chan.emit(Event(OnExit(exitCode)))
123132
})
124133
->ignore
@@ -155,6 +164,7 @@ module Module: Module = {
155164
let send = (self, request): bool => {
156165
switch self.status {
157166
| Created(process) =>
167+
Js.log("[ LOG ] Process.send: Sending request: " ++ request)
158168
let payload = NodeJs.Buffer.fromString(request ++ NodeJs.Os.eol)
159169
process
160170
->NodeJs.ChildProcess.stdin
@@ -164,7 +174,9 @@ module Module: Module = {
164174
->ignore
165175
)
166176
true
167-
| _ => false
177+
| _ =>
178+
Js.log("[ LOG ] Process.send: Cannot send, process is not in a valid state")
179+
false
168180
}
169181
}
170182

0 commit comments

Comments
 (0)