Add more tests#943
Conversation
There was a problem hiding this comment.
Pull request overview
This PR expands the repository’s RSpec coverage by adding new unit and integration specs around auxiliary helpers (resource scoping, replacement maps, command execution), QEMU runner option validation, and end-to-end behaviors for JSON overrides and CLI query mode. It also introduces tag-based skipping controls via spec_helper and ensures spec_helper is always loaded via .rspec.
Changes:
- Add RSpec tag filters to optionally skip
:linux_processand:integrationspecs via env vars. - Add new unit specs for
ResourceScope,ReplacementMap,CmdRun, and QEMU option/runner behavior. - Add integration specs covering JSON override deep-merge behavior and
--query images-namesCLI/project flow.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| spec/spec_helper.rb | Adds env-controlled tag filters for :linux_process and :integration examples. |
| .rspec | Ensures spec_helper is auto-required for all spec runs. |
| spec/setupmanagers/qemuhck/qemu_machine_spec.rb | Unit tests for QemuMachine#validate_run_opts default merging + unknown key errors. |
| spec/setupmanagers/qemuhck/qemu_machine_runner_spec.rb | Unit tests for Runner constants + check_fails_too_quickly, plus tagged Linux process sanity checks. |
| spec/lib/auxiliary/resource_scope_spec.rb | Tests ResourceScope.open, LIFO close behavior, exception safety, and transaction semantics. |
| spec/lib/auxiliary/replacement_map_spec.rb | Tests placeholder substitution, shell-escaping in create_cmd, merge behavior, and enumerability. |
| spec/lib/auxiliary/cmd_run_spec.rb | Tagged Linux-process tests for CmdRun success/failure behavior, logging, idempotent close, and spawn options. |
| spec/integration/json_override_spec.rb | Integration coverage for JSON override deep-merge behavior and Config.read override application. |
| spec/integration/cli_query_images_names_spec.rb | Integration coverage for CLI parsing + Project#prepare query mode output behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive suite of unit and integration tests for AutoHCK, covering CLI query modes, JSON overrides, command execution, resource management, and QEMU machine runners. Feedback focuses on enhancing test reliability and isolation by mocking external dependencies like the monotonic clock and configuration files, as well as using stub_const to avoid constant initialization warnings in specs.
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive suite of unit and integration tests for various AutoHCK components, including CLI query modes, JSON override mechanisms, command execution, resource management, and QEMU machine handling. It also updates the RSpec configuration to allow selective execution of integration and process-heavy tests via environment variables. The review feedback suggests improving test isolation by avoiding top-level constant and class definitions in spec files to prevent global namespace pollution, recommending the use of let blocks or stub_const instead.
Tagged examples use real /bin/true, /bin/false, sleep plus SIGKILL, and optional qemu-system-x86_64 --version. Omit them with SKIP_LINUX_PROCESS=1 or rspec --tag ~linux_process. Load spec_helper from .rspec so the filter applies project-wide. Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Cover open/ensure close order, exceptions, nested open, << chaining, and transaction transferring resources to the parent scope. Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Tagged :linux_process (real spawn). Covers success, shelljoin logging, CmdRunError, exception: false, idempotent close, chdir, and status after rescue. Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
- Deep-merge keyed by the exact path passed to read_json - Config.read with override keys shaped like production (config.json) - No merge when override file missing; no entry for base path unchanged - :integration tag; SKIP_INTEGRATION=1 or --tag ~integration to skip - Reset Json override path around examples to avoid leaking state Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive suite of unit and integration tests covering CLI query modes, JSON configuration overrides, command execution, resource management, and QEMU machine runners. It also updates the test configuration to allow skipping specific test categories via environment variables. Feedback was provided regarding the integration tests for CLI query modes, specifically suggesting that mocking the configuration reader is a more robust approach than writing a temporary configuration file to the repository root, which can cause side effects and conflicts.
Exercise CLI.parse, Project.new, and prepare in test mode with --query images-names: assert output file, string log, and unknown query error. Runs from repo root so platform JSON resolves; stubs Config.read with spec/fixtures/minimal_config.json to avoid touching config.json. Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Done by Cursor