Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts: misc fixes, and clarify public vs. private with underscores #494

Merged
merged 3 commits into from
Sep 20, 2023

Conversation

gperciva
Copy link
Member

No description provided.

@gperciva
Copy link
Member Author

In POSIX sh, there's no such thing as "public" or "private" functions.

However, functions are allowed to contain underscores [1], so we're adopting the convention of leading underscores indicating a function which is not intended to be called by code in a different file.

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_235

@gperciva

This comment was marked as outdated.

@gperciva gperciva force-pushed the scripts-public-private branch from 25e93ca to 743422b Compare August 17, 2023 03:21
@gperciva gperciva marked this pull request as ready for review August 17, 2023 03:22
@gperciva

This comment was marked as outdated.

@gperciva gperciva marked this pull request as draft August 17, 2023 17:58
@gperciva gperciva closed this Aug 19, 2023
@gperciva gperciva reopened this Aug 29, 2023
@gperciva gperciva force-pushed the scripts-public-private branch from 743422b to 5a78d7e Compare August 29, 2023 17:27
@gperciva gperciva changed the title scripts: clarify public vs. private with underscores scripts: misc fixes, and clarify public vs. private with underscores Aug 29, 2023
@gperciva gperciva marked this pull request as ready for review August 29, 2023 17:30
@gperciva gperciva marked this pull request as draft August 30, 2023 00:41
- Add find_system() to the "public API", which should have been part of:
    2023-06-29 scripts: misc fixes
    ed4c19a
  find_system() is not used by any other scripts in libcperciva, but
  other projects make use of it.

- Fix the API comment for run_scenarios(), which should have been part of:
    2021-03-24 tests: add `make test N=` to shared framework
    acea39b

- Fix the API comment for valgrind_check_optional(), which was incorrect
  from the very beginning:
    2017-10-28 tests: import shared_test_functions.sh
    d486415

- Use {} for $USE_VALGRIND and $PATH in comments.  This should have been
  part of:
    2023-08-06 scripts: always use double quotes and curly braces
    a1e8ac7
- document the public variables
- define them in a single place
- instead of recording the number of open file descriptors (as a public
  variable), just keep the relevant filename; we can extract the actual
  number every time we need it.  This simplifies the logic of
  USE_VALGRIND_NO_REGEN.
In POSIX sh, there's no such thing as "public" or "private" functions.

However, functions are allowed to contain underscores [1], so we're
adopting the convention of leading underscores indicating a function
which is not intended to be called by code in a different file.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_235

Private functions in shared_test_functions.sh:
    prepare_directory
    notify_success_or_fail
    scenario_runner

Private functions in shared_valgrind_functions.sh:
    valgrind_prepare_directory
    valgrind_check_optional
    valgrind_process_suppression_file
    valgrind_ensure_suppression
    valgrind_get_basename
    valgrind_check_logfile
@gperciva gperciva force-pushed the scripts-public-private branch from 5a78d7e to 5b8921e Compare August 30, 2023 17:12
@gperciva gperciva marked this pull request as ready for review August 30, 2023 17:12
@cperciva cperciva merged commit 3b2e076 into master Sep 20, 2023
@gperciva gperciva deleted the scripts-public-private branch September 20, 2023 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants