packages/library/codewars-odin-runner
c

codewars-odin-runner

bffeb65library

No description provided.

0 stars0 forksMITupdated 4 months ago
Open repo

codewars-odin-runner

A Docker-based test runner for Odin programming language challenges.

Prerequisites

  • Docker: Must be installed and running on your system
  • Windows: For the PowerShell runner (run.ps1)
  • Linux/macOS: For the bash runner (run)

Quick Start

Using PowerShell (Windows)

# Run the default "addition" example
& .\bin\run.ps1

# Run a specific example
& .\bin\run.ps1 -ExampleName "hello_world"

Using Bash (Linux/macOS)

# Run the default "addition" example
./bin/run

# Run a specific example
./bin/run hello_world

Project Structure

.
├── Dockerfile           # Docker image configuration with Odin compiler
├── README.md            # This file
├── bin/
│   ├── run             # Bash script for Linux/macOS
│   └── run.ps1         # PowerShell script for Windows
├── examples/           # Sample challenges with solutions
│   ├── addition/
│   │   ├── solution.odin
│   │   └── solution_test.odin
│   └── hello_world/
│       ├── solution.odin
│       └── solution_test.odin
└── workspace/          # Files needed by the Docker environment
    ├── codewars_reporter.odin  # Test reporting framework
    └── tests.odin              # Main test runner

How It Works

  1. Build Phase: If the Docker image doesn't exist, it's built from the Dockerfile
  2. Copy Phase: Example files are copied into the container
  3. Execution Phase: The Odin compiler runs the code with tests via odin run .
  4. Cleanup Phase: The container is removed after execution

Writing Your Own Challenge

1. Create a Challenge Directory

examples/
└── my_challenge/
    ├── solution.odin
    └── solution_test.odin

2. Write Your Solution

solution.odin:

package tests

// Your solution code here
solution :: proc(x: int) -> int {
    return x * 2
}

3. Write Your Tests

solution_test.odin:

package tests

do_tests :: proc() {
    describe("Describe Your Test Suite", proc() {
        it("Test case 1", proc() {
            assert_equals(solution(5), 10)
        })
        it("Test case 2", proc() {
            assert_equals(solution(0), 0)
        })
    })
}

4. Run Your Challenge

.\bin\run.ps1 -ExampleName "my_challenge"

or

./bin/run my_challenge

Testing Framework

The project includes a Codewars-compatible testing framework in workspace/codewars_reporter.odin with the following functions:

  • describe(name: string, proc()) - Describe a test suite
  • it(name: string, proc()) - Define a test case
  • assert_equals(actual, expected) - Assert equal values
  • pass() - Mark test as passed
  • fail(message: string) - Mark test as failed

Environment Details

Docker Image

  • Base: Ubuntu 22.04
  • Odin Compiler: dev-2026-03 build

Resources

Package Info
Version
bffeb65
License
MIT
Author
@jon-edward
Type
library
Forks
0
Created
4 months ago
Updated
4 months ago
Health
maintained
has releases
has readme
has license
Activity
last 56 weeks