Giter Site home page Giter Site logo

Comments (4)

nwhetsell avatar nwhetsell commented on August 17, 2024 1

Thank you again for responding.

The problem with using require here is that test.rb ends with a call to exit:

exit 0 if !@noexit

This means something like

ruby -e 'require("./test.rb")' \
     -e 'puts ENV.keys' \
     /Applications/Max.app

cannot work. Ruby exits immediately after the call to require, and the puts is never reached.

It seems like the most straightforward way to fix this (that is, to get a usable exit code) is to patch the last line of test.rb.

from max-test.

benbrackenc74 avatar benbrackenc74 commented on August 17, 2024

In the current state of things, the test runner always succeeds, and it is the expectation that the results will need to be parsed.

As far as the "environment variables" used here, in this case the ENV class is used to pass on the variable to a parent ruby process, nothing more. So if you had a parent ruby script that spawned test.rb, it should have access to these variables.

from max-test.

nwhetsell avatar nwhetsell commented on August 17, 2024

@benbrackenc74 Thank you for your response.

So if you had a parent ruby script that spawned test.rb, it should have access to these variables.

Iā€™m not sure I follow this. Whether I run (on macOS)

ruby -e 'system("ruby test.rb /Applications/Max.app")' \
     -e 'puts ENV.keys'

or

ruby -e 'require "open3"' \
     -e 'stdout, stderr = Open3.capture3("ruby test.rb /Applications/Max.app")' \
     -e 'puts stdout' \
     -e 'puts stderr' \
     -e 'puts ENV.keys'

or

ruby -e 'pid = spawn("ruby test.rb /Applications/Max.app")' \
     -e 'Process.wait pid' \
     -e 'puts ENV.keys'

I do not see MAXTEST or MAXTEST_PASS among ENV.keys. Is there some other way to spawn a Ruby process that Iā€™m missing?

from max-test.

benbrackenc74 avatar benbrackenc74 commented on August 17, 2024

I've done something like this before using require:

in env_sub.rb:
ENV['AN_ENV_VARIABLE'] = 'cool!'

in env_main.rb:

require './env_sub.rb'
puts ENV['AN_ENV_VARIABLE']

from max-test.

Related Issues (16)

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.