Giter Site home page Giter Site logo

Comments (5)

JoshCheek avatar JoshCheek commented on July 1, 2024

So MSpec uses temp files, and Seeing Is Believing uses IO.pipe.

My reasoning was just that it didn't require me to deal with temp files. But I'm wondering if there's anything I'm failing to consider (ie why didn't MSpec use IO.pipe?)

cc @brixen

from seeing_is_believing.

brixen avatar brixen commented on July 1, 2024

@JoshCheek MSpec does not use IO.pipe because it's a significantly more complex operation than writing to a file (which typically requires a pretty simple call to a system library). MSpec was built to be easy to use in a Ruby implementation that didn't have much working yet.

from seeing_is_believing.

JoshCheek avatar JoshCheek commented on July 1, 2024

Makes sense. I'm going to stick with IO.pipe since my considerations are different. Thanks!

from seeing_is_believing.

JoshCheek avatar JoshCheek commented on July 1, 2024

More things to consider, based on #49:

  1. You cannot catch every exception, because, for example, at_exit { raise "omg" } this will execute after a begin/rescue/end around the whole program.
  2. These types of exceptions are handled by Ruby, before getting to the matrix's at_exit hook, it deals with them by printing some info to stderr (the normal error stuff you see all the time)
  3. This causes a weird difference between exceptions in the code and exceptions in hooks.
  4. You cannot close stderr after the program runs, because it could be legitimate to print to stderr, e.g. at_exit { $stderr.puts "now we run your test suite" }

So, what do we do?

  • Could redefine at_exit to rescue the exception and record it right there... Sounded really stupid when I thought of it, but now it seems more legit. OTOH, there could be any number of ways that I just don't know of, that will get your code running at that time, and if anything ever changes, this code could be fragile. It looks like at_exit blocks are just a linked list of blocks to run, and there isn't anything else that deals with this stuff.
  • Could wrap at_exit blocks in special error handling code. This seemed better to me initially, but how do you determine a block being passed to an at_exit hook from any other type of block? I can't think of a good way.
  • Could just ignore it and let the errors you see in at_exit hooks be printed in stderr as well.

from seeing_is_believing.

JoshCheek avatar JoshCheek commented on July 1, 2024

Going to go with "ignore it". If I redefine at_exit, which I did, then it does not set $!. We do this intentionally, to prevent Ruby from printing it to stderr, but it also means the next at_exit hook can't see the error in $! I tried hanging onto it and setting it right before invoking the next at_exit hook, but turns out that is not allowed ($! is a readonly variable -- probably b/c it's threadlocal or something, idk).

I think it's better to have edge cases where output is inconsistent than where behaviour is changed, so going to ignore it.

from seeing_is_believing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.