Arguments to PyUnit not parsed correctly - eclipse

When we try to run a PyUnit test in Eclipse as a Python unit-test, it fails. This is because the arguments sent to PyUnit come in the following order: file-to-test --port portno. We have discovered that there is an environment variable called POSIXLY_CORRECT that, if set, makes PyUnit expect the arguments to come in a certain order, options first.
We have looked everywhere in Eclipse to try and find where these arguments are set, but are unable to find them. So as a workaround we change the run configuration to use an environment without the POSIXLY_CORRECT set. But this is very awkward.
Does anyone know how to solve this so that we do not need to modify the run configurations to be able to run our tests?

Related

Get CircleCI environment variables into Swift via Fastlane

I want to add some secrets to CircleCI environment variables so that its not hardcoded in my project for security and so that we can cycle them as needed too.
I know I can access the environment variables from Fastlane with ENV["SOME_ENVIRONMENT_VARIABLE_KEY"] and from what I understand I can pass that into build_app's xcargs parameter. This is supposedly then available in build phase in Xcode.
eg build_app(..., xcargs: "Testing='SUCCESS'")
I cannot seem to find much documentation on this but I did see in a couple questions that you should be able to add a step to Build Phases and then in the script you export an environment variable that can be used in code. I tried export TESTING=${Testing} and when I try access that in code it (with ProcessInfo.processInfo.environment["TESTING"]) it comes back as nil.
I was not convinced that my script was actually doing anything so hardcoded it in the build phase to export TESTING="SUCCESS" and even then ProcessInfo.processInfo.environment["TESTING"] comes back as nil, just to be sure I added a breakpoint and printed ProcessInfo.processInfo.environment.keys and the TESTING key is not present
I have tried running from Fastlane directly with both the hardcoded value in the build phase and the variable that should come back from Fastlane and, despited me having prints in the unit test and echos in the script, nothing prints (It does print ▸ Running script 'Set up environment variables from CircleCI' but not my debugging echos where I print a string just to see where I am and try print all the environment variables and doesn't print anything for the unit test)
Am I missing something very obvious here? Surely it shouldn't be this complicated?
Thanks in advance

VSCode Test Explorer Pytest Inject Environment Variables using AWS Parameter Store

I am currently Using Pytest though the Python Test Explorer (see screen). I would like to pass my tests some environment variables at runtime. However, I currently get my AWS Parameter Store BEFORE I run tests. Meaning, I run a command in BASH that loads my environment variables into my current terminal session. Then I can run my test from the command line using pytest exampletest.py, and it finds the environment variable perfectly.
Trying to run exampletest.py from the integrated VSCode Test Explorer results in an error telling me that it could not find my environment variable. This means that whatever environment that is used when you hit the "Play Button" on the Test Explorer is not the same terminal session that I set my environment variables in.
The conventional way of setting environment variables such that they can be accessed when using the Test Explorer in VSCode is by either using an ini file or a .env file. The only caveat there is that you must hardcode the key value pair. I would not like to hardcode anything, as I would just like to inject them in at runtime from aws Parameter Store.
I really would like to continue using the Test Explorer to run my tests, as it has been great in the past, but if I cannot find a way to somehow get the Test Explorer to use my environment variables without using an ini or a .env file, I may have to abandon it.
Some questions:
When you click the play button on the Test Explorer to execute a test or suite of tests, what exactly happens? Does it open a Terminal session? Can you access that terminal session before runtime?
How does the Test Explorer set environment variables. When I raise Exception(os.environ), I can see all the environment variables that are quite different from the ones that I get when I run from the command line.
Is there a way to say "Hey Test Explorer, please run the tests inside of this specified Terminal window that is already running"
Perhaps a virtual environment is a way to go (not really a question more of a thought). Doing some cursory research reveals more headaches to come if I pursue this route I believe.
Do you have any further reading about that VsCode Test Explorer that goes beyond the official documentation. I feel like I can make some changes to it's source code or something, but I feel like documentation on it is a bit lacking.
Let me know your thoughts on this matter, and thanks in advance.
I have the same question. The only way I could make it work was by this unwieldy series of steps before running the tests via the vscode UI:
Execute your script or command in a terminal to set the env
variables.
Copy those env variables into your .env file (placed at the root of your project/vscode-workspace). I usually do :
env | grep AWS_ or whatever you want and you'll see them as name-value pairs. I then copy and paste those entries at the bottom of the .env file each time I run the test via the UI.
Now execute your tests via the vscode UI (the test 'beaker'/flask). The testing UI/flask seems to execute the .env file every time before it runs the tests and hence picks up those env variables.
I know, it's not preferable - you would want it to just pick it up from the env values you see in your integrated terminal but so far that is not happening.

Creating VSCode Debugger Extension

I'm in the process of trying to write a VSCode extension to support basic SNES application development. I already have a basic grammar definition and build task, so I have syntax highlighting, and am able to build my project with Ctrl+Shift+B using the bass v14 assembler, but now I'm trying to figure out how to launch the project using launch.json. I've already worked through the official docs and played around with the mock debugger project, but I can't seem to figure out how to adapt it for my extension. To start, I'm using the bsnes-plus emulator as my debugger. There isn't really any command-line or IPC interface that will actually allow me to implement a proper debug adapter, so all I really want to do is to run the program and pass it my output file to launch. For the time being, I'm assuming that bsnes-plus.exe is located in my $PATH, but eventually I'll try and figure out the best practices for external executable dependencies for an extension.
So here are my current questions:
Is the "program" field of launch.json my compiled application, or is it bsnes-plus.exe?
If "program" is my application, where do I specify bsnes-plus.exe? Or vice versa.
Is there a way to specify my own project-level variables, e.g. $OUTPUT so that I don't have to hard-code the output filename into both the build task and the launch task?
At one point, I was able to get the launch command to open bsnes-plus, but not load the game, and when I closed it, VSCode complained that the debugger terminated unexpectedly and immediately re-opened bsnes-plus. How do I avoid this? Do I need to write a debug adapter even though it's not going to actually do anything other than launch the application, just so I can tell VSCode that it exited cleanly?
Is the "program" field of launch.json my compiled application, or is it bsnes-plus.exe?
This is entirely up to the debug extension. It's just passed through to the debug adapter. It usually corresponds to the specific app/script being debugged though, not the runtime that's running it, so I would suggest it should be your compiled application.
If "program" is my application, where do I specify bsnes-plus.exe? Or vice versa.
You can put it any other field. In Dart, we have a dartPath field that can be passed through to the debug adapter. It's usually populated silently by the DebugConfigurationProvider.resolveDebugConfig though (we detect the SDK by searching PATH) so the user never needs to add it.
Is there a way to specify my own project-level variables, e.g. $OUTPUT so that I don't have to hard-code the output filename into both the build task and the launch task?
You can't make your own variables, but using resolveDebugConfig you can manipulate the launch config yourself before it's passed to the debug adapter, which probably allows you to do what you need here (eg. you could do a string replace on program - or you could even just add it if it's not set, allowing a launch.json-less launch too).
Do I need to write a debug adapter even though it's not going to actually do anything other than launch the application, just so I can tell VSCode that it exited cleanly?
I'm not sure what happened here without more details, but having a debug adapter probably makes the most sense - for example if you want to make the Stop/Restart buttons work on the toolbar, you'd probably want a debug adapter that can terminate and/or restart the process.

Drop into a Scala interpreter in Spark script?

I'm using Scala 2.11.8 and Spark 2.1.0. I'm totally new to Scala.
Is there a simple way to add a single line breakpoint, similar to Python:
import pdb; pdb.set_trace()
where I'll be dropped into a Scala shell and I can inspect what's going on at that line of execution in the script? (I'd settle for just the end of the script, too...)
I'm currently starting my scripts like so:
$SPARK_HOME/bin/spark-submit --class "MyClassName" --master local target/scala-2.11/my-class-name_2.11-1.0.jar
Is there a way to do this? Would help debugging immensely.
EDIT: The solutions in this other SO post were not very helpful / required lots of boilerplate + didn't work.
I would recommend one of the following two options:
Remote debugging & IntelliJ Idea's "evaluate expression"
The basic idea here is that you debug your app like you would if it was just an ordinary piece of code debugged from within your IDE. The Run->Evaluate expression function allows you to prototype code and you can use most of the debugger's usual variable displays, step (over) etc functionality. However, since you're not running the application from within your IDE, you need to:
Setup the IDE for remote debugging, and
Supply the application with the correct Java options for remote debugging.
For 1, go to Run->Edit configurations, hit the + button in the top right hand corner, select remote, and copy the content of the text field under Command line arguments for running remote JVM (official help).
For 2, you can use the SPARK_SUBMIT_OPTS environment variable to pass those JVM options, e.g.:
SPARK_SUBMIT_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005" \
$SPARK_HOME/bin/spark-submit --class Main --master "spark://127.0.0.1:7077" \
./path/to/foo-assembly-1.0.0.jar
Now you can hit the debug button, and set breakpoints etc.
Apache Zeppelin
If you're writing more script-style Scala, you may find it helpful to write it in a Zeppelin Spark Scala interpreter. While it's more like Jupyter/IPython notebooks/the ipython shell than (i)pdb, this does allow you to inspect what's going on at runtime. This will also allow you to graph your data etc. I'd start with these docs.
Caveat
I think the above will only allow debugging code running on the Driver node, not on the Worker nodes (which run your actual map, reduce etc functions). If you for example set a breakpoint inside an anonymous function inside myDataFrame.map{ ... }, it probably won't be hit, since that's executed on some worker node. However, with e.g. myDataFrame.head and the evaluate expression functionality I've been able to fulfil most of my debugging needs. Having said that, I've not tried to specifically pass Java options to executors, so perhaps it's possible (but probably tedious) to get it work.

How to pass server.{host,port} to grails under Eclipse/STS

I need to set grails.server.host and grails.server.port differently on different dev machines, or in different configurations. I can set them in BuildConfig.groovy but that is source-controlled so I don't want to check in machine-specific info there. How can I pass these from the Run Configuration?
I have tried every combination of -Dserver.host and -Dgrails.server.host, with the values in quotes or not, in the Arguments tab Program Arguments and VM Arguments fields, and just server.host or grails.server.host in the Environment tab; I even tried changing the Grails tab's Grails Command field to "-Dserver.host=192.168.2.110 run-app" but grails keeps coming up "localhost:8080"
My fallback is to try and set them with an external property file, but then I have to get fancy about setting them differently for different environments and such, and I don't have easy UI visibility like I do with the Run As ... menu. So, can someone tell me how they are configuring Eclipse/STS to pass a grails parameter?
(Using Eclipse (STS 2.7.1) with grails 2.0.0M1)
-Dserver.host=192.168.2.110 -Dserver.port=8888 Should work if set in the VM arguments...
Have you tried grails -Dserver.host=192.168.2.110 -Dserver.port=8888 run-app from terminal or the command prompt?