From 307673ec253e63802aaf53e1e76520d3389facbf Mon Sep 17 00:00:00 2001 From: Curtis Vogt Date: Thu, 23 Jun 2016 21:16:47 -0400 Subject: [PATCH 1/4] Emulate REPL behaviour --- juliadoc/jldoctest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/juliadoc/jldoctest.py b/juliadoc/jldoctest.py index a23f79e..8d5b479 100644 --- a/juliadoc/jldoctest.py +++ b/juliadoc/jldoctest.py @@ -808,6 +808,7 @@ def test_group(self, group, filename): j = Popen(["../julia"], stdin=PIPE, stdout=PIPE, stderr=STDOUT) j.stdin.write("macro raw_str(s) s end;nothing\n".encode('utf-8')) j.stdin.write("_ans = nothing\n".encode('utf-8')) + j.stdin.write("pushdisplay(TextDisplay(IOContext(IOContext(STDOUT, :multiline => true), :limit => true))); nothing\n".encode('utf-8')) self.setup_runner.julia = j self.test_runner.julia = j self.cleanup_runner.julia = j From ca46f12a60b77584fd223e3fa91be6b821d1f933 Mon Sep 17 00:00:00 2001 From: Curtis Vogt Date: Fri, 24 Jun 2016 19:40:57 -0400 Subject: [PATCH 2/4] Fix doctests from hanging when missing trailing \n The `dump` call was not providing a trailing newline which was causing the doctests to hang since the seperator never appeared on its own line. Code has been changed such that the seperator will always appear after a newline. --- juliadoc/jldoctest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/juliadoc/jldoctest.py b/juliadoc/jldoctest.py index 8d5b479..2986f20 100644 --- a/juliadoc/jldoctest.py +++ b/juliadoc/jldoctest.py @@ -480,14 +480,14 @@ def __run(self, test, out): self.julia.stdin.write('_ans=ans; nothing\n'.encode('utf-8')) # read separator sep = 'fjsdiij3oi123j42' - self.julia.stdin.write(('println("' + sep + '")\n').encode('utf-8')) + self.julia.stdin.write(('println("\\n' + sep + '")\n').encode('utf-8')) self.julia.stdin.flush() got = [] line = '' while line[:-1] != sep: got.append(line) line = self.julia.stdout.readline().decode('utf-8').rstrip() + '\n' - got = ''.join(got).expandtabs() + got = ''.join(got).expandtabs()[:-1] exception = None except KeyboardInterrupt: raise From d1b31df6bc93f63a89cba424e4914f5fe4a6b600 Mon Sep 17 00:00:00 2001 From: Curtis Vogt Date: Fri, 24 Jun 2016 21:13:32 -0400 Subject: [PATCH 3/4] Fix exception in report_failure Issue was due to `self._checker.output_difference` and `self._failure_header` sometimes returning different types (unicode and string). --- juliadoc/jldoctest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/juliadoc/jldoctest.py b/juliadoc/jldoctest.py index 2986f20..df51e3c 100644 --- a/juliadoc/jldoctest.py +++ b/juliadoc/jldoctest.py @@ -384,8 +384,8 @@ def report_failure(self, out, test, example, got): Report that the given example failed. """ try: - out(self._failure_header(test, example) + - self._checker.output_difference(example, got, self.optionflags)) + out(self._failure_header(test, example)) + out(self._checker.output_difference(example, got, self.optionflags)) except: raise Exception(example.want, got) From de608d53f30574b581c0dfb67c024a3952325967 Mon Sep 17 00:00:00 2001 From: Curtis Vogt Date: Sat, 25 Jun 2016 09:20:01 -0400 Subject: [PATCH 4/4] REPL emulation now only applies to 0.5 Additionally broke up the long `pushdisplay` line. --- juliadoc/jldoctest.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/juliadoc/jldoctest.py b/juliadoc/jldoctest.py index df51e3c..4493cea 100644 --- a/juliadoc/jldoctest.py +++ b/juliadoc/jldoctest.py @@ -808,7 +808,15 @@ def test_group(self, group, filename): j = Popen(["../julia"], stdin=PIPE, stdout=PIPE, stderr=STDOUT) j.stdin.write("macro raw_str(s) s end;nothing\n".encode('utf-8')) j.stdin.write("_ans = nothing\n".encode('utf-8')) - j.stdin.write("pushdisplay(TextDisplay(IOContext(IOContext(STDOUT, :multiline => true), :limit => true))); nothing\n".encode('utf-8')) + j.stdin.write(""" + if VERSION >= v"0.5.0-dev+1911" + pushdisplay(TextDisplay( + IOContext(IOContext(STDOUT, :multiline => true), :limit => true) + )); + nothing + end + """.encode('utf-8') + ) self.setup_runner.julia = j self.test_runner.julia = j self.cleanup_runner.julia = j