A specialized CLI tool for running and testing CSES (Code Submission Evaluation System) problems with GoLang solutions. Now with direct CSES authentication and test case downloading!
- π Direct CSES Authentication - Login with your CSES credentials
- π₯ Official Test Case Download - Download test cases directly from CSES
- π Auto Re-authentication - Automatically handles session expiration
- π¦ Zip File Processing - Extract and process test cases from CSES zip files
- π Go-optimized: Built specifically for Go solutions
- π§ͺ Parallel test execution with configurable concurrency
- π¦ Direct CSES integration with official test cases
- πΎ Smart caching system for faster subsequent runs
- π¨ Beautiful colorized output with detailed progress reporting
- β‘ Timeout handling with context-based cancellation
- π Comprehensive result reporting with performance metrics
- π Verbose mode for debugging and optimization
- π§Ή Cache management utilities
- π Race detection support for concurrent programs
curl -sSL https://raw.githubusercontent.com/anurag5sh/cses-go-runner/main/install.sh | bash
git clone https://github.com/anurag5sh/cses-go-runner.git cd cses-go-runner go mod tidy go build -ldflags="-s -w" -o cses-go-runner .
make build-optimized make install # Optional: install to /usr/local/bin
Set your CSES credentials:
export CSES_USERNAME='your_username' export CSES_PASSWORD='your_password'
Authenticate with CSES:
cses-go-runner auth
# Authenticate first cses-go-runner auth # Run tests cses-go-runner -file=solution.go -problem=1068
# Authenticate with CSES cses-go-runner auth # Run tests (default command) cses-go-runner -file=solution.go -problem=1068 # Run tests with explicit command cses-go-runner run -file=solution.go -problem=1068 # Clean cache cses-go-runner clean
# With verbose output and diff display cses-go-runner -file=solution.go -problem=1068 -verbose -diff # With custom timeout and parallel execution cses-go-runner -file=solution.go -problem=1068 -timeout=5s -parallel=8 # With race detection (for concurrent programs) cses-go-runner -file=solution.go -problem=1068 -race # Force re-authentication cses-go-runner -file=solution.go -problem=1068 -force-auth
Flag | Description | Default |
---|---|---|
-file | Path to Go solution file | - |
-problem | CSES problem ID | - |
-timeout | Timeout per test case | 1s |
-verbose | Enable verbose output | false |
-cache-dir | Cache directory | ./cses-cache |
-parallel | Number of parallel executions | 4 |
-diff | Show diff for failed tests | false |
-max-output | Maximum output length to display | 1000 |
-optimize | Enable compiler optimizations | true |
-race | Enable race detector | false |
-force-auth | Force re-authentication | false |
-help | Show help message | false |
-version | Show version | false |
-
Set Environment Variables:
export CSES_USERNAME='your_username' export CSES_PASSWORD='your_password'
-
Authenticate:
cses-go-runner auth
-
Use Normally:
cses-go-runner -file=solution.go -problem=1068
The tool will automatically:
- Check for valid authentication before running tests
- Re-authenticate if the session expires
- Download test cases directly from CSES
- Cache everything for offline development
The tool downloads test cases directly from CSES using the official API:
- URL:
https://cses.fi/problemset/tests/{problem_id}/
- Method: POST request with CSRF token and session ID
- Format: ZIP file containing input/output pairs
- Caching: Automatically cached for subsequent runs
π Starting CSES Go Test Runner for problem 1068 π Solution file: solution.go π go version go1.21.0 linux/amd64 π₯ Fetching test cases from CSES... π¦ Extracted 15 test cases from zip file πΎ Cached 15 test cases to ./cses-cache/1068 β
Found 15 test cases π¨ Compiling Go solution... β
Compilation successful π§ͺ Running 15 test cases (parallel: 4)... β±οΈ Total execution time: 0.25s ============================================================ π TEST RESULTS SUMMARY ============================================================ β
PASSED: 15/15 tests β±οΈ Average execution time: 16.67ms ============================================================ π ALL TESTS PASSED! π ============================================================
cses-cache/ βββ .auth/ β βββ session.json # Authentication session βββ 1068/ β βββ 1.in β βββ 1.out β βββ 2.in β βββ 2.out β βββ ... βββ 1083/ βββ 1.in βββ 1.out βββ ...
package main import ( "fmt" "strconv" "strings" ) func main() { var n int fmt.Scanf("%d", &n) var result []string for n != 1 { result = append(result, strconv.Itoa(n)) if n%2 == 0 { n = n / 2 } else { n = n*3 + 1 } } result = append(result, "1") fmt.Println(strings.Join(result, " ")) }
# Check environment variables echo $CSES_USERNAME echo $CSES_PASSWORD # Force re-authentication cses-go-runner auth -force-auth # Check verbose output cses-go-runner -file=solution.go -problem=1068 -verbose
# Clean cache and retry cses-go-runner clean cses-go-runner -file=solution.go -problem=1068
authentication required
- Runcses-go-runner auth
firstsession expired
- Tool will automatically re-authenticatefailed to download test cases
- Check your internet connection and credentials
- Credentials are only stored in environment variables
- Session tokens are stored locally in
cses-cache/.auth/session.json
- Use
cses-go-runner clean
to remove all cached data including sessions - Never commit your credentials to version control
- Fork the repository
- Create a feature branch
- Test with various Go solutions
- Submit a pull request
MIT License - see LICENSE file for details