You can clone with
HTTPS or Subversion.
@visionmedia what do you think about catching SIGTERM, SIGINT and SIGHUP, running the after callback function to clean things up in the test?
hmmm in general -1 but what's the cleanup doing that is so crucial? i know it doesnt fit every case but i usually clean out the db in a before / beforeEach etc so even failures are fine
actually i almost never use after / afterEach
well, we are seeding the database only once in the before callback, then removing the data in the after callback function. Tests run faster than doing it per every test in the suite.
gotcha, why not add another before() and clear it first? that's the approach I usually take, come to think of it I dont think I've ever used after / afterEach
hahaha that's sweet
my specs were looking so natural until a hit this wall. I can use before to remove the data and then reload it again but it doesn't feel right to me that after doesn't get called upon any sort of test interruption :dissapointed:
IMO it just makes more sense than trying to recover from every possible fail point, im not 100% against it if it was an option but it's sort of a non-problem, I agree though that most people will be doing it this way and that it feels more natural
I'm going to implement remove if it exists in my fixture loading functions and leave the after callback anyways because I know you are going to reconsider this :P
remove if it exists
hahaha, nah I totally get it, just thinking on it. we need some more people in here that use after hooks, because im not totally convinced that they should exist
you know they exist in every single respetable BDD/TDD/xUnit framework, that's why you designed it like that in mocha. It just needs a small tweak heheh
yup, doesn't mean they really make sense though. A test can fail in so many different ways, if the machine shuts down you have bad state, if you get SIGKILL you have bad state etc
indeed, but those are exceptional situations, hitting Ctrl + C to terminate the runner in development time is fairly common.
yeah i thing SIGINT is reasonable
hahahahaha. ill try it in a min
so it does work fine, but I think this will have edge-cases regardless, if you SIGINT during one of the after hooks then you're fucked anyway
hm, I was expecting it to call after callbacks upon SIGINT and then exit the process. Isn't that how it works?
that part works fine, but if what's hanging is an after hook then you're screwed
or if you just happen to SIGINT at the wrong time
agreed, it minimizes the chance to screw things up anyway. Do you feel like pushing that into master or you're not entirely sure yet?
From my experience the most common scenario is the test hanging for some reason, the after function is usually pretty straight forward.
im not feelin it so far, mostly because then we are kind of promising something that isn't really possible, the only thing you could do is flat-out ignore SIGINT when after hooks are being fired, but then if you are really hanging you'll have to kill(1) it which is not any more convenient
fair enough, let's leave it open for now until we clear things up a bit more. I wonder how other test frameworks deal with this though.
yup it's still something to consider