Ticket #534 (new defect)

Opened 11 years ago

Fixing the test files

Reported by: orseau Owned by: shawnpresser
Priority: major Milestone:
Component: shawnpresser/racket-unix-sockets.plt Keywords:
Cc: Version: (1 0)
Racket Version:

Description

Thanks a lot for this package, it will be very helpful.

The tests don't work properly as they are.
In particular, when installing the package from PLaneT, names tend to be quite long, raising the 100 characters long error.
Placing the socket in racket's pref-dir should be better.

Also, all racket files should begin with the "#lang" line. Usually "#lang racket" or "#lang racket/base" for non-GUI programs.

Last, it is usually advised that the test files should not reference the PLaneT package, but the updir main.rkt file instead.

Maybe there should also be a note in the readme telling to avoid testing the listener in DrRacket?, otherwise a crash may be expected ;)

Fixes for the test files:

-- test-connecting.rkt:
#lang racket
(require "../main.rkt")

(define-values (i o)

(unix-socket-connect

(build-path (find-system-path 'pref-dir)

"tmp-socket")))

(display "hello" o)

-- test-listenning.rkt:
#lang racket
(require "../main.rkt")

(define (serve path)

(define listener (unix-socket-listen path 5))
(printf "listening: ~a" listener)
(newline)
(define (loop)

(accept-and-handle listener)
(loop))

(loop))

(define (accept-and-handle listener)

(define-values (i o) (unix-socket-accept listener))
(printf "accepted: ~a" listener)
(newline)
(display (read-line i))
(newline))

(serve (build-path (find-system-path 'pref-dir) "tmp-socket"))

Note: See TracTickets for help on using tickets.