diff --git a/java/src/main/java/mal/step0_repl.java b/java/src/main/java/mal/step0_repl.java index 060f43e3..b966a1f7 100644 --- a/java/src/main/java/mal/step0_repl.java +++ b/java/src/main/java/mal/step0_repl.java @@ -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) { diff --git a/mal/step0_repl.mal b/mal/step0_repl.mal new file mode 100644 index 00000000..723c83c4 --- /dev/null +++ b/mal/step0_repl.mal @@ -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) diff --git a/ps/step0_repl.ps b/ps/step0_repl.ps index d26844c5..b7c2f175 100644 --- a/ps/step0_repl.ps +++ b/ps/step0_repl.ps @@ -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 diff --git a/runtest.py b/runtest.py index 7e1e16d2..8871bb83 100755 --- a/runtest.py +++ b/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, diff --git a/tests/docker/Dockerfile b/tests/docker/Dockerfile index d06f4194..a20bb696 100644 --- a/tests/docker/Dockerfile +++ b/tests/docker/Dockerfile @@ -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 diff --git a/tests/step0_repl.mal b/tests/step0_repl.mal index d5cba95c..70e2b7b6 100644 --- a/tests/step0_repl.mal +++ b/tests/step0_repl.mal @@ -6,3 +6,9 @@ abcABC123 ;:() []{}"'* ;=>;:() []{}"'* + + +;;; Test long line +hello world abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 (;:() []{}"'* ;:() []{}"'* ;:() []{}"'*) +;=>hello world abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 (;:() []{}"'* ;:() []{}"'* ;:() []{}"'*) +