mirror of
https://github.com/kanaka/mal.git
synced 2024-10-26 14:22:25 +03:00
runtest: set pty size to fix readline of long lines.
- Also, add a long line test to step0 tests. - Fix java step0 arg parsing. - Fix postscript long line reads (larger buffer) - Add mal step0_repl
This commit is contained in:
parent
798206accb
commit
b3c30da9fc
@ -28,7 +28,7 @@ public class step0_repl {
|
||||
public static void main(String[] args) {
|
||||
String prompt = "user> ";
|
||||
|
||||
if (args[0].equals("--raw")) {
|
||||
if (args.length > 0 && args[0].equals("--raw")) {
|
||||
readline.mode = readline.Mode.JAVA;
|
||||
}
|
||||
while (true) {
|
||||
|
30
mal/step0_repl.mal
Normal file
30
mal/step0_repl.mal
Normal file
@ -0,0 +1,30 @@
|
||||
;; read
|
||||
(def! READ (fn* [strng]
|
||||
strng))
|
||||
|
||||
;; eval
|
||||
(def! EVAL (fn* [ast env]
|
||||
ast))
|
||||
|
||||
;; print
|
||||
(def! PRINT (fn* [exp] exp))
|
||||
|
||||
;; repl
|
||||
(def! rep (fn* [strng]
|
||||
(PRINT (EVAL (READ strng) {}))))
|
||||
|
||||
;; repl loop
|
||||
(def! repl-loop (fn* []
|
||||
(let* [line (readline "mal-user> ")]
|
||||
(if line
|
||||
(do
|
||||
(if (not (= "" line))
|
||||
(try*
|
||||
(println (rep line))
|
||||
(catch* exc
|
||||
(println "Uncaught exception:" exc))))
|
||||
(repl-loop))))))
|
||||
|
||||
(def! -main (fn* [& args]
|
||||
(repl-loop)))
|
||||
(-main)
|
@ -1,5 +1,5 @@
|
||||
% read
|
||||
/_readline { print flush (%stdin) (r) file 99 string readline } def
|
||||
/_readline { print flush (%stdin) (r) file 1024 string readline } def
|
||||
|
||||
/READ {
|
||||
% just "return" the input string
|
||||
|
11
runtest.py
11
runtest.py
@ -2,11 +2,14 @@
|
||||
|
||||
import os, sys, re
|
||||
import argparse, time
|
||||
import signal, atexit
|
||||
|
||||
import pty, signal, atexit
|
||||
from subprocess import Popen, STDOUT, PIPE
|
||||
from select import select
|
||||
|
||||
# Pseudo-TTY and terminal manipulation
|
||||
import pty, array, fcntl, termios
|
||||
|
||||
IS_PY_3 = sys.version_info[0] == 3
|
||||
|
||||
# TODO: do we need to support '\n' too
|
||||
@ -54,6 +57,12 @@ class Runner():
|
||||
else:
|
||||
# provide tty to get 'interactive' readline to work
|
||||
master, slave = pty.openpty()
|
||||
|
||||
# Set terminal size large so that readline will not send
|
||||
# ANSI/VT escape codes when the lines are long.
|
||||
buf = array.array('h', [100, 200, 0, 0])
|
||||
fcntl.ioctl(master, termios.TIOCSWINSZ, buf, True)
|
||||
|
||||
self.p = Popen(args, bufsize=0,
|
||||
stdin=slave, stdout=slave, stderr=STDOUT,
|
||||
preexec_fn=os.setsid,
|
||||
|
@ -17,7 +17,7 @@ RUN apt-get -y install make wget curl git
|
||||
RUN apt-get -y install gcc pkg-config
|
||||
|
||||
# Deps for Java-based languages (Clojure, Scala, Java)
|
||||
RUN apt-get -y install openjdk-7-jre-headless
|
||||
RUN apt-get -y install openjdk-7-jdk
|
||||
ENV MAVEN_OPTS -Duser.home=/mal
|
||||
|
||||
# Deps for Mono-based languages (C#, VB.Net)
|
||||
@ -44,6 +44,7 @@ ADD https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein \
|
||||
/usr/local/bin/lein
|
||||
RUN sudo chmod 0755 /usr/local/bin/lein
|
||||
ENV LEIN_HOME /mal/.lein
|
||||
ENV LEIN_JVM_OPTS -Duser.home=/mal
|
||||
|
||||
# CoffeeScript
|
||||
RUN npm install -g coffee-script
|
||||
@ -124,9 +125,6 @@ ENV SBT_OPTS -Duser.home=/mal
|
||||
# VB.Net
|
||||
RUN apt-get -y install mono-vbnc
|
||||
|
||||
# TODO: move this up with Clojure
|
||||
ENV LEIN_JVM_OPTS -Duser.home=/mal
|
||||
|
||||
# MATLAB is proprietary/licensed. Maybe someday with Octave.
|
||||
ENV SKIP_IMPLS matlab
|
||||
|
||||
|
@ -6,3 +6,9 @@ abcABC123
|
||||
|
||||
;:() []{}"'*
|
||||
;=>;:() []{}"'*
|
||||
|
||||
|
||||
;;; Test long line
|
||||
hello world abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 (;:() []{}"'* ;:() []{}"'* ;:() []{}"'*)
|
||||
;=>hello world abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 (;:() []{}"'* ;:() []{}"'* ;:() []{}"'*)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user