This repository has been archived by the owner on Oct 25, 2023. It is now read-only.
How We Streamlined Testing #66
carsakiller
announced in
Dev Thoughts
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
How We Streamlined Testing
Hello!:wave:
In this post, I would like to talk about how we were able to streamline our testing using batch files. After using them in this project, I would never develop a similar project without them. I can definitely recommend you use them as it enables you to have your code in one directory and then it just gets copied over for Stormworks.
Realizing There Was a Problem
Testing in Stormworks is a very lengthy process. It can be a very draining experience as there are a lot of menus to go through that all slowly fade and stutter and strain your eyes. Especially when testing persistent data in
g_savedata
, it can become very strenuous to frequently start a new game to ensure you have a clean save with no old save data.Add on top of this, we were working from a Git repository that I stored in a location like
Documents/Stormworks/Carsa's Commands/
so I can easily commit and push my changes. I would then have to manually copy my edited files over to%AppData%/Stormworks/data/missions/Carsa's Commands/
so it could be tested in-game. One can only perform this task loop (or the inverse) so many times before losing their mind.Finding a Solution
I knew there was a way to solve this problem of copying over files with some sort of script. My first instinct was to just use Lua as we were already using it and after doing some research, it seemed easy enough to write up. So I then wrote a little script that would just take the files from the current directory and copy them over to a target directory. There was a problem that was not revealed in my research though, there is no way in vanilla Lua to create a directory. This could pose an issue if someone executes the script and does not have a directory called
Carsa's Commands
at the target location already.I then spoke with @CrazyFluffyPony about the idea and he pointed out that a batch file would be a much better fit for the job. Seeing as all of the contributors develop on Windows and we expected this trend to continue, I agreed a batch file would be a much better solution. This also meant that all collaborators would be able to run the script natively on Windows without having to install Lua. There was a problem though, I had barely any knowledge on batch files, never mind how to write a usable one. And so, I again embarked on some research and learning.
Our Solution
Below is the batch file we use for "building" Carsa's Commands. The newSave.bat file is very similar but that script instead creates a new
autosave
save so that you can just press the continue button from the main menu of the game to get right into a new save.Without going too in-depth (besides, I learned how to write the below from searching online, you can too), I can go over the gist of the file.
%~dp0
.src/
directory that contains all of the source files that need to be copied over.NORMALIZEPATH
function and%~f1
to expand the path so we can get the absolute path of the source files.XCOPY
to copy the files over, and then displaying the result of the operationSetting Up in VS Code
You can create a tasks.json file that tells VS Code how to run your build task. I set ours up so that we could make our changes, press
CTRL + SHIFT+ B
, and all of our code would be updated for testing with the game. You can find out more about how to set up build tasks on VS Code's documentation site.Beta Was this translation helpful? Give feedback.
All reactions