Make test config scripts consistent when sourcing other files
#25,162 opened on Jun 3, 2024
Repository metrics
- Stars
- (2,010 stars)
- PR merge metrics
- (PR metrics pending)
Description
We should make test config scripts more consistent with how they see and source other files.
I recently fixed an issue where one of the config scripts was not being sourced, and because no error was thrown this went silently undetected for many years. One way to fix this is to just consitently have the same pattern in all of the test config scripts (util/cron/*.bash).
Additionally, while reviewing https://github.com/chapel-lang/chapel/pull/25161, @bradcray pointed out that using CWD is potentially confusing, as its not really the current working directory but rather the util/cron folder.
We also have two distinct patterns for this, which may lead to confusion.
CWD=$(cd $(dirname ${BASH_SOURCE[0]}) ; pwd)
CWD=$(cd $(dirname $0) ; pwd)
These both have slightly different semantics, but functionally do the same thing, they get the directory path of the current file in a portable way. The difference being that $BASH_SOURCE is always the relative path to the script while $0 is the path to the file as passed to execve (and is not set when the file is sourced).
So I think we should have a consistent way to get the util/cron directory and address @bradcray's concerns and rename CWD to something like scriptDir. Additionally, I think an error in one of these scripts should cause the test to fail, not fail silently.