Skip to content

refactor: scrub file names in expect_snapshot_igraph_error()#2537

Merged
krlmlr merged 3 commits intobetterfrom
copilot/sub-pr-2515
Jan 24, 2026
Merged

refactor: scrub file names in expect_snapshot_igraph_error()#2537
krlmlr merged 3 commits intobetterfrom
copilot/sub-pr-2515

Conversation

Copy link
Contributor

Copilot AI commented Jan 24, 2026

Enhanced expect_snapshot_igraph_error() to scrub file paths from error messages in test snapshots, making them independent of build directory structure and more stable across environments.

Changes

  • Updated transform function: Now scrubs both file names and line numbers from error messages using two patterns:
    • Source: filename:linenumberSource: <file>:<line>
    • At path/to/file:line :At <file>:<line> :
  • Updated snapshots: Regenerated all affected test snapshots (52 error messages across aaa-auto.md and centrality.md) to use the new format

The regex handles legacy placeholders (xx, <linenumber>) for compatibility with tests using custom transforms.

Example

Before:

Error in `arpack()`:
! ARPACK error. N must be positive
Source: linalg/arpack.c:42

After:

Error in `arpack()`:
! ARPACK error. N must be positive
Source: <file>:<line>
  • By submitting this pull request, I assign the copyright of my contribution to The igraph development team.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 24, 2026 10:36
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 24, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cran.rstudio.com
    • Triggering command: /opt/R/4.5.2/lib/R/bin/exec/R /opt/R/4.5.2/lib/R/bin/exec/R --no-restore --no-echo --args nextArgigraph_2.2.1.9017.tar.gznextArg--as-crannextArg--timingsnextArg--no-manual d/00LOCK-igraph/00new/igraph/libs/igraph.so g &#39;/tmp/RtmpCt6TEX/Rbuild3d1029c518bd/igraph/src/vendor/cigraph/vendor/cs/cs_ltsolve.o&#39; /usr/bin/nm /core/set.o src/layout/kamad-c endor /usr/bin/nm -Pg /tmp/RtmpCt6TEX/Rbuild3d1029c518bd/igraph/src/vendor/cigraph/src/operators/simplify.o g &#39;/tmp/RtmpCt6TEX/Rbuild3d1029c518bd/igraph/src/vendor/cigraph/vendor/pcg/pcg-output-64.o&#39; /usr/bin/nm /games/preferencsh src/misc/order_c-c rgo/bin/as /usr/bin/nm (dns block)
    • Triggering command: /opt/R/4.5.2/lib/R/bin/exec/R /opt/R/4.5.2/lib/R/bin/exec/R --no-restore --no-echo --args nextArgigraph_2.2.1.9017.tar.gznextArg--as-crannextArg--timingsnextArg--no-manual /00LOCK-igraph/00new/igraph/libs/igraph.so g &#39;/tmp/RtmpwNRKqt/Rbuild69aa179eb5fa/igraph/src/vendor/cigraph/vendor/cs/cs_ltsolve.o&#39; /usr/bin/nm /core/set.o src/layout/kamad-c /x86_64-linux-gn-- /usr/bin/nm -Pg /tmp/RtmpwNRKqt/Rbuild69aa179eb5fa/igraph/src/vendor/cigraph/src/operators/simplify.o g &#39;/tmp/RtmpwNRKqt/Rbuild69aa179eb5fa/igraph/src/vendor/cigraph/vendor/pcg/pcg-output-64.o&#39; /usr/bin/nm /games/preferencsh src/misc/order_c-c rgo/bin/as /usr/bin/nm (dns block)
  • packagemanager.posit.co
    • Triggering command: /opt/R/4.5.2/lib/R/bin/exec/R /opt/R/4.5.2/lib/R/bin/exec/R --no-restore --no-echo --args nextArgigraph_2.2.1.9017.tar.gznextArg--as-crannextArg--timingsnextArg--no-manual d/00LOCK-igraph/00new/igraph/libs/igraph.so g &#39;/tmp/RtmpCt6TEX/Rbuild3d1029c518bd/igraph/src/vendor/cigraph/vendor/cs/cs_ltsolve.o&#39; /usr/bin/nm /core/set.o src/layout/kamad-c endor /usr/bin/nm -Pg /tmp/RtmpCt6TEX/Rbuild3d1029c518bd/igraph/src/vendor/cigraph/src/operators/simplify.o g &#39;/tmp/RtmpCt6TEX/Rbuild3d1029c518bd/igraph/src/vendor/cigraph/vendor/pcg/pcg-output-64.o&#39; /usr/bin/nm /games/preferencsh src/misc/order_c-c rgo/bin/as /usr/bin/nm (dns block)
    • Triggering command: /opt/R/4.5.2/lib/R/bin/exec/R /opt/R/4.5.2/lib/R/bin/exec/R --no-restore --no-echo --args nextArgigraph_2.2.1.9017.tar.gznextArg--as-crannextArg--timingsnextArg--no-manual /00LOCK-igraph/00new/igraph/libs/igraph.so g &#39;/tmp/RtmpwNRKqt/Rbuild69aa179eb5fa/igraph/src/vendor/cigraph/vendor/cs/cs_ltsolve.o&#39; /usr/bin/nm /core/set.o src/layout/kamad-c /x86_64-linux-gn-- /usr/bin/nm -Pg /tmp/RtmpwNRKqt/Rbuild69aa179eb5fa/igraph/src/vendor/cigraph/src/operators/simplify.o g &#39;/tmp/RtmpwNRKqt/Rbuild69aa179eb5fa/igraph/src/vendor/cigraph/vendor/pcg/pcg-output-64.o&#39; /usr/bin/nm /games/preferencsh src/misc/order_c-c rgo/bin/as /usr/bin/nm (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Fix formatting of error messages from C refactor: scrub file names in expect_snapshot_igraph_error() Jan 24, 2026
Copilot AI requested a review from krlmlr January 24, 2026 10:56
@krlmlr krlmlr marked this pull request as ready for review January 24, 2026 10:58
Copilot AI review requested due to automatic review settings January 24, 2026 10:58
@krlmlr krlmlr merged commit 625e841 into better Jan 24, 2026
@krlmlr krlmlr deleted the copilot/sub-pr-2515 branch January 24, 2026 10:58
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 enhances the expect_snapshot_igraph_error() test helper function to scrub file paths and line numbers from error messages in test snapshots, making them independent of build directory structures and more stable across different environments.

Changes:

  • Updated the transform function in expect_snapshot_igraph_error() to replace file paths and line numbers with placeholders <file> and <line>
  • Regenerated 52 error message snapshots across test files to use the new sanitized format
  • Added tests/testthat/_problems/ to .gitignore to exclude testthat's problem report directory

Reviewed changes

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

File Description
tests/testthat/helper.R Enhanced transform function with two regex patterns to scrub "Source:" and "At" file path patterns, with backward compatibility for legacy placeholders
tests/testthat/_snaps/centrality.md Updated 1 error snapshot to use <file>:<line> placeholders
tests/testthat/_snaps/aaa-auto.md Updated 51 error snapshots to use <file>:<line> placeholders
.gitignore Added testthat problem reports directory to exclusions

# Scrub file name and line number from error/warning messages
# Handles "Source: filename:linenumber" and "At path/to/file:line :" patterns
y <- gsub("Source: [^:]+:(\\d+|xx|<linenumber>)", "Source: <file>:<line>", y)
y <- gsub("At [^:]+:(\\d+|xx) :", "At <file>:<line> :", y)
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

The regex pattern for the "At" pattern on line 55 only includes xx as a legacy placeholder but not <linenumber>, while the "Source" pattern on line 54 includes both xx and <linenumber>. For consistency and to handle all cases mentioned in the PR description, consider updating the pattern to: "At [^:]+:(\\d+|xx|<linenumber>) :". This ensures both patterns handle the same set of legacy placeholders.

Suggested change
y <- gsub("At [^:]+:(\\d+|xx) :", "At <file>:<line> :", y)
y <- gsub("At [^:]+:(\\d+|xx|<linenumber>) :", "At <file>:<line> :", y)

Copilot uses AI. Check for mistakes.
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.

2 participants