-
Notifications
You must be signed in to change notification settings - Fork 519
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
mocha_test example #1216
mocha_test example #1216
Conversation
1f0c7fe
to
5deb0af
Compare
ae60c5d
to
9d370a0
Compare
@alexeagle Is this just and example on how to run Based on this I looked in mocha's github repo and couldn't find any Bazel rules: Just curious :) |
@fredrikredflag the new model for So the So yeah this PR is an example and also illustrates that no implementation is required. (however we have to figure out what to do about Windows, this currently relies on Bazel's runfiles symlink tree. Asking @meteorcloudy for some advice there) |
@alexeagle excellent, thanks! Then I can throw out our own mocha build rule hopefully. Do you know if mocha will honor |
in this model, we run vanilla mocha, so it will behave the same as if you don't run it under Bazel. Timing out more gracefully should go on my list of reasons one might want to wrap a test runner with bazel logic. |
@alexeagle I think you mentioned this problem in our last meeting, right? For Windows, is there a way to teach the binary about runfiles library? Can you give a simple example to reproduce this issue? |
@meteorcloudy this example is about as simple as it gets. We can't teach the binary about runfiles, because there are hundreds of binaries and we want them all to work. Let's think about how this work work outside of Bazel. I have my sources, in some cases I want to execute against them directly, in some cases I run a transformation like the typescript compiler and want to execute against the output directory. I think we can make this the same under Bazel by changing the working directory before running node, to either the directory containing the package input, or the output. Of course users will have to copy untransformed input files to the output tree, as you won't have a "union view" of them. But this matches how these tools work outside of Bazel. If we were to take that approach, we should think about whether every node binary run under Bazel should have the working dir changed in this way. |
@alexeagle That could be the solution.
This could be achieved by a wrapper script?
Maybe we can think of this copy as an no-op "transform", so we can implement it through a genrule or an Starlark action, then everything will be in the output directory. Question is how many files we need to copy? Is it going to be a performance issue? |
Yes the node_launcher.sh should continue to adapt Bazel's environment to host node programs in the way they expect. I think setting the pwd is a reasonable thing for it to do, if we understand what is the right pwd to make node programs run the way they expect. Copying files to the output dir will take time, but I'm less concerned about that since it's required outside of Bazel. I'm more concerned that Bazel makes it difficult to copy the file to the output directory under the same path. This is something we should discuss independently of this issue, for here let's assume I can always make an output dir with the right files (typically by creating a new subdirectory as the rule output and re-root files there) |
@alexeagle When I was trying to reproduce at this PR I got this error:
|
@meteorcloudy sorry - there's a change here to create the |
3362279
to
9967936
Compare
I'm going to tag the mocha_test with |
9967936
to
add73a6
Compare
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.
🥇
@alexeagle Thanks! I successfully reproduced the failure. And when I add |
Outside of Bazel a developer would do something like
which suggests we wanted the test to have a working dir of WORKSPACE/package rather than case 2) dist or build dir
this is true for a usecase like
again you either wanted the working dir to be in the sources or in the dist folder. In short, there is no concept of a "union view" over sources and outputs, you run in either one of the two directories. If you have a I'll document Let's follow-up in another place. |
This allows a mocha_test macro to be neatly written - otherwise it got inputs like wksp_name/./file.js
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information