A blazing-fast, feature-rich Competitive Programming test case runner for Visual Studio Code.
CP Runner is a robust Visual Studio Code extension designed for competitive programmers. It integrates seamlessly with Competitive Companion to parse problems and contests directly into your IDE, allowing you to run and verify test cases effortlessly. Stop copy-pasting inputs and outputs manually—let CP Runner automate your workflow so you can focus on solving the problem!
✨ Features
Competitive Companion Integration: Listen and parse problem test cases automatically via a local webhook.
Multi-Language Support: Run solutions in C++, C, Java, and Python.
Concurrent Execution: Run multiple test cases in parallel using configurable worker threads, significantly reducing testing time.
Smart Diff Engine: Compare expected and actual outputs with support for:
Ignoring trailing whitespaces
Normalizing line-endings (\r\n vs \n)
Float precision tolerance (epsilon comparison for geometry/probability problems)
Auto Run: Optionally run test cases automatically every time you save your code.
Configurable Limits: Set hard memory (MB) and time (ms) limits to detect memory leaks or TLEs (Time Limit Exceeded).
Custom Webview UI: A beautiful, native-feeling Webview built with React and TailwindCSS for managing and viewing test case results right inside your editor.
📋 Prerequisites
Before using CP Runner, make sure you have the following installed based on the languages you intend to use:
C/C++: gcc/g++ installed and available in your system's PATH.
Python: python3 (or python) installed and available in PATH.
Java: Java Development Kit (javac & java) installed and available in PATH.
Competitive Companion: The browser extension installed in Chrome or Firefox to parse problems.
🚀 Installation
Open VS Code.
Go to the Extensions view (Ctrl+Shift+X / Cmd+Shift+X).
Search for CP Runner and click Install.
(Optional) Make sure the browser extension Competitive Companion is installed.
If installing from a local .vsix file:
Go to the Extensions view.
Click the ... menu in the top right corner and select "Install from VSIX...".
Select the downloaded cp-runner-X.X.X.vsix file.
📖 Usage Guide
1. Parsing a Problem
Open a problem on supported platforms (Codeforces, LeetCode, AtCoder, etc.) in your browser.
Click the Competitive Companion extension icon (the green plus sign) in your browser.
CP Runner will automatically receive the problem details, generate a source file, and populate the test cases in the CP Runner side panel.
2. Running Test Cases
Write your solution in the generated file.
Press Ctrl+Alt+R (or Cmd+Alt+R on Mac) to run the test cases.
View the results (Accepted, Wrong Answer, Time Limit Exceeded, Runtime Error, etc.) in the CP Runner webview panel.
3. Managing Test Cases
Add custom test cases: Use the + button in the UI or the CP Runner: Add Test Case command.
Edit test cases: Directly click on the input/output text areas in the UI to modify them.
Clear test cases: Use the trash icon to clear individual or all test cases.
⌨️ Commands & Keybindings
Command
Description
Default Keybinding
cp-runner.runTests
Run Test Cases for the active file
Ctrl+Alt+R / Cmd+Alt+R
cp-runner.stopExecution
Force stop running Test Cases
Ctrl+Alt+S / Cmd+Alt+S
cp-runner.addTestCase
Add a new empty Test Case
-
cp-runner.clearTestCases
Clear All Test Cases
-
⚙️ Configuration
CP Runner is highly customizable. You can modify these settings via VS Code settings (Ctrl+, -> search for CP Runner):
Execution Settings
cp-runner.execution.timeLimit: Execution time limit per test case in milliseconds. (Default: 2000)
cp-runner.execution.memoryLimit: Memory limit constraints in MB. (Default: 256)
cp-runner.concurrency.maxWorkers: Maximum concurrent execution threads. (Default: 4)
cp-runner.execution.autoRun: Automatically run test cases when the active source file is saved. (Default: false)
cp-runner.execution.autoSave: Automatically save the active file before running tests. (Default: true)
Compiler & Command Settings
cp-runner.compiler.cppCommand: C++ compiler command/path (Default: g++)
cp-runner.compiler.cppFlags: C++ compiler flags (Default: -O2 -std=c++17 -Wshadow)
cp-runner.compiler.cCommand: C compiler command/path (Default: gcc)
cp-runner.compiler.cFlags: C compiler flags (Default: -O2 -std=c11)