Skip to content

fix: read NAMESPACE to check source-module exports#83

Merged
vandenman merged 3 commits into
jasp-stats:masterfrom
juliuspfadt:fix/rFunctionExistsInModule-source-pkg
Jun 12, 2026
Merged

fix: read NAMESPACE to check source-module exports#83
vandenman merged 3 commits into
jasp-stats:masterfrom
juliuspfadt:fix/rFunctionExistsInModule-source-pkg

Conversation

@juliuspfadt

@juliuspfadt juliuspfadt commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

#81 replaced R-file sourcing with getFromNamespace, which requires the package to already be loaded. Test files whose analysisOptions() call runs before any runAnalysis() has loaded the namespace therefore fail.
For instance, this one https://github.com/jasp-stats/jaspReliability/actions/runs/27349024804/job/80805431404
or https://github.com/jasp-stats/jaspFactor/actions/runs/27413322189/job/81019730649

Reading the NAMESPACE file directly is load-order-independent, simpler, and equally fast.

getFromNamespace requires the package to be loaded, causing
analysisOptions() to fail for test files that run before any
runAnalysis() has loaded the package into R's namespace.

Reading the NAMESPACE file directly is simpler, faster, and
works without the package being installed or loaded.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates rFunctionExistsInModule() to determine whether a function is available in a (non-binary) module by inspecting the module’s NAMESPACE exports, removing the previous namespace lookup helper.

Changes:

  • Removed function_exists() helper that used utils::getFromNamespace().
  • Updated non-binary path in rFunctionExistsInModule() to read NAMESPACE and detect export(<funName>).

Comment thread R/utils.R Outdated
Comment on lines +82 to +83
nsFile <- file.path(modulePath, "NAMESPACE")
return(any(grepl(paste0("^export\\(", funName, "\\)$"), readLines(nsFile, warn = FALSE))))
Comment thread R/utils.R Outdated
Comment on lines +82 to +83
nsFile <- file.path(modulePath, "NAMESPACE")
return(any(grepl(paste0("^export\\(", funName, "\\)$"), readLines(nsFile, warn = FALSE))))
Handles export(foo, bar), whitespace, comments, and names with
regex metacharacters correctly without any string escaping.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 1 out of 1 changed files in this pull request and generated no new comments.

Comment thread R/utils.R
@vandenman vandenman merged commit 281f17a into jasp-stats:master Jun 12, 2026
9 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.

3 participants