-
Notifications
You must be signed in to change notification settings - Fork 34
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
Initial erc tests #35
Conversation
1ce6a9a
to
30be5f7
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.
Looks just fine for a start. Be prepared to turn it on its head though soon, like everything.
Now put it in GitHub actions!
dape-tests.el
Outdated
(defun dape--line-with-property (property &optional value) | ||
(car (dape--lines-with-property property value))) | ||
|
||
(defmacro dape--with-files (file-fixtures &rest body) |
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.
Make these BODY taking macros hygienic, delegate immediately to a function. Google "CALL-WITH idiom"
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.
Sure, is it because of stack traces. Whats your reasoning? Just curious I am allergic to "best practices"
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.
No, not specifically because of stack traces. One of the benefits is that you change the implementation of
the wrapper, you don't need to find all the users of the macro and recompile them: you just recompile the implementation. The other benefit has to do with hygiene and shadowing. By wrapping the body
in a lambda, you guarantee that it is not affected by bindings int the macro preamble. Another way to solve this is with gensym
or make-symbol
.
This is actually not unlike the problems posed by the C preprocessor.
I am allergic to "best practices"
:-) That's a very healthy position. Indeed always question. "best practices" is often very close to "cargo cult"
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.
So in your original macro I think you had something like
(defmacro dape--with-files (file-fixtures &rest body)
`(let* ((temp-dir (make-temp-file "dape-tests-" t))
...,@body
(remove-directory temp-dir)))
or something like that. If some use of this macro a body had a (setq temp-dir something)
you would not get an error and the code would be silently (or loudly) broken. The alternative to call-with
to make it hygeniec is to:
(defmacro dape--with-files (... &rest body)
(let ((temp-dir-sym (gensym)))
`(let ((,temp-dir-sym (make-temp-file...)))
,@body
(remove-directory ,temp-dir-sym))))
But this is ugly to read and makes for funky macroexpansions. Very common though. The call with-idiom is much better
and has other benefits.
(defmacro dape--with-files (... &rest body)
`(call-with-files (make-temp-file ...) (lambda () ,@body)))
(defun call-with-files (temp-dir fn)
(funcall fn)
(remove-directory temp-dir))
Makefile
Outdated
@echo Compiling $< | ||
@${EMACS} -batch -q -no-site-file -L . -f batch-byte-compile $< | ||
|
||
test: $(ELCFILES) |
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.
Emacs convention is to call this 'check'. Pretty arbitrary, I guess.
dape-tests.el
Outdated
,@body) | ||
(delete-directory temp-dir t)))) | ||
|
||
(defmacro dape--should-eventually (pred &optional seconds) |
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.
Interesting macro name and semantics! Will copy
48b3b32
to
0c4569c
Compare
@@ -930,7 +930,10 @@ If NOWARN does not error on no active process." | |||
(json (json-serialize object :false-object nil)) | |||
(string (format "Content-Length: %d\r\n\r\n%s" (length json) json))) | |||
(dape--debug 'io "Sending:\n%S" object) | |||
(process-send-string process string))) | |||
(condition-case err |
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.
You might want condition-case-unless-debug
here, else you lock yourself out of useful backtraces if something does go wrong
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.
Ah nice one, had know idea of the existence of condition-case-unless-debug
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.
Reverted, ert enables debug on error which was the reson for it the first time around. As you know this code will be replaced by jsonrpc anyway.
The handling of js-debug termination is not handled a clean way, there is no orphaned process but process is dies during termination with an strange timing.
For some reason one of the test does not work for emacs 28.2, which I am not motivated at this time to solve.
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.
Fair, and indeed ert enabling debug-on-error is a pain . You can rebind it in your tests tho. But you're right, this is soon to be replaced anyway.
You know what you be a really good idea this early in the I didn't do this for Of course, I can hear you say already "but typing So something like this footer in
All the symbols are still named |
Speaking of convention, another reasonably arbitrary one is that the file containing tests for package |
Duh, nevermind, you already have it like that. 🤦 |
Will do, makes sense. Is this the best diss I have ever received |
I'm lost 😬 You are Daniel right? (Or Svante?) I just meant |
This reverts commit 9fa2fd0.
dff4515
to
0e0cc6c
Compare
Basis for tests discussion