Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 (#689)

* Add some tests for racket/htdp#228, racket/htdp#229, and racket/htdp#230 to
  `tests/drracket/module-lang-test`.

  + Tests of racket/htdp#229 should first save the buffer to disk before running
  + Some racket/htdp#229 tests are ported from htdp-test:intm-lam.rktl

* Update `tests/drracket/language-test` to match racket/htdp#229.

* Manually check for empty stderr in tests/drracket/module-lang-test

  Somehow `-e`/`--check-stderr` does not work with `tests/drracket/module-lang-test`
  (perhaps due to using `test-log` + `exit 0` in `fire-up-drracket-and-run-tests`?)

* Test utils: sleep for 0.1s after printing error msg

  In tests/drracket/module-lang-test, stderr goes through a pipe to be
  checked for the absence of error messages. Therefore, sleep for 0.1s
  before existing to let the background thread pipe the messages to terminal.
  • Loading branch information
shhyou authored Nov 11, 2024
1 parent d27a480 commit 0375cc8
Show file tree
Hide file tree
Showing 4 changed files with 551 additions and 16 deletions.
8 changes: 4 additions & 4 deletions drracket-test/tests/drracket/language-test.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -1326,8 +1326,8 @@ the settings above should match r5rs
(test-undefined-fn "(print (floor (sqrt 2)))" "print")

(test-expression "(let ([f (lambda (x) x)]) f)"
"(lambda (a1) ...)"
"(lambda (a1) ...)")
"f"
"f")
(test-expression ",1"
"unquote: misuse of a comma or unquote, not under a quasiquoting backquote")

Expand Down Expand Up @@ -1503,8 +1503,8 @@ the settings above should match r5rs
(test-expression "(print (floor (sqrt 2)))" "#i1.0")

(test-expression "(let ([f (lambda (x) x)]) f)"
"(lambda (a1) ...)"
"(lambda (a1) ...)")
"f"
"f")
(test-expression ",1"
"unquote: misuse of a comma or unquote, not under a quasiquoting backquote")

Expand Down
Loading

3 comments on commit 0375cc8

@shhyou
Copy link
Collaborator Author

@shhyou shhyou commented on 0375cc8 Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The errors should disappear tomorrow after a new snapshot build (with the updated htdp-lib) lands:

  xvfb-run -a raco test -e -l tests/drracket/module-lang-test
  shell: /usr/bin/bash -e {0}
raco test: (submod (file "/home/runner/work/drracket/drracket/drracket-test/tests/drracket/module-lang-test.rkt") test)
raco test: @(test-responsible 'robby)
FAILED line 583: #lang htdp/isl+
(define p (make-posn 7 3))
(check-expect posn-x 7)

  extra assertion expected: #px"check-expect[ a-z]+error.*[^\n]+\n.*::.*at line 3, column 0 first argument.*function.*given posn-x[^\n]*\nat line 3, column 0"

  got: Ran 1 test.
0 tests passed.

Check failures:
        check-expect encountered the following error instead of the expected value, 7. 
   ::  at line 3, column 0 first argument of equality cannot be a function, given (lambda (a1) ...)
at line 3, column 0
> 
FAILED line 583; extra assertion returned #f
FAILED (line 684): #lang htdp/isl+

(define (my-add1 n) (+ n 1))
my-add1
(check-expect my-add1 2)

(let ([keep-parity (lambda (m)
                     (+ m 2))])
  keep-parity)

(local [(define alt-parity (lambda (m)
                             (- 1 m)))]
  alt-parity)

(let ()
  (lambda (m)
    (+ m 2)))

(local [(define lam-in-if
         (if (> (random 10) 5)
             (lambda (x) (+ x 5))
             (lambda (y) (* y 2))))]
 lam-in-if)

        no-interactions
  expected: #rx"^my-add1.*keep-parity.*alt-parity.*[(]lambda [(]a1[)] [.][.][.][)].*lam-in-if.*Ran 1 test[.].*0 tests passed[.]"
       got: "(lambda (a1) ...)\n(lambda (a1) ...)\n(lambda (a1) ...)\n(lambda (a1) ...)\n(lambda (a1) ...)\nRan 1 test.\n0 tests passed.\n\nCheck failures:\n        .\n."
FAILED line 684: #lang htdp/isl+

(define (my-add1 n) (+ n 1))
my-add1
(check-expect my-add1 2)

(let ([keep-parity (lambda (m)
                     (+ m 2))])
  keep-parity)

(local [(define alt-parity (lambda (m)
                             (- 1 m)))]
  alt-parity)

(let ()
  (lambda (m)
    (+ m 2)))

(local [(define lam-in-if
         (if (> (random 10) 5)
             (lambda (x) (+ x 5))
             (lambda (y) (* y 2))))]
 lam-in-if)

  extra assertion expected: #px"::\\s+in gh208-pr229-islplus\\.rkt, line 5, column 0[^\n]+function[^\n]+given my-add1"

  got: (lambda (a1) ...)
(lambda (a1) ...)
(lambda (a1) ...)
(lambda (a1) ...)
(lambda (a1) ...)
Ran 1 test.
0 tests passed.

Check failures:
        check-expect encountered the following error instead of the expected value, 2. 
   ::  in gh208-pr229-islplus.rkt, line 5, column 0 first argument of equality cannot be a function, given (lambda (a1) ...)
in gh208-pr229-islplus.rkt, line 5, column 0
> 
FAILED line 684; extra assertion returned #f
FAILED (line 744): #lang htdp/isl+

(define (my-add1 n) (+ n 1))
my-add1
(check-expect my-add1 2)

(let ([keep-parity (lambda (m)
                     (+ m 2))])
  keep-parity)

(local [(define alt-parity (lambda (m)
                             (- 1 m)))]
  alt-parity)

(let ()
  (lambda (m)
    (+ m 2)))

(local [(define lam-in-if
         (if (> (random 10) 5)
             (lambda (x) (+ x 5))
             (lambda (y) (* y 2))))]
 lam-in-if)

        no-interactions
  expected: #rx"^my-add1.*keep-parity.*alt-parity.*[(]lambda [(]a1[)] [.][.][.][)].*lam-in-if.*Ran 1 test[.].*0 tests passed[.]"
       got: "(lambda (a1) ...)\n(lambda (a1) ...)\n(lambda (a1) ...)\n(lambda (a1) ...)\n(lambda (a1) ...)\nRan 1 test.\n0 tests passed.\n\nCheck failures:\n        .\n."
FAILED line 744; extra assertion returned #f
FAILED (line 850): #lang htdp/isl+
   (map (lambda (x y) (+ x y)) (list 2 3 4))
        no-interactions
  expected: #rx"map: first argument must be a function that expects one argument,.*given \\(lambda \\(a1 a2\\) \\.\\.\\.\\)"
       got: ". . map: first argument must be a function that expects one argument, given ...ts-intm-lam-map.rkt:2:8"
stacks from error message:

----
  /var/tmp/htdp-tests-intm-lam-map.rkt:2:3
----

----
  /home/runner/racket-current-CS/share/pkgs/htdp-lib/lang/private/teachprims.rkt:423:0
  /home/runner/racket-current-CS/share/pkgs/htdp-lib/lang/private/teachprims.rkt:416:2
----
FAILED (line 879): #lang htdp/isl+
   (foldr (lambda (x y) (+ x y)) 0 (list 2 3 4) (list 2 3 4))
        no-interactions
  expected: #rx"foldr: first argument must be a function that expects three arguments,.*given \\(lambda \\(a1 a2\\) \\.\\.\\.\\)"
       got: ". . foldr: first argument must be a function that expects three arguments, given ...intm-lam-foldr2.rkt:2:10"
stacks from error message:

----
  /var/tmp/htdp-tests-intm-lam-foldr2.rkt:2:3
----

----
  /home/runner/racket-current-CS/share/pkgs/htdp-lib/lang/private/teachprims.rkt:423:0
  /home/runner/racket-current-CS/share/pkgs/htdp-lib/lang/private/teachprims.rkt:409:14
----
FAILED (line 908): #lang htdp/isl+
   (foldr (lambda (x y z) (+ x y z)) 0 (list 2 3 4))
        no-interactions
  expected: #rx"foldr: first argument must be a function that expects two arguments,.*given \\(lambda \\(a1 a2 a3\\) \\.\\.\\.\\)"
       got: ". . foldr: first argument must be a function that expects two arguments, given ...intm-lam-foldr3.rkt:2:10"
stacks from error message:

----
  /var/tmp/htdp-tests-intm-lam-foldr3.rkt:2:3
----

----
  /home/runner/racket-current-CS/share/pkgs/htdp-lib/lang/private/teachprims.rkt:423:0
  /home/runner/racket-current-CS/share/pkgs/htdp-lib/lang/private/teachprims.rkt:409:14
----
non-empty stderr
#t
Error: Process completed with exit code 1.

@rfindler
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you say why you had to add the sleep/yield call?

@shhyou
Copy link
Collaborator Author

@shhyou shhyou commented on 0375cc8 Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this commit, current-error-port is piped through an intermediate port to be checked for cleanness in order for the exit code checking of GH CI to work.

(module test racket/base
(require racket/port syntax/location)
(define-values (inp outp) (make-pipe))
(define tee-error-port (open-output-bytes 'tee-stderr))
(define stderr (current-error-port))
(void
(thread
(λ () (copy-port inp tee-error-port stderr))))

The sleep/yield call is an attempt to hope that the intermediate port is flushed before the program exits.

Please sign in to comment.