Skip to main content

๐Ÿงช leetrs test & leetrs submit

Commands for executing code against sample test cases and submitting solutions to LeetCode judging servers.


๐Ÿงช leetrs testโ€‹

Executes your local solution file against sample test cases without recording an official submission on LeetCode.

Usageโ€‹

leetrs test <FILE> [--cases <INPUT> | --cases-file <PATH>]

Argumentsโ€‹

ArgumentTypeDescription
<FILE>pathPath to the local solution file (e.g. two_sum.rs, two_sum.py)

Optionsโ€‹

OptionTypeDescription
-c, --cases <INPUT>stringCustom test input, one argument per line. A literal \n outside a quoted string also separates lines.
--cases-file <PATH>pathFile containing custom test input. Can't be combined with --cases.

Without either option, the problem's example test cases are used.

Workflowโ€‹

  1. Parses the metadata header comment inside <FILE> to extract problem ID, slug, and language.
  2. Sends a test-run payload to LeetCode's judging API.
  3. Polls judging status asynchronously until complete.
  4. Renders colored test results: passed test cases, runtime, output vs expected output, and compiler errors.

Exampleโ€‹

leetrs test two_sum.rs
leetrs test two_sum.rs -c "[3,2,4]\n6"
leetrs test two_sum.rs --cases-file ./test_inputs.txt

๐Ÿš€ leetrs submitโ€‹

Submits your local solution file to LeetCode for official judging and profile score updating.

Usageโ€‹

leetrs submit <FILE>

Argumentsโ€‹

ArgumentTypeDescription
<FILE>pathPath to the local solution file (e.g. two_sum.rs, two_sum.py)

Output Metricsโ€‹

Upon completion, leetrs submit displays:

  • Judge Status: Accepted, Wrong Answer, Time Limit Exceeded, Compile Error, or Runtime Error.
  • Test cases passed: e.g., 57 / 57 testcases passed.
  • Runtime Performance: e.g., 0 ms (Beats 100.00% of Rust submissions).
  • Memory Usage: e.g., 2.1 MB (Beats 98.50% of Rust submissions).

Exampleโ€‹

leetrs submit two_sum.rs