Giter Site home page Giter Site logo

Comments (6)

jquast avatar jquast commented on September 26, 2024

accordingly to my test, https://travis-ci.org/Microalg/Microalg/builds/24602682 I would suspect that you've omitted a few key:

        world.output += world.process.after.rstrip('\n')

as you can see, the text you are seeking, is actually available in world.after at the time of the exception. What do you think?

I'm glad the # comments and variable_names were english, I understand just enough to know it looks interesting :-) good luck

from pexpect.

Grahack avatar Grahack commented on September 26, 2024

abusing your pull to get your travis to display a few more details

You are welcome!!!

accordingly to my test, https://travis-ci.org/Microalg/Microalg/builds/24602682
I would suspect that you've omitted a few key:
world.output += world.process.after.rstrip('\n')

Not sure. This doesn't explain why it works on my machine but nothing appears on Travis.

as you can see, the text you are seeking, is actually available in world.after
at the time of the exception. What do you think?

Mmmh. I can only see after: <class 'pexpect.EOF'>.

I'm glad the # comments and variable_names were english,
I understand just enough to know it looks interesting :-) good luck

Good practice always pay!

This project only targets French people, but I thought this CLI Lettuce steps would be generic enough to be reusable. Hence the # comments and variable_names for a possible publication.

Did you fork+clone on a local machine or just tweaked my files online?
I'm curious to see if it works for you locally...

from pexpect.

jquast avatar jquast commented on September 26, 2024

Hey @Grahack I'll absolutely look at this again this weekend, any updates (theories?) since last spoke? I'll reproduce locally with mac and linux and see what I think.

from pexpect.

Grahack avatar Grahack commented on September 26, 2024

Thanks for considering this issue.
Things are worse and better:

  • worse since things now go wrong on my machine too,
  • better because its easier to test locally and not on Travis ;)

My theory is that it is a flush issue.

I wrote some install docs here for you since the only docs I have are in French.
Sorry, this is quite big, but only needed once. For a minimal one, see at the bottom of this post.

For the big one:

  • clone
  • my project is a language embedded in a Lisp called PicoLisp, so you have to install two versions of Picolisp (run the two install scripts, or adapt content)
    • the main one (C/ASM), a C toolchain is needed for the installation
    • a Java version called Ersatz, only java is needed (and not javac since a .jar is provided) to run it
  • NodeJS is needed too since a third implementation of PicoLisp is Node-based, the node module is in the repo.
  • see .travis.yml for some other requirements (including pexpect!)
  • from the root of the clone, PATH=$PATH:pwd:pwd/picolisp:pwd/ersatz:pwd/emulisp

Now you can lettuce or lettuce -v 2… and see the fails.

One suggestion I have is to run the failing examples and see that in fact they work well:

  • run by hand, like pil exemples/test_read.l or malgjs exemples/test_demander.malg
  • run with pexpect interactively, like:

    >>> import pexpect
    >>> child = pexpect.spawn('pil', ['exemples/test_read.l'])
    >>> child.expect('.*')
    0
    >>> child.after
    "Votre nom ?"\r\n'
    >>> child.sendline('jquast')
    7
    >>> child.expect('.*')
    0
    >>> child.after
    jquast\r\n"Salut jquast"\r\n'
    >>> child.expect(pexpect.EOF)   # Strange: I call child.expect('.*') in the original script.
    0
    >>>

Minimal setup:

  • clone
  • install lettuce, fix lettuce (see the script fix_lettuce.sh)
  • install pexpect (ya know, this interesting project I once told you about ;)
  • install nodejs and the sync-prompt module (if possible, I know it's hard on Windows)
  • lettuce -v 2 -s 6 features/hello.feature to see it fail with pexpect
  • see it work too:
    • by hand: run malgjs exemple/test_demander.malg to see it work by hand
    • in the Python prompt, as above, to see it work with pexpect

from pexpect.

jquast avatar jquast commented on September 26, 2024

I'm very sure this is due to greedy ".*" search. You are in a race, processes and buffers are racing at different speeds, ".*" is simply too greedy. You need to expect newlines, if "for each line input, expect each line output" is desired. Expecting ".*" might match well.. nothing !

>>> bool(re.search(pattern=".*", string=""))
True

I think I can submit a patch to your cli.py, we will see.

from pexpect.

jquast avatar jquast commented on September 26, 2024

I was not able to get the nodejs version (can't find it using npm), nor the java version (its not clear how it is installed, it certainly is called 'pilj' on my system) of picolisp installed correctly.

regardless i submitted pull to your project https://github.com/jquast/Microalg/commit/b8215fa11fa344c21a4c5d98ee516ebbdda8b1ab

the root of the issue is your expecting of .*, i'm very certain of it. Where your tests fail, if you simply display the world.process object, you will see the data you desire in world.process.after, not world.process.before, because your expect will match anything, even nothing.

I recommend you work around the concept of a repl, with a PROMPT. picolisp has one, and you can expect \r\n : -- unfortunately one of your test cases overrides that with its own custom prompt, so I can't really recommend it in bin/cli.py except for some kind of parameter.

maybe even look into @takluyver work in adding a "replwrapper" #51

from pexpect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.