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

Debug.logs aren't shown if a test hangs #120

Open
MartinSStewart opened this issue Oct 28, 2022 · 3 comments
Open

Debug.logs aren't shown if a test hangs #120

MartinSStewart opened this issue Oct 28, 2022 · 3 comments

Comments

@MartinSStewart
Copy link

I've noticed that the Debug.log messages aren't shown until the tests are completed. Unfortunately this means that if I have a test that hangs I need to kill the test runner and then I never see the Debug.logs. Is there a way to handle this situation?

@mpizenberg
Copy link
Owner

Hum, currently, calls to the log function accumulate in an array, which is transferred to the reporter and cleared everytime a test finishes:

msg.logs = logs;
parentPort.postMessage(msg);
logs.length = 0;

I haven't really thought if there could be a way to stream the logs in addition to accumulate them, or if that's desirable. If you need unblocking, after having compiled once, you can modified these line in the file elm-stuff/tests-0.19.1/js/node_runner.js of your project.

@mpizenberg
Copy link
Owner

mpizenberg commented Oct 28, 2022

Actually (I just checked now) and that file gets overwritten on next elm-test-rs call. So what you'd need to do after one call of elm-test-rs is emulating the final call yourself. So the steps are:

  1. Call elm-test-rs once (kill it if it fails, we only care about the compiled artifacts)
  2. Inside elm-stuff/tests-0.19.1/js/node_runner.js, replace console.elmlog = (str) => logs.push(str + "\n"); by
console.elmlog = (str) => {
  console.error(str);  // uses stderr stream because stdout stream is not piped to elm-test-rs main
  logs.push(str + "\n");
};
  1. cd inside elm-stuff/tests-0.19.1/js/ and call echo "./node_runner.js" | node node_supervisor.js

Sorry for the inconvenience.

@MartinSStewart
Copy link
Author

I was able to solve the issue but this is good to know if I run into it again.

Sorry for the inconvenience.

No worries. This tool on the whole more than makes up for this slight inconvenience 👍

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

No branches or pull requests

2 participants