How luchobazz/quicktest works
Project Type and Purpose
• Quick Test CLI is a CLI tool built in Rust (evidenced by Cargo.toml and the “src” structure) designed to perform various types of testing (cmp, check, stress, output, setup) for competitive programming projects.
• Its goal is to generate test cases, compare outputs (possibly with a brute force or checker solution), execute target code in different languages, and report on potential errors (WA, TLE, RTE).
Analyzing the File Structure
• Top-level directories like “src”, “tests”, “examples”, “assets”, and “website” indicate a multi-faceted project.
• Under “src”, you have detailed separation into CLI components (src/cli), controllers (src/controllers), error handling, file handling, generators, language modules, runner, and views for output rendering.
• The “examples” folder shows real-world use cases (cmp, check, output, stress) for various supported languages, reinforcing that the tool interconnects code generators, compilers, and validators.
• The “website” directory suggests there is an accompanying documentation and tutorial site, but for the system design, the primary focus is on the CLI tool itself.
Key Components
a. CLI Interface
• Entry point (src/main.rs) and option parsing (src/cli/opt.rs) which receives user commands and arguments.
• Subcommand models (src/cli/model/*) representing commands like cmp, stress, check, output, and setup.
b. Controllers
• Modules in src/controllers handle the business logic for each command. Notice both asynchronous controllers (e.g., cmd_cmp_async.rs) and legacy synchronous ones, showing a phase of evolution and potential backward compatibility.
c. Core Functional Modules
• Generator Module (src/generator): Builds test cases through generator programs.
• File Handler Module (src/file_handler): Manages reading/writing files, paths, and asynchronous file operations.
• Language Module (src/language): Handles language-specific tasks like determining file extensions, command generation for compiling/executing code, and JSON configs (src/language/json). This module bridges the CLI commands with multi-language support.
• Runner Module (src/runner): Manages command execution/state counting and process management.
• Views (src/views): Responsible for displaying outputs such as diff views or styled outputs.
• Error Handling (src/error): Captures and processes errors raised in various components.
d. Configuration and Constants:
• Configurations (src/config) for language settings, reading configuration files, and constants (src/constants.rs) ensuring consistent configuration across the application.
Relationships and Interactions
• How each subcommand routes the request to its corresponding controller.
• Each controller then interacts with core modules:
• The Generator module for producing test cases.
• The File Handler to read/write both source code and test files.
• The Language module, which selects and prepares compilation/execution commands for multiple programming languages.
• The Runner module, which is responsible for executing the target code and capturing results.
• The Error Handling module that processes runtime errors, timeouts, and memory issues.
• The Views module to display detailed output, differences, or errors.
Architectural Patterns and Design Principles
• The presence of “controllers”, “models”, and “views” suggests a loosely applied MVC pattern specific to CLI processing.
• Asynchronous processes (e.g., in the async controller implementations under src/controllers) to denote concurrent processing, which is key for responsiveness during stress testing.