Skip to content

Add more tests#943

Open
kostyanf14 wants to merge 9 commits into
HCK-CI:masterfrom
kostyanf14:utests
Open

Add more tests#943
kostyanf14 wants to merge 9 commits into
HCK-CI:masterfrom
kostyanf14:utests

Conversation

@kostyanf14
Copy link
Copy Markdown
Contributor

Done by Cursor

Copilot AI review requested due to automatic review settings May 4, 2026 16:42
Comment thread spec/lib/auxiliary/resource_scope_spec.rb Fixed
Comment thread spec/lib/auxiliary/cmd_run_spec.rb Fixed
Comment thread spec/lib/auxiliary/cmd_run_spec.rb Fixed
Comment thread spec/lib/auxiliary/replacement_map_spec.rb Fixed
Comment thread spec/lib/auxiliary/replacement_map_spec.rb Fixed
Comment thread spec/lib/auxiliary/resource_scope_spec.rb Fixed
Comment thread spec/lib/auxiliary/resource_scope_spec.rb Fixed
Comment thread spec/setupmanagers/qemuhck/qemu_machine_runner_spec.rb Fixed
Comment thread spec/setupmanagers/qemuhck/qemu_machine_runner_spec.rb Fixed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_process and :integration specs 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-names CLI/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.

Comment thread spec/lib/auxiliary/cmd_run_spec.rb Outdated
Comment thread spec/lib/auxiliary/cmd_run_spec.rb Outdated
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread spec/integration/cli_query_images_names_spec.rb Outdated
Comment thread spec/lib/auxiliary/resource_scope_spec.rb Outdated
Comment thread spec/setupmanagers/qemuhck/qemu_machine_runner_spec.rb
kostyanf14 added 2 commits May 4, 2026 19:49
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
@kostyanf14
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread spec/integration/cli_query_images_names_spec.rb Outdated
Comment thread spec/lib/auxiliary/resource_scope_spec.rb Outdated
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>
@kostyanf14
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread spec/integration/cli_query_images_names_spec.rb
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • sorbet/rbi/spec/resource_scope_spec.rbi: Language not supported

Comment thread spec/lib/auxiliary/cmd_run_spec.rb
Comment thread spec/integration/json_override_spec.rb
Comment thread spec/integration/cli_query_images_names_spec.rb
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants