Comments (5)
Thanks for reporting this with examples!
I don't have much experience in reporting signals source, do you have a reference I can look up?
I guess at least not dropping the ball at the first failing test could be easily achievable.
A note to myself, the command to reproduce in my settings
emacs --batch --eval "(progn (package-initialize) (require 'doctest) (doctest \"test.el\"))"
where test
(defun divide (a b)
"
>> (/ 1 0)
=> 2
>> (divide 1 2)
=> 3
>> (divide 1 0)
=> 3"
(/ a b))
from doctest.
with my latest change this improves a little bit. How does that sound @doublep ?
An example of trace:
Warning (emacs): Test cases in comments can cause byte-compile warnings, please add '(not docstrings) to `byte-compile-warnings'
35
58
80
0 passed, 3 failed
test.el#4: (/ 1 0 => 2 but got Failure evaluating input:
(/ 1 0
which caused:
(end-of-file)
test.el#8: (divide 1 2) => 3 but got 0test.el#11: (divide 1 0) => 3 but got Failure evaluating input:
(divide 1 0)
which caused:
(arith-error)
from doctest.
I don't have much experience in reporting signals source, do you have a reference I can look up?
You could study either ERT or Buttercup source code. They use Edebug functionality to find backtraces. Buttercup is probably more readable.
The largest difference to your quick hack is that they print signal backtrace, which is useful if the error is signalled not from the function in question, but from something it calls (with 10 nesting levels). Though you could argue that doctest is aimed at simple functions.
+ (evaluated-input (condition-case err
+ (format "%S" (eval (car (read-from-string input))))
+ (error
+ (format "Failure evaluating input:\n\n%s\nwhich caused:\n%s\n\n" input err))))
At the very least the error handler should use t
instead of error
. Otherwise the condition-case
form doesn't catch non-error signals, just try this:
>> (signal 'wtf nil)
=> nil
Error output also confusingly repeats test code twice.
from doctest.
thanks I will give a look at buttercup source once I have time.
This change should do for a minimal functionality though.
Happy to receive a PR for more advanced stuff meanwhile I (find the time to) study.
from doctest.
closing this as I consider the more advanced version something nice to have but not strictly necessary yet.
from doctest.
Related Issues (3)
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 doctest.