Skip to content

Teach test_active_file() about snapshot files#2666

Open
hadley wants to merge 2 commits intomainfrom
test-file-snapshot
Open

Teach test_active_file() about snapshot files#2666
hadley wants to merge 2 commits intomainfrom
test-file-snapshot

Conversation

@hadley
Copy link
Member

@hadley hadley commented Feb 2, 2026

No description provided.

@hadley hadley requested review from Copilot and jennybc February 3, 2026 13: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 teaches the test_active_file() function to recognize and handle snapshot files by adding support for detecting snapshot file types and mapping them back to their corresponding test files.

Changes:

  • Added logic to identify snapshot files (.md files in _snaps directories) as type "snap"
  • Extended support to handle both direct snapshot files and snapshot variant files (in subdirectories)
  • Added comprehensive test coverage for the new snapshot file detection functionality

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
R/active.R Added detection logic for snapshot files by checking for _snaps directory and .md extension
tests/testthat/test-active.R Added tests verifying snapshot file detection and mapping to test files for both regular and variant snapshots

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


test_file_type <- function(path) {
dir <- path_file(path_dir(path))
parent_dir <- path_file(path_dir(path_dir(path)))
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The variable name parent_dir is misleading. This variable contains the name of the parent directory (e.g., '_snaps'), not the parent directory path itself. Consider renaming it to parent_dir_name or grandparent_dir_name to clarify that it represents the directory name, not the path.

Copilot uses AI. Check for mistakes.
@hadley
Copy link
Member Author

hadley commented Feb 3, 2026

I accidentally requested the copilot review.

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