-
Notifications
You must be signed in to change notification settings - Fork 316
/
Copy pathmisc-devel.R
32 lines (28 loc) · 971 Bytes
/
misc-devel.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#### Regression and other checks for 'make check-devel' but *not* for 'make check'
## PR#18555: dummy_fgetc() returning EOF if the connection has an encoding specified
# try to find an available port
port <- NULL
for(p in round(runif(100, 27000, 28000))) {
sock <- tryCatch(serverSocket(p), error= function(e) NULL)
if (!is.null(sock)) {
port <- p
break
}
}
stopifnot(!is.null(port))
outgoing <- socketConnection("localhost", port)
incoming <- socketAccept(sock, encoding="UTF-8")
close(sock)
r <- readLines(incoming, 1) # sets EOF_signalled
stopifnot(identical(r, character(0)))
writeLines("hello", outgoing)
close(outgoing)
r <- readLines(incoming, 1) # due to EOF_signalled, readLines() didn't realize
# that more data became available
while(isIncomplete(incoming)) {
socketSelect(list(incoming))
r <- readLines(incoming, 1)
}
close(incoming)
stopifnot(identical(r, "hello")) # r was character(0) in error
proc.time()