Comments (7)
It seems that's just how processes work
That makes sense. Therefore, trying to suppress the signal being sent from Emacs is not the right approach.
After another look at spring I found an irresistibly simple way to fix it (for me) by monkey patching spring from its user config file:
# ~/.spring.rb:
Spring::IGNORE_SIGNALS << "HUP"
I'll use this approach now, so far it works exactly as needed. Thanks a lot for the guidance!
from rspec-mode.
For the record, this comment clarifies the intention of spring on this matter: rails/spring#575 (comment), which I think is a good reason to keep it a local config hack instead of trying to make it configurable within spring itself.
from rspec-mode.
I'm not sure what would be a good solution.
The docs page you linked to suggests using nohup
. Have you tried customizing rspec-spec-command
to "nohup rspec"
?
Also note that most recent versions of Rails don't have Spring in the default config anymore: rails/rails#42997
So it might be worth to re-evaluate whether it brings enough benefit for your particular project.
from rspec-mode.
I've tried but haven't found a way to use nohup
as part of rspec-spec-command
without it affecting also the rspec
process itself. E.g. like this, all output from rspec gets suppressed:
nohup bin/rspec --format documentation /home/tils/deka-etf/spec/helpers/liquidation_helper_spec.rb:14
nohup: ignoring input and appending output to 'nohup.out'
Regarding the usefulness of Spring, you're right, it's something I should probably reconsider. In this particular project, the difference is currently very noticeable: a simple helper spec takes 5s without Spring, 750ms with Spring, but I suppose the startup time could be improved with some effort (e.g. add bootsnap
, which this old project doesn't have yet).
from rspec-mode.
Yeah, bootsnap
is worth a try too.
I've tried but haven't found a way to use nohup as part of rspec-spec-command without it affecting also the rspec process itself
That makes sense. I probably should have tested it first.
On the high level, it seems like you'd want to launch spring
in the background using nohup
or its equivalent, so this could be an option in Spring itself (because it creates the subprocess during the command's execution), but I haven't found one so far.
In general, I would just recommend launching Spring in a separate terminal with the same env, so that it picks up the rspec launches as well. And here's a corresponding recommendation for when it's difficult to keep the terminal running: rails/spring#343
from rspec-mode.
bootsnap
reduced the startup from 5s to 2.6s – already a huge win! bootsnap
says in its README that it works nicely along spring
, so until I can reduce startup time further through other means, I'd still like to use spring
occasionally I think.
so this could be an option in Spring itself (because it creates the subprocess during the command's execution), but I haven't found one so far.
I haven't found one either. Adding HUP
to the list of ignored signals in https://github.com/rails/spring/blob/main/lib/spring/env.rb#L7 has the desired effect, but I don't know if it has implications elsewhere and if it fits into spring
's intents to make this configurable.
In general, I would just recommend launching Spring in a separate terminal
Exactly. I should have mentioned, this has been my workflow for many years now: run specs in Emacs, notice slow startup, switch to terminal, run any spec there to start spring, switch back to Emacs. It's only a minor annoyance, which I was hoping to be easy to fix once and for all , but apparently it isn't 😄.
I've tried to find out from where exactly compile
causes the HUP
signal to be sent to the compilation process, but no success yet. It might be the way that make-process
works, which is called through start-file-process-shell-command
?
from rspec-mode.
bootsnap reduced the startup from 5s to 2.6s – already a huge win
Pretty good, indeed.
Adding HUP to the list of ignored signals in https://github.com/rails/spring/blob/main/lib/spring/env.rb#L7 has the desired effect, but I don't know if it has implications elsewhere and if it fits into spring's intents to make this configurable.
I don't know for sure. But the intent might be that, when you close all the open terminals with C-d
, spring
shuts down as well. Whereas with this alteration its process might still stay around.
I've tried to find out from where exactly compile causes the HUP signal to be sent to the compilation process, but no success yet. It might be the way that make-process works, which is called through start-file-process-shell-command?
It seems that's just how processes work: the compilation runs spring and rspec as a shell command, meaning a shell process is launched to handle it. But then it finishes and the parent process is terminated, and the OS sends SIGHUP to all its children that are still around. See also the explanation here: https://serverfault.com/a/117153, quoting "Advanced Programing in the Unix Environment".
from rspec-mode.
Related Issues (20)
- Copy last test command to clipboard HOT 3
- How to customize rspec erorr stack colours matching with my preferred theme. HOT 7
- rspec-mode does not work when I follow the instruction on README HOT 3
- Wrong Ruby version used during test invocation with Rbenv + ZSH + Spacemacs HOT 9
- Handle the FactoryGirl -> FactoryBot rename HOT 1
- Multiple rspec processes at the same time HOT 1
- Error for rspec-compile-target-directory HOT 3
- Setting docker variables, does nothing HOT 23
- Running `rspec-verify-matching` uses wrong full path to matched files HOT 7
- Opt out of multiple compilation buffer support HOT 2
- Using rake spec doesn't exclude files HOT 3
- Docker based invocation should not assume presence of bash HOT 4
- Request: Ability to configure primary spec directory
- How disable rspec -b backtrace options HOT 2
- Low level configurable spec runner command HOT 3
- Trouble using rspec-mode with docker HOT 6
- Pry history is broken HOT 1
- Support for request specs in rspec-toggle-spec-and-target? HOT 5
- rspec not using test env if RAILS_ENV is set in the environment. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rspec-mode.