#Balatest - Unit Testing for Balatro

1 messages · Page 1 of 1 (latest)

cloud vine
astral whale
#

@heavy blaze pepecrazyeyes

heavy blaze
#

Hey @cloud vine, how does this specifically hook into the game code?

#

Are you operating in the normal game flow or doing something weird?

cloud vine
#

With regards to Remotro in particular, these are currently non-goals for me:

  • Defining or triggering tests from outside of a Balatro mod
  • Interoperating with a language other than Lua
  • Preventing the user from interacting with running tests
  • Strictly defining/limiting the capabilities of tests
#

Feel free to steal any of my code, though, it's GPL-3.0 licensed

heavy blaze
heavy blaze
#

So in a sense remotro might be more capable of making integration/e2e tests than Balatest

heavy blaze
#

if you are implementing more e2e-style tests lmk @cloud vine

cloud vine
astral whale
#

@heavy blaze ? you could use this a lot, no? they have functions defined for a lot of actions

heavy blaze
#

Would be useful for accelerating my RE efforts @astral whale

#

And unlike balatro's codebase I can pipe it into a sota llm and really speed up me being able to generate various hooks

astral whale
#

ah right async vs sync is the issue here for you, i get it

#

or maybe i don't lol...i still think you could use this basically every action in game

heavy blaze
cloud vine
#

I can't stop you either way, but it would make me a touch sad

#

It's not that much of an issue, especially if you provide proper attribution

zealous barn
#

interesting

#

this may be of some use if my lovely plans work out the way I want

cloud vine
formal mica
#

to fall asleep to

#

so real

#

wait, does it use Nopeus' unsafe speed or its own

cloud vine
#

its own

formal mica
#

alr good to know

cloud vine
#

it also automatically activates it

formal mica
#

for most devices unsafe speed is overkill

#

but for my 13yo Mac it barely affords my needs

cloud vine
#

the point here is to run the tests as fast as it can because otherwise it takes forever

#

if i turned off the speedups in this these tests would easily take 3X as long

formal mica
#

Ik that

#

as a Balatro modder, testing modded Balatro on a 13yo Mac is a masochistic move

#

yet I'm doing it

cloud vine
#

real

astral whale
#

my 1 year old macbook paid by my company is happy to jump in if any of you guys need it 😂

#

48 GB memory goes brrrrr

half flicker
#

Well luckily I don't use that Mac that often

#

Just with some lovely development

#

Which is rough cause compilation is slow

icy dome
#

this is really neat

cloud vine
#

I've already found a nice handful of bugs with these, too

icy dome
#

im writing tests for morefluff right now and the api is really clean

cloud vine
#

Hell yeah

#

lmk if you want/need anything else from it

icy dome
#

...though i'm skipping Complexity Creep for now (probably the joker that needs to be tested the most), since i really dont want to get into that now

#

ill get to that at the end

cloud vine
#

big mood

#

i personally saved Proxy and Card Sleeve 'til near the end, haha

#

both of them have so many edge cases :agony:

icy dome
#

the one slight issue i've had (which was my fault) is that .buy()ing a voucher results in it going to your joker slots which makes sense but feels off

cloud vine
#

😭

icy dome
#

that is how the game works though so i can't complain

cloud vine
#

try .useing it?

icy dome
#

yeah that's what i did and it worked

cloud vine
#

dlhlghdgkd

#

this game is so cool

icy dome
#

you should colour the pass/fail messages red/green btw

cloud vine
#

i should do way more with the results reporting tbh

icy dome
#

this is very nice to see this early on in balatro's modding scene

coral siren
#

this is incredible honestly

icy dome
#

oh yeah if you have nopeus installed the unsafe speed doesn't work

#

which is proabbly a non-issue i just thought i'd mention it here for anyone who looks at the thread in future

cloud vine
#

that's fixable and i should fix it soon

icy dome
cloud vine
#

i found like half a dozen in bakery lmao

#

it's almost like testing for bugs finds bugs /positive

icy dome
#

True...

coral siren
#

the idea of unit testing mods at all is massive

#

we're lucky to have a well-documented API and testing

cloud vine
#

it's called Unsafe for a reason; it can break shit

icy dome
#

oh i just meant like

#

the cards left the hand slowly

#

instead of going all at once

cloud vine
#

that worked for me

#

Works On My Machine™️

next spruce
#

Also having an issue where cards slowly retract back into the deck

#

It only works for the first test, and then doesnt work again

next spruce
#

Uninstalled talisman and it works fine now

cloud vine
icy dome
next spruce
#

After scoring is complete, and blind is defeated. ^

icy dome
#

it might just be a clash between the two mod's "skip all animations" settings

next spruce
#

Skip anim was off

#

It was just talisman being installed

cloud vine
#

😭 I'll look into it

#

i use talisman so maybe it's a versioning issue?

next spruce
#

Im on an older smods, for whatever reason. 410b

#

Talisman 2.2.0~dev

sacred canopy
#

This is really cool

crisp pelican
#

oh my god what the peak

cloud vine
#

Reminder: LMK if there's anything you want from this that it doesn't already do

#

(currently it's just output log coloring)

astral whale
#

i feel like i'm stupid

#

i defined a test following the example in the readme

#

and it just doesn't select the blind?

#

i feel like it's doing things too fast maybe?

#

oh it crashed at some point before and got stuck at this game speed

#

nvm, that wasn't the issue....

#

still gets stuck at blind select or hand drawn

cloud vine
#

Can you send your test definition and also your mod list

cloud vine
astral whale
#

mod list is literally just this code, too many jokers, smods and debugplus

#

and obviously balatest

#

i'll try without tmj

cloud vine
#

i'll try it with

astral whale
#

it's actually tmj 😭

#

most unexpected compat issue ever???

cloud vine
#

This is working fine for me, what versions do you have?

astral whale
#

how can i print this? or do i have to crash the game for it somehow?

cloud vine
#

I use Bakery_API.crash() lmao

#

shockingly useful function

astral whale
#
Additional Context:
Balatro Version: 1.0.1o-FULL
Modded Version: 1.0.0~BETA-0527d-STEAMODDED
LÖVE Version: 11.5.0
Lovely Version: 0.7.1
Platform: OS X
Steamodded Mods:
    1: DebugPlus by WilsontheWolf [ID: DebugPlus, Version: 1.5.0~dev, Uses Lovely]
    2: Balatest by BakersDozenBagels [ID: Balatest, Priority: -1000, Version: 1.1.0, Uses Lovely]
    3: Balafuzz by nnmrts [ID: Balafuzz, Priority: -999, Version: 1.0.0]
Lovely Mods:
#

with the above everything works

#

and, one sec

#

with this it doesn't:

Balatro Version: 1.0.1o-FULL
Modded Version: 1.0.0~BETA-0527d-STEAMODDED
LÖVE Version: 11.5.0
Lovely Version: 0.7.1
Platform: OS X
Steamodded Mods:
    1: Too Many Jokers by cg [ID: toomanyjokers, Priority: 1000000, Uses Lovely]
    2: Balafuzz by nnmrts [ID: Balafuzz, Priority: -999, Version: 1.0.0]
    3: Balatest by BakersDozenBagels [ID: Balatest, Priority: -1000, Version: 1.1.0, Uses Lovely]
    4: DebugPlus by WilsontheWolf [ID: DebugPlus, Version: 1.5.0~dev, Uses Lovely]
Lovely Mods:
#

okay wtf

#

just rechecked again

#

and that works

cloud vine
#

????

astral whale
#

i'm soooo done

cloud vine
#

as a friend likes to say, "all technology is shit"

astral whale
#

let me turn of vsync, maybe it was that

#

nah even with vsync off

#

ahhhh i don't even wanna know what that was

#

god just wanted to waste my time i guess

sorry for wasting yours

cloud vine
#

well, I'm glad it works now

#

there's a chance it was something something stale lovely cache something conflicting patches something

astral whale
#

i'm not sure if i'm more curious what that means or more afraid of the answer

cloud vine
#

actually no lovely shouldn't be conflicting for this

#

the one lovely patch here is just for speed

astral whale
#

then again i'm running balatro from source AND self compiled lovely

#

didn't lead to any issues so far but i guess that was it maybe

cloud vine
#

lmk if something like this comes up again

astral whale
#

yup, thanks again

cloud vine
#

Hot tip for y'all:
If you have a file like this, you can watch lua it with DebugPlus to auto-run it on save

Balatest.run_test {
    jokers = { "j_joker" },
    consumeables = { "c_pluto" },
    execute = function()
        Balatest.use(G.consumeables.cards[1])
        Balatest.play_hand { "2S" }
    end,
    assert = function()
        Balatest.assert_chips(102)
    end
}
cloud vine
#

You can now specify multiple categories for a test.
Also, the docs for Balatest.hook no longer lie about giving you an already-hooked function

#

I will also be deprecating requires since it's bad and dumb

atomic igloo
#

i'm not too good at lua but i had to make a change to your source to get the mod to work for me
on line 470 and 479 of main.lua you had to_big(a):eq(b) which would throw

Error: [SMODS Balatest "src/main.lua"]:470: attempt to index a number value

I'm not sure why this dosn't work but i just replaced it with to_big(a) == to_big(b) and things started working
my test case is as follows

Balatest.TestPlay {
    name = 'base_test_case',
    requires = {},
    category = 'base_test',

    jokers = { 'j_joker' }, -- Start with a Joker
    
    execute = function()
        Balatest.play_hand { '2S' } -- Play a High Card
    end,
    assert = function()
        Balatest.assert_chips(35) -- Total round score, *not* the last hand
    end
}

my mod version is the latest from the github linked at the top.
i'd submit a pull request if i knew how to. thanks

cloud vine
#

and what number setting

atomic igloo
#

oh, mb, is talisman required

#

i have it disabled

cloud vine
#

no, it shouldn't be required

#

actually I might have an idea what's happening here

#

I'll put a proper guard in tonight

atomic igloo
#

i have debugplus, flower pot, handy, cartomancer, balatest, 39joker, brainstorm, blueprint, card back injection, my mod and a few other texture mods

atomic igloo
astral whale
#

i'm cooking so much with balatest

astral whale
hazy dagger
#

Does balatest have support for testing save file reloading?

#

Like exiting to the menu and going back to the run

cloud vine
#

Not ATM but I can add support for that

hazy dagger
#

That'd be great! Thank you so much

cloud vine
astral whale
#

i am now ready to take over the world

hazy dagger
#

How do i run a set of tests with a category?

#

I can't seem to run them for some reason

#

Here are my tests by the way.

cloud vine
hazy dagger
#

it gives nil

cloud vine
#

Did you forget to actually run the file with your test definitions? What happens if you put a print next to them?

hazy dagger
#

no no it runs fine when I do Balatest.run_tests('pkrm_gym')

cloud vine
#

i see

hazy dagger
#

I think there's a mismatch between the mod_id and actual id used in naming the tests

cloud vine
#

oh of course

hazy dagger
#

oh i'm dumb

cloud vine
#

yeah I use the mod ID not its prefix

hazy dagger
#

how come the prefix still works when I use it to run though 🤔

cloud vine
#

it's falling back to running everything

#

I'll rework the error handling to be a bit more clear on this

hazy dagger
#

thanks a lot!

#

The testing framework is really great. I enjoyed every single moment of using it.

cloud vine
#

Thanks! ✨

cloud vine
#

The default logging should be colored now. It also now pcalls anything you Balatest.q, which has a small chance of breaking things

cloud vine
#

I've pushed a small update for compatibility with bleeding-edge SMODS. As always, let me know if something breaks

crisp pelican
cloud vine
#

... and another for no_auto_start (and also Balatest.exit_shop() without then starting a blind)

cloud vine
#

Another small update to account for more SMODS (smh my head)

cloud vine
#

Pushed a very small feature update (an optional parameter to Balatest.wait() to wait multiple times) and a bugfix

cloud vine
#

Balatest now has proper LSP-compatible documentation! Also, you can now face multiple distinct blinds in a test.

cloud vine
#

New feature: you can specify a set of mods required for a test to run, and Balatest will automatically skip that test if they're not all installed. This makes it easier to have tests for cross-mod content.