Skip to content

Fix testing to be source path agnostic#444

Merged
Zordrak merged 2 commits intomasterfrom
improve-testing
Jul 4, 2025
Merged

Fix testing to be source path agnostic#444
Zordrak merged 2 commits intomasterfrom
improve-testing

Conversation

@Zordrak
Copy link
Collaborator

@Zordrak Zordrak commented Jul 4, 2025

No description provided.

@Zordrak Zordrak requested a review from Copilot July 4, 2025 10:41

This comment was marked as outdated.

@Zordrak Zordrak requested a review from Copilot July 4, 2025 12:29
Copy link

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 centralizes test setup into a shared test_common.sh, removes duplicated boilerplate from individual test scripts, and makes test paths agnostic by introducing temporary directories and using TFENV_CONFIG_DIR in cleanup and directory checks.

  • Added test_common.sh to consolidate TFENV_ROOT determination, helpers sourcing, and PATH setup
  • Updated individual tests to source test_common.sh and replaced hard-coded paths with TFENV_CONFIG_DIR or temporary directories
  • Enhanced cleanup() in lib/helpers.sh to verify TFENV_CONFIG_DIR before removing test artifacts

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/test_use_minrequired.sh Removed inline TFENV_ROOT boilerplate, now sources test_common.sh
test/test_use_latestallowed.sh Same boilerplate removal and common setup sourcing
test/test_uninstall.sh Sourced common setup and switched version-dir checks to use TFENV_CONFIG_DIR
test/test_symlink.sh Sourced common setup; replaced fixed /tmp path with mktemp -d and added trap for cleanup
test/test_list.sh Removed inline setup and sources test_common.sh
test/test_install_and_use.sh Boilerplate removed, now sources common setup
test/test_common.sh New shared setup file for TFENV_ROOT, helpers, and PATH
test/run.sh Refactored to source test_common.sh
lib/helpers.sh Updated cleanup() to check for TFENV_CONFIG_DIR and delete from that directory
Comments suppressed due to low confidence (2)

test/test_uninstall.sh:56

  • TFENV_CONFIG_DIR is referenced here but never initialized in test_common.sh, causing this check to always fail. Consider defining and exporting TFENV_CONFIG_DIR in test_common.sh to point to an isolated config directory for tests.
  [ -d "${TFENV_CONFIG_DIR}/versions" ] || exit 1

test/test_common.sh:3

  • Tests and the cleanup routine rely on TFENV_CONFIG_DIR but it isn't set here. Add an initialization, e.g.: export TFENV_CONFIG_DIR="$(mktemp -d)"; trap 'rm -rf "${TFENV_CONFIG_DIR}"' EXIT.
# Common test setup header

@Zordrak Zordrak merged commit f6cc330 into master Jul 4, 2025
5 checks passed
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.

1 participant