Comments (10)
@MartinJohns I can't easily test this, but can you try the following hack to see if it makes things work for you?
diff --git a/runtest.py b/runtest.py
index 436b769..c9d2ea8 100755
--- a/runtest.py
+++ b/runtest.py
@@ -12,9 +12,12 @@ import pty, array, fcntl, termios
IS_PY_3 = sys.version_info[0] == 3
-# TODO: do we need to support '\n' too
-sep = "\r\n"
-#sep = "\n"
+import platform
+if platform.system().find("CYGWIN_NT") >= 0:
+ # TODO: this is weird, is this really right on Cygwin?
+ sep = "\n\r\n"
+else:
+ sep = "\r\n"
rundir = None
parser = argparse.ArgumentParser(
from mal.
@MartinJohns had a chance to test the above change?
from mal.
@kanaka This patch (off master) works on Cygwin 64 (and probably 32, but I
didn't check); however, due to the nature of the change, I'd recommend you
test it on non-Cygwin. This is for make test^python^step0 -- confirmed
that without the change, the test fails; with the change, it passes.
diff --git a/runtest.py b/runtest.py
index 436b769..932dd82 100755
--- a/runtest.py
+++ b/runtest.py
@@ -12,9 +12,11 @@ import pty, array, fcntl, termios
IS_PY_3 = sys.version_info[0] == 3
-# TODO: do we need to support '\n' too
-sep = "\r\n"
-#sep = "\n"
+import platform
+if platform.system().find("CYGWIN_NT") >= 0:
- sep = "\r\n"
+else:
- sep = "\n"
rundir = None
parser = argparse.ArgumentParser(
@@ -120,7 +122,7 @@ class Runner():
args = parser.parse_args(sys.argv[1:])
-test_data = args.test_file.read().split('\n')
+test_data = args.test_file.read().split(sep)
if args.rundir: os.chdir(args.rundir)
from mal.
The "\n\r\n"
doesn't seem right. Git for Windows will automatically convert line endings to "\r\n"
, so the .mal
test files themselves will change when cloned on a Windows machine. If the test runner is assuming these files always have the Unix-style "\n"
endings, that could explain the problem.
I tried manually changing the tests/step0_repl.mal
file to Unix line endings and then the make test^python^step0
tests pass if I use Cygwin's python
. Tests using Windows' py -2
and py -3
still aren't passing on my setup, but this appears to be for unrelated reasons.
from mal.
The unrelated reason seems to be that Python for Windows doesn't include the readline
module, but the Python MAL implementation requires it. An example without this dependency could be illuminating.
This one-liner will pass the step0 test using Cygwin's python
, given a Unix-terminated test file. (It does not require readline
.)
while 1:print raw_input("user> ")
This still does not work when using Python for Windows:
----------------------------------------------
Testing test^python^step0, step file: python/step0_repl.py, test file: tests/ste
p0_repl.mal
Running: ../runtest.py ../tests/step0_repl.mal -- py -2 ../python/step0_repl.p
y
Did not one of following prompt(s): ['user> ', 'mal-user> ']
Got : ''
Makefile:199: recipe for target 'test^python^step0' failed
make: *** [test^python^step0] Error 1
Cygwin's python3
passes using
while 1:print(input("user> "))
But and Windows' py -3
has a different error:
----------------------------------------------
Testing test^python^step0, step file: python/step0_repl.py, test file: tests/ste
p0_repl.mal
Running: ../runtest.py ../tests/step0_repl.mal -- py -3 ../python/step0_repl.p
y
TEST: hello world -> ['',hello world] -> FAIL (line 2):
Expected : ['hello world\r\nhello world', 'hello world\r\nhello world\r\nhel
lo world']
Got : 'hello world\r\nhello world\r'
TEST: abcABC123 -> ['',abcABC123] -> FAIL (line 5):
Expected : ['abcABC123\r\nabcABC123', 'abcABC123\r\nabcABC123\r\nabcABC123']
Got : 'abcABC123\r\nabcABC123\r'
TEST: []{}"'* ;:() -> ['',[]{}"'* ;:()] -> FAIL (line 8):
Expected : ['[]{}"\'* ;:()\r\n[]{}"\'* ;:()', '[]{}"\'* ;:()\r\n[]{}"\'* ;:(
)\r\n[]{}"\'* ;:()']
Got : '[]{}"\'* ;:()\r\n[]{}"\'* ;:()\r'
TEST: hello world abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 01234567
89 (;:() []{}"'* ;:() []{}"'* ;:() []{}"'*) -> ['',hello world abcdefghijklmnopq
rstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 (;:() []{}"'* ;:() []{}"'* ;:()
[]{}"'*)] -> FAIL (line 13):
Expected : ['hello world abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWX
YZ 0123456789 (;:() []{}"\'* ;:() []{}"\'* ;:() []{}"\'*)\r\nhello world abcdefg
hijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 (;:() []{}"\'* ;:() []
{}"\'* ;:() []{}"\'*)', 'hello world abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOP
QRSTUVWXYZ 0123456789 (;:() []{}"\'* ;:() []{}"\'* ;:() []{}"\'*)\r\nhello world
abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 (;:() []{}"\'*
;:() []{}"\'* ;:() []{}"\'*)\r\nhello world abcdefghijklmnopqrstuvwxyz ABCDEFGH
IJKLMNOPQRSTUVWXYZ 0123456789 (;:() []{}"\'* ;:() []{}"\'* ;:() []{}"\'*)']
Got : 'hello world abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXY
Z 0123456789 (;:() []{}"\'* ;:() []{}"\'* ;:() []{}"\'*)\r\nhello world abcdefgh
ijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 (;:() []{}"\'* ;:() []{
}"\'* ;:() []{}"\'*)\r'
TEST RESULTS (for ../tests/step0_repl.mal):
0: soft failing tests
4: failing tests
0: passing tests
4: total tests
Makefile:199: recipe for target 'test^python^step0' failed
make: *** [test^python^step0] Error 1
This time it does appear to be an issue with line terminators, but changing back to "\r\n"
only makes it worse.
from mal.
I got tests working on Windows Under Cygwin64 withe following couple of changes. (This is a diff from Master)
@@ -125,11 +125,11 @@ class Runner():
debug(new_data)
if self.no_pty:
self.buf += new_data.replace("\n", "\r\n")
else:
self.buf += new_data
- self.buf = self.buf.replace("\r\r", "\r")
+ self.buf = self.buf.replace("\r\r", sep)
for prompt in prompts:
regexp = re.compile(prompt)
match = regexp.search(self.buf)
if match:
end = match.end()
@@ -191,17 +191,18 @@ class TestReader:
return True
continue
elif line[0:1] == ";": # unexpected comment
log("Test data error at line %d:\n%s" % (self.line_num, line))
return None
- self.form = line # the line is a form to send
+ # remove the last character. Writeline will insert the line ending.
+ self.form = line[0:len(line)-1] # the line is a form to send
# Now find the output and return value
while self.data:
line = self.data[0]
if line[0:3] == ";=>":
- self.ret = line[3:]
+ self.ret = line[3:].rstrip() + sep
self.line_num += 1
self.data.pop(0)
break
elif line[0:2] == "; ":
self.out = self.out + line[2:] + sep
I think part of the problem, as stated above, is that when the repo is clones with Git on Windows, the line endings are changed to \r\n. Adding the conditional sep
assignment was useful, but was not carried through on the reads and writes. All tests are working for me now. Not sure how this would affect non-windows users.
from mal.
@nukecoder that patch breaks tests on Linux.
If somebody suggests a clean patch that will work on Linux, OS X and Windows (cygwin or native but both would be a plus) I'll be happy to merge it. I don't have a convenient way to test all three (only Linux).
from mal.
According to @nukecoder 's message another thing we should pay attention to is Git's translation of line endings - apparently on Windows git will auto-translate line endings to \r\n
- just to add some more noise to the party.
from mal.
It seems like sep = "\r\n"
works well on cygwin now.
cygwin version
$ uname -a
CYGWIN_NT-10.0 wos-ThinkPad 2.11.2(0.329/5/3) 2018-11-08 14:34 x86_64 Cygwin
Tested (passed all tests): awk
, bash
, make
, perl
, python
, powershell
from mal.
Okay, seems like this has been resolved and tested by @inkydragon in #396 (thanks!) so I'm going to close it.
from mal.
Related Issues (20)
- Does there exist implementation of emacs written in mal? HOT 1
- Consider merging eval, eval-ast and macroexpand
- Problem Running Tests with Readline Library in C HOT 4
- Newline Escaping HOT 1
- What was used to make the MAL diagram? HOT 1
- what is the minimum requirement for the base language? HOT 1
- Verilog: is there a good reason mal has not been implemented? HOT 1
- VHDL: defmacro! doesn't modify existing functions HOT 1
- make "test^js^step0" fails -- Fatal error in , line 0 -- Check failed: result.second. HOT 1
- PDFs?
- Somebody should solve Rosetta Code challenges with mal
- Mal in Coq? HOT 1
- Apparently in step 3 'env' is a class or structure type, not an object
- Questions on different design from lisp: Mal symbol do not use property lists?
- Lots of unanswered merge requests
- Why is quasiquote so complicated? HOT 3
- What with `` gensym ''
- lexicial versus dynamic
- Floats don't work in the python implementation.
- Is #mal IRC channel still active? people seems tends to use discord now XD
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mal.