You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#### Parallel Testing with Multiple Balatro Instances
41
+
42
+
The test suite supports running tests in parallel across multiple Balatro instances. This dramatically reduces test execution time by distributing tests across multiple game instances.
43
+
44
+
**Setup for Parallel Testing:**
45
+
46
+
1.**Check existing instances and start multiple Balatro instances on different ports**:
38
47
39
-
1.**Always start Balatro first**:
48
+
```bash
49
+
# First, check if any instances are already running
50
+
./balatro.sh --status
40
51
41
-
```bash
42
-
# Check if game is running
43
-
ps aux | grep -E "(Balatro\.app|balatro\.sh)"| grep -v grep
52
+
# If you need to kill all existing instances first:
53
+
./balatro.sh --kill
54
+
```
44
55
45
-
# Start if not running
46
-
./balatro.sh > balatro.log 2>&1& sleep 10 &&echo'Balatro started and ready'
47
-
```
56
+
```bash
57
+
# Start two instances with a single command
58
+
./balatro.sh -p 12346 -p 12347
48
59
49
-
2.**Monitor game startup**:
60
+
# With performance optimizations for faster testing
61
+
./balatro.sh --fast -p 12346
50
62
51
-
```bash
52
-
# Check logs for successful mod loading
53
-
tail -n 100 balatro.log
63
+
# Headless mode for server environments
64
+
./balatro.sh --headless -p 12346
54
65
55
-
# Look for these success indicators:
56
-
# - "BalatrobotAPI initialized"
57
-
# - "BalatroBot loaded - version X.X.X"
58
-
# - "TCP socket created on port 12346"
59
-
```
66
+
# Fast Headless mode on 4 instances (recommended configuration)
-**Test suite**: 102 tests covering API functions and TCP communication
70
-
-**Execution time**: ~210 seconds (includes game state transitions)
71
-
-**Coverage**: API function calls, socket communication, error handling, edge cases
80
+
**Benefits:**
72
81
73
-
5.**Troubleshooting test failures**:
82
+
- **Faster test execution**: ~4x speedup with 4 parallel workers
83
+
- **Port isolation**: Each worker uses its dedicated Balatro instance
84
+
85
+
**Notes:**
86
+
87
+
- Each Balatro instance must be running on a different port before starting tests
88
+
- Tests automatically distribute across available workers
89
+
- Monitor logs for each instance: `tail -f logs/balatro_12346.log`
90
+
- Logs are automatically created in the `logs/` directory with format `balatro_PORT.log`
91
+
92
+
#### Test Prerequisites and Workflow
74
93
75
-
-**Connection timeouts**: Ensure TCP port 12346 is available
76
-
-**Game state errors**: Check if game is responsive and not crashed
77
-
-**Invalid responses**: Verify mod loaded correctly by checking logs
78
-
-**If test/s fail for timeout the reasons is that Balatro crash because there was an error in the Balatro mod (i.e. @balatrobot.lua and @src/lua/ ). The error should be logged in the `balatro.log` file.**
79
-
-**Balatro app crashes**: When the Balatro app crashes during testing, **do not run the remaining tests**. The crash usually indicates an issue with the Lua mod code that causes cryptic errors in `balatro.log`. Stop test execution and investigate the crash logs before continuing. Before running the tests again, ALWAYS kill the current Balatro instance running and start it again.
94
+
0. **Check existing instances first**:
95
+
96
+
```bash
97
+
# Check if Balatro instances are already running
98
+
./balatro.sh --status
99
+
100
+
# If instances are running on needed ports, you can proceed with testing
101
+
# If you need to kill all running instances and start fresh:
102
+
./balatro.sh --kill
103
+
```
80
104
81
105
### Documentation
82
106
@@ -100,19 +124,14 @@ BalatroBot is a Python framework for developing automated bots to play the card
100
124
101
125
### 2. Python Framework Layer (`src/balatrobot/`)
102
126
103
-
**NOTE**: This is the old implementation that is being heavily refactored without backwards compatibility.
104
-
It will be drastically simplified in the future. For the moment I'm just focusing on the Lua API (`src/lua/api.lua`).
105
-
I keep the old code around for reference.
106
-
107
-
-**Bot Base Class** (`base.py`): Abstract base class defining the bot interface
108
-
-**ActionSchema**: TypedDict defining structured action format with `action` (enum) and `args` (list)
109
-
-**Enums** (`enums.py`): Game state enums (Actions, Decks, Stakes, State)
0 commit comments