Designing an automated tester for Choicescript

Ahh! Curse me rushing and posting late at night. I had this in the back of my mind and meant to check and include it in the post.
Some python libraries have to be manually downloaded (though I will investigate the best approaches to packaging it together with the tool). I had also just assumed that pandas came with base python because of how ubiquitous it is.

https://packaging.python.org/en/latest/tutorials/installing-packages/
Using pip should work by going to the command line and typing ‘python3 -m pip install pandas’

I’ll take a look tonight, it might be best if I just provide the pandas library alongside my code.

The good news is that the tool already checks temp declarations against the startup, so if you temp define a variable that is already created, then it will raise an error.

Which does make me think of a rarer situation that is harder to check for, if one scene file uses a gosub to another - it currently won’t identify those

:thinking: I’m not sure that’s practical. What you can do instead is package your code in the PyPI and list the dependencies. Then people can install through pip like a package. And pip will automatically install any dependency.

pip install cs-test

Or something like this. By the way, for Windows users, it’s just python -m pip install pandas, but the shorter version starting with pip should work for both.

@Sinnie let me know if you want help with this, I’ll scrounge my brain. It’s been a while since I published anything in the PyPI.


Else, just include a requirements.txt with your repo. This is pretty standard for python repositories. Then the person can install dependencies more easily:

pip install -r requirements.txt

You’re right, I had a quick Google and if I try to supply the libraries then I’ll be lost in a web of dependencies.

I think the cleanest solution is to package it as an exe then non technical users can just grab that and run it without having to mess around with anything.

But adding it as a library in its own right is a good idea too.

I’ve only used python for my own purposes or within databricks, so I’ve never had to solve these issues and it slipped my mind last night when I got too excited about posting.

I’m at work now, so will take a look this evening.

2 Likes

I am hoping that I have got this right and it works! Let me know if you know a better way to achieve any of this. @Chris_Conley, hopefully this will work smoothly for you this time!

Here is a link to the .zip file containing the executable for the tool: Dropbox - CStest.zip - Simplify your life. It’s just 56mb so shouldn’t be too onerous to download.

Once you have downloaded it, unzip the folder to sit alongside your CS projects, as before:
image

Open the folder and you’ll see these folders. Open ‘dist’ and you’ll find the exe. Simply double click it to run.
image

Once it loads, you’ll see this window. Type in the folder name of the project you wish to test.
image

The test will run in a few seconds, presenting you with this:

Navigate to the test outcomes folder, which is in the main CStest folder, a new folder will be created for your project, within which a folder will be created for each time you run the tool. The folder is named with a timestamp. Inside you will find the two output files with the errors found:
image

@cup_half_empty In the end, after some trials, I used pyinstaller to package it up into an exe. Seems to work pretty well - I’ll possibly look into the folder structure so there’s a little less folder diving required to use it.

3 Likes

Sorry it took so long to get back to you. Yes, I can confirm this is a bug.