emacsfodder / move-text

move current line or region up or down
199 stars 12 forks source link

Test framework #22

Closed paaguti closed 2 years ago

paaguti commented 2 years ago

Using with-temp-buffer I can (at least) debug non-interactive functions... Hope that helps. BTW look at your variable names ;-)

jasonm23 commented 2 years ago

BTW look at your variable names ;-)

which one(s)

jasonm23 commented 2 years ago

@paaguti please resolve the conflicts.

paaguti commented 2 years ago

Just woke up ...

Your code:

"INPUT-STRING processed by BODY forms in a temp buffer should equal
EXPECT-STRING."
(declare (indent 1) (debug t))
`(should (string= ,expect
(with-current-buffer-window "*ERT-should-temp-buffer*"
(erase-buffer)
(insert ,input)
(goto-char (point-min))
,@body
(buffer-string)))))

I fear should read:

(defmacro should-on-temp-buffer (input-string expect-string &rest body) "INPUT-STRING processed by BODY forms in a temp buffer should equal EXPECT-STRING." (declare (indent 1) (debug t)) `(should (string= ,expect-string (with-current-buffer-window "ERT-should-temp-buffer" (erase-buffer) (insert ,input-string) (goto-char (point-min)) @.*** (buffer-string)))))

right? Fixing these variable names allows me to pass the first move-text-down test.

Nest, /PA

On Thu, 8 Sept 2022 at 07:25, Jason Milkins @.***> wrote:

@paaguti https://github.com/paaguti please resolve the conflicts.

— Reply to this email directly, view it on GitHub https://github.com/emacsfodder/move-text/pull/22#issuecomment-1240235807, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZKU4BYGV3S5YQVH7EJLWTV5F2EHANCNFSM6AAAAAAQG4YCJU . You are receiving this because you were mentioned.Message ID: @.***>

-- Fragen sind nicht da um beantwortet zu werden, Fragen sind da um gestellt zu werden Georg Kreisler

Headaches with a Juju log: unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run a leader-deposed hook here, but we can't yet

Oof...my eyes! rofl please format the code, or better still, comment on the "Files changed" tab at the line(s) relevant.

Oops, right, that isn't the nicest way of showing code, sorry :-)

jasonm23 commented 2 years ago

Oof...my eyes! 🤣 please format the code, or better still, comment on the "Files changed" tab at the line(s) relevant.

jasonm23 commented 2 years ago

FYI from email I think 4 leading space text is formatted as code... let me check

jasonm23 commented 2 years ago

This is a quick test of code formatting from email....

(defun mark-range (start end)
  "..."
  (set-mark (min start end))
  (goto-char (max start end))
  (activate-mark)
  (message "Select %d to %d" start end))

How did I do?!

jasonm23 commented 2 years ago

Oh, well that sucks!

Anyway, it's always better to use the webapp, and then the diff view (Files changed) in the PR.

paaguti commented 2 years ago

BTW, if you don't want to keep the test buffer, you can also use with-temp-buffer. Look at my test-framework branch. I just got the first test OK with call-interactively ;-)

On Thu, 8 Sept 2022 at 07:31, Pedro Andres Aranda Gutierrez < @.***> wrote:

Just woke up ...

Your code: (defmacro should-temp-buffer (input-string expect-string &rest body) "INPUT-STRING processed by BODY forms in a temp buffer should equal EXPECT-STRING." (declare (indent 1) (debug t)) `(should (string= ,expect (with-current-buffer-window "ERT-should-temp-buffer" (erase-buffer) (insert ,input) (goto-char (point-min)) @.*** (buffer-string)))))

I fear should read: (defmacro should-on-temp-buffer (input-string expect-string &rest body) "INPUT-STRING processed by BODY forms in a temp buffer should equal EXPECT-STRING." (declare (indent 1) (debug t)) `(should (string= ,expect-string (with-current-buffer-window "ERT-should-temp-buffer" (erase-buffer) (insert ,input-string) (goto-char (point-min)) @.*** (buffer-string))))) right? Fixing these variable names allows me to pass the first move-text-down test.

Nest, /PA

On Thu, 8 Sept 2022 at 07:25, Jason Milkins @.***> wrote:

@paaguti https://github.com/paaguti please resolve the conflicts.

— Reply to this email directly, view it on GitHub https://github.com/emacsfodder/move-text/pull/22#issuecomment-1240235807, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZKU4BYGV3S5YQVH7EJLWTV5F2EHANCNFSM6AAAAAAQG4YCJU . You are receiving this because you were mentioned.Message ID: @.***>

-- Fragen sind nicht da um beantwortet zu werden, Fragen sind da um gestellt zu werden Georg Kreisler

Headaches with a Juju log: unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run a leader-deposed hook here, but we can't yet

-- Fragen sind nicht da um beantwortet zu werden, Fragen sind da um gestellt zu werden Georg Kreisler

Headaches with a Juju log: unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run a leader-deposed hook here, but we can't yet

paaguti commented 2 years ago

Nope ;-)

paaguti commented 2 years ago

good work, tidy up the remaining points and resolve the conflicts. I'll add a test runner when it's ready to merge.

I'm going to try to go back to the call-interactively for the region tests in the next couple of days...

jasonm23 commented 2 years ago

Ok check emacsfodder/test-box .github/workflows/

jasonm23 commented 2 years ago

git pull --rebase on upstream/test-framework before you do more work.

The test runner is in place.

jasonm23 commented 2 years ago
Screenshot 2022-09-08 at 7 53 55 PM

When this is green and the line and region tests are verified, we're good to merge.

paaguti commented 2 years ago

Hi

this will be my first attempt at this stuff . When I run the test (as I have it now, with 4 separate tests), all 4 tests pass: Running 4 tests (2022-09-08 17:25:41+0200, selector ‘t’) passed 1/4 move-line-down-test (0.000172 sec) passed 2/4 move-line-up-test (0.000092 sec) Mark set Mark at 23 - Point at 30 passed 3/4 move-region-down-test (0.000108 sec) Mark set passed 4/4 move-region-up-test (0.000080 sec) Ran 4 tests, 4 results as expected, 0 unexpected (2022-09-08 17:25:41+0200, 0.000705 sec) 0 Don't know how to proceed... /PA On Thu, 8 Sept 2022 at 14:55, Jason Milkins ***@***.***> wrote: > [image: Screenshot 2022-09-08 at 7 53 55 PM] > > When this is green and the line and region tests are verified, we're good > to merge. > > — > Reply to this email directly, view it on GitHub > , > or unsubscribe > > . > You are receiving this because you were mentioned.Message ID: > ***@***.***> > -- Fragen sind nicht da um beantwortet zu werden, Fragen sind da um gestellt zu werden Georg Kreisler Headaches with a Juju log: unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run a leader-deposed hook here, but we can't yet
jasonm23 commented 2 years ago

This branch cannot be rebased due to conflicts

Did you know how to do this part?

Here's what happens next

That's all we need to do, running the tests after any change will happen automatically, but it's good practice to run them on the local dev machine to avoid turning the badge red here.

I approved the workflow run so hopefully we are seeing a green badge... now?

jasonm23 commented 2 years ago

Green (Blue!) pass on the tests. 00:00am here so I'm out for the next 8hrs. Goodnight.

jasonm23 commented 2 years ago

Looks like I can squash and merge.

jasonm23 commented 2 years ago

Any additional tidying will happen in #23

jasonm23 commented 2 years ago

BTW, if you don't want to keep the test buffer, you can also use with-temp-buffer. Look at my test-framework branch. I just got the first test OK with call-interactively ;-) On Thu, 8 Sept 2022 at 07:31, Pedro Andres Aranda Gutierrez < @.> wrote: … Just woke up ... Your code: (defmacro should-temp-buffer (input-string expect-string &rest body) "INPUT-STRING processed by BODY forms in a temp buffer should equal EXPECT-STRING." (declare (indent 1) (debug t)) `(should (string= ,expect (with-current-buffer-window "ERT-should-temp-buffer" (erase-buffer) (insert ,input) (goto-char (point-min)) @. (buffer-string))))) I fear should read: (defmacro should-on-temp-buffer (input-string expect-string &rest body) "INPUT-STRING processed by BODY forms in a temp buffer should equal EXPECT-STRING." (declare (indent 1) (debug t)) `(should (string= ,expect-string (with-current-buffer-window "ERT-should-temp-buffer" (erase-buffer) (insert ,input-string) (goto-char (point-min)) @. (buffer-string))))) right? Fixing these variable names allows me to pass the first move-text-down test. Nest, /PA On Thu, 8 Sept 2022 at 07:25, Jason Milkins @.> wrote: > @paaguti https://github.com/paaguti please resolve the conflicts. > > — > Reply to this email directly, view it on GitHub > <#22 (comment)>, > or unsubscribe > https://github.com/notifications/unsubscribe-auth/AAZKU4BYGV3S5YQVH7EJLWTV5F2EHANCNFSM6AAAAAAQG4YCJU > . > You are receiving this because you were mentioned.Message ID: > @.***> > -- Fragen sind nicht da um beantwortet zu werden, Fragen sind da um gestellt zu werden Georg Kreisler Headaches with a Juju log: unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run a leader-deposed hook here, but we can't yet -- Fragen sind nicht da um beantwortet zu werden, Fragen sind da um gestellt zu werden Georg Kreisler Headaches with a Juju log: unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run a leader-deposed hook here, but we can't yet

https://github.com/emacs-mirror/emacs/blob/master/lisp/emacs-lisp/ert-x.el ... is what we should've found the other day, these temp buffer, temp file styles have been done there.

paaguti commented 2 years ago

Yup, that will be the next step for the test-framework. :-)

paaguti commented 2 years ago

Right :-)

On Thu, 8 Sept 2022 at 09:53, Jason Milkins @.***> wrote:

@.**** commented on this pull request.

In move-text.el https://github.com/emacsfodder/move-text/pull/22#discussion_r965625160:

@@ -67,11 +67,15 @@ Note: region-beginning' andregion-end' are the reason why an

So the predicate `region-active-p' is needed to avoid calling them when there's no region."

  • `(,@(if (region-active-p)
  • (list (region-beginning) (region-end))
  • (list nil nil))
  • ,current-prefix-arg))
  • ;; `(,@(if (region-active-p)
  • ;; (list (region-beginning) (region-end))
  • ;; (list nil nil))
  • ;; ,current-prefix-arg))
  • (list
  • (if mark-active (region-beginning) nil)

Better they learn that if is really an or/and combo.

— Reply to this email directly, view it on GitHub https://github.com/emacsfodder/move-text/pull/22#discussion_r965625160, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZKU4CRWMP62EMKLBWRKZLV5GLQ5ANCNFSM6AAAAAAQG4YCJU . You are receiving this because you were mentioned.Message ID: @.***>

-- Fragen sind nicht da um beantwortet zu werden, Fragen sind da um gestellt zu werden Georg Kreisler

Headaches with a Juju log: unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run a leader-deposed hook here, but we can't yet