What changed, and why it matters
This commit simply renames a test-generation script and updates the GitHub Actions workflow that calls it. The old file `contrib/generate-re-export-test.sh` is renamed to `contrib/generate-primitives-re-export-test.sh`, and the CI step name and command are updated accordingly. The script's contents are unchanged. There is no security relevance.
No security action needed. This is a routine refactoring/rename commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff is a pure rename of contrib/generate-re-export-test.sh to contrib/generate-primitives-re-export-test.sh with identical content, plus a matching update in .github/workflows/rust.yml to invoke the new script name. The script generates a compile-time test verifying that bitcoin_units public items are re-exported through bitcoin_primitives. No code behavior changes, no bug fixes, and no security-sensitive modifications are present.
Changed components
.github/workflows/rust.ymlcontrib/generate-primitives-re-export-test.shcontrib/generate-re-export-test.shInspect captured patch +172 / −172
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
index 5b47d8df..5016ba16 100644
--- a/.github/workflows/rust.yml
+++ b/.github/workflows/rust.yml
@@ -433,5 +433,5 @@ jobs:
persist-credentials: false
- name: "Select toolchain"
uses: dtolnay/rust-toolchain@5d458579430fc14a04a08a1e7d3694f545e91ce6 # stable
- - name: "Run API checker script"
- run: contrib/generate-re-export-test.sh && cd ./primitives && cargo test --all-features
+ - name: "Run primitives API checker script"
+ run: contrib/generate-primitives-re-export-test.sh && cd ./primitives && cargo test --all-features
diff --git a/contrib/generate-primitives-re-export-test.sh b/contrib/generate-primitives-re-export-test.sh
new file mode 100755
index 00000000..ca138ead
--- /dev/null
+++ b/contrib/generate-primitives-re-export-test.sh
@@ -0,0 +1,170 @@
+#!/usr/bin/env bash
+#
+# Script for generating a Rust test file that verifies all bitcoin_units items
+# are re-exported in bitcoin_primitives.
+#
+# The script parses api/units/all-features.txt and generates use statements
+# that will fail to compile if any re-exports are missing.
+
+set -euo pipefail
+
+api_file="./api/units/all-features.txt"
+output_file="./primitives/tests/check-re-exports.rs"
+
+usage() {
+ cat <<EOF
+Usage:
+
+ ./generate-primitives-re-export-test.sh
+
+DESCRIPTION
+ Generates a Rust test file that verifies all public types and modules from
+ bitcoin_units are re-exported in bitcoin_primitives.
+
+ The script parses api/units/all-features.txt and creates use statements for
+ every 'pub enum', 'pub struct', and 'pub mod' declaration.
+
+ Output file: primitives/tests/check-re-exports.rs
+EOF
+}
+
+main() {
+ while [[ $# -gt 0 ]]; do
+ case $1 in
+ -h|--help)
+ usage
+ exit 0
+ ;;
+ *)
+ say_err "unknown option: $1"
+ usage
+ exit 1
+ ;;
+ esac
+ done
+
+ check_required_commands
+ check_required_files
+
+ say "Parsing $api_file and generating Rust test..."
+
+ generate_test_file
+
+ say "Generated $output_file"
+ say "Run 'cd primitives && cargo test --all-features check_all_bitcoin_units_items_are_reexported' to test"
+}
+
+generate_test_file() {
+ local temp_file;
+ temp_file=$(mktemp)
+
+ # Generate the file header
+ cat > "$temp_file" <<'EOF'
+// SPDX-License-Identifier: CC0-1.0
+
+//! Test that all public types and modules from bitcoin_units are re-exported in bitcoin_primitives.
+//!
+//! This test is automatically generated by contrib/generate-primitives-re-export-test.sh
+//! Any compilation error indicates a missing re-export.
+
+#![allow(dead_code)]
+#![allow(unused_imports)]
+// No benefit in running this test without features enabled.
+#[cfg(not(feature = "alloc"))]
+compile_error!("alloc feature needs to be enabled");
+#[cfg(not(feature = "hex"))]
+compile_error!("hex feature needs to be enabled");
+#[cfg(not(feature = "arbitrary"))]
+compile_error!("arbitrary feature needs to be enabled");
+
+#[test]
+fn check_all_bitcoin_units_items_are_reexported() {
+ // This test will fail to compile if any bitcoin_units item is not re-exported in bitcoin_primitives
+
+EOF
+
+ # Extract and convert all pub items
+ local use_statements=()
+ local seen_items=()
+
+ while IFS= read -r line; do
+ local path=""
+
+ # Extract pub enum
+ if [[ "$line" =~ pub\ enum\ (bitcoin_units::[^[:space:]]+) ]]; then
+ path="${BASH_REMATCH[1]}"
+ # Extract pub struct
+ elif [[ "$line" =~ pub\ struct\ (bitcoin_units::[^[:space:]\(]+) ]]; then
+ path="${BASH_REMATCH[1]}"
+ # Extract pub mod
+ elif [[ "$line" =~ ^pub\ mod\ (bitcoin_units::[^[:space:]]+)$ ]]; then
+ path="${BASH_REMATCH[1]}"
+ fi
+
+ if [[ -n "$path" ]]; then
+ # Remove generic type parameters (e.g., <T>)
+ path="${path%%<*}"
+
+ # Convert bitcoin_units:: to bitcoin_primitives::
+ local primitives_path="${path//bitcoin_units::/bitcoin_primitives::}"
+
+ # Skip if we've already seen this item
+ if [[ " ${seen_items[*]} " != *" $primitives_path "* ]]; then
+ seen_items+=("$primitives_path")
+ use_statements+=(" use $primitives_path as _;")
+ fi
+ fi
+ done < "$api_file"
+
+ # Sort use statements and add to file
+ printf '%s\n' "${use_statements[@]}" | sort >> "$temp_file"
+
+ # Add closing brace
+ echo "}" >> "$temp_file"
+
+ # Move temp file to final location
+ mv "$temp_file" "$output_file"
+}
+
+check_required_files() {
+ if [[ ! -f "$api_file" ]]; then
+ err "Required file not found: $api_file"
+ fi
+
+ local output_dir
+ output_dir=$(dirname "$output_file")
+ if [[ ! -d "$output_dir" ]]; then
+ err "Output directory not found: $output_dir"
+ fi
+}
+
+check_required_commands() {
+ need_cmd grep
+ need_cmd sort
+ need_cmd mktemp
+}
+
+say() {
+ echo "generate-primitives-re-export-test: $1"
+}
+
+say_err() {
+ say "$1" >&2
+}
+
+err() {
+ echo "$1" >&2
+ exit 1
+}
+
+need_cmd() {
+ if ! command -v "$1" > /dev/null 2>&1
+ then err "need '$1' (command not found)"
+ fi
+}
+
+#
+# Main script
+#
+main "$@"
+exit 0
diff --git a/contrib/generate-re-export-test.sh b/contrib/generate-re-export-test.sh
deleted file mode 100755
index 555a8afd..00000000
--- a/contrib/generate-re-export-test.sh
+++ /dev/null
@@ -1,170 +0,0 @@
-#!/usr/bin/env bash
-#
-# Script for generating a Rust test file that verifies all bitcoin_units items
-# are re-exported in bitcoin_primitives.
-#
-# The script parses api/units/all-features.txt and generates use statements
-# that will fail to compile if any re-exports are missing.
-
-set -euo pipefail
-
-api_file="./api/units/all-features.txt"
-output_file="./primitives/tests/check-re-exports.rs"
-
-usage() {
- cat <<EOF
-Usage:
-
- ./generate-re-export-test.sh
-
-DESCRIPTION
- Generates a Rust test file that verifies all public types and modules from
- bitcoin_units are re-exported in bitcoin_primitives.
-
- The script parses api/units/all-features.txt and creates use statements for
- every 'pub enum', 'pub struct', and 'pub mod' declaration.
-
- Output file: primitives/tests/check-re-exports.rs
-EOF
-}
-
-main() {
- while [[ $# -gt 0 ]]; do
- case $1 in
- -h|--help)
- usage
- exit 0
- ;;
- *)
- say_err "unknown option: $1"
- usage
- exit 1
- ;;
- esac
- done
-
- check_required_commands
- check_required_files
-
- say "Parsing $api_file and generating Rust test..."
-
- generate_test_file
-
- say "Generated $output_file"
- say "Run 'cd primitives && cargo test --all-features check_all_bitcoin_units_items_are_reexported' to test"
-}
-
-generate_test_file() {
- local temp_file;
- temp_file=$(mktemp)
-
- # Generate the file header
- cat > "$temp_file" <<'EOF'
-// SPDX-License-Identifier: CC0-1.0
-
-//! Test that all public types and modules from bitcoin_units are re-exported in bitcoin_primitives.
-//!
-//! This test is automatically generated by contrib/generate-re-export-test.sh
-//! Any compilation error indicates a missing re-export.
-
-#![allow(dead_code)]
-#![allow(unused_imports)]
-// No benefit in running this test without features enabled.
-#[cfg(not(feature = "alloc"))]
-compile_error!("alloc feature needs to be enabled");
-#[cfg(not(feature = "hex"))]
-compile_error!("hex feature needs to be enabled");
-#[cfg(not(feature = "arbitrary"))]
-compile_error!("arbitrary feature needs to be enabled");
-
-#[test]
-fn check_all_bitcoin_units_items_are_reexported() {
- // This test will fail to compile if any bitcoin_units item is not re-exported in bitcoin_primitives
-
-EOF
-
- # Extract and convert all pub items
- local use_statements=()
- local seen_items=()
-
- while IFS= read -r line; do
- local path=""
-
- # Extract pub enum
- if [[ "$line" =~ pub\ enum\ (bitcoin_units::[^[:space:]]+) ]]; then
- path="${BASH_REMATCH[1]}"
- # Extract pub struct
- elif [[ "$line" =~ pub\ struct\ (bitcoin_units::[^[:space:]\(]+) ]]; then
- path="${BASH_REMATCH[1]}"
- # Extract pub mod
- elif [[ "$line" =~ ^pub\ mod\ (bitcoin_units::[^[:space:]]+)$ ]]; then
- path="${BASH_REMATCH[1]}"
- fi
-
- if [[ -n "$path" ]]; then
- # Remove generic type parameters (e.g., <T>)
- path="${path%%<*}"
-
- # Convert bitcoin_units:: to bitcoin_primitives::
- local primitives_path="${path//bitcoin_units::/bitcoin_primitives::}"
-
- # Skip if we've already seen this item
- if [[ " ${seen_items[*]} " != *" $primitives_path "* ]]; then
- seen_items+=("$primitives_path")
- use_statements+=(" use $primitives_path as _;")
- fi
- fi
- done < "$api_file"
-
- # Sort use statements and add to file
- printf '%s\n' "${use_statements[@]}" | sort >> "$temp_file"
-
- # Add closing brace
- echo "}" >> "$temp_file"
-
- # Move temp file to final location
- mv "$temp_file" "$output_file"
-}
-
-check_required_files() {
- if [[ ! -f "$api_file" ]]; then
- err "Required file not found: $api_file"
- fi
-
- local output_dir
- output_dir=$(dirname "$output_file")
- if [[ ! -d "$output_dir" ]]; then
- err "Output directory not found: $output_dir"
- fi
-}
-
-check_required_commands() {
- need_cmd grep
- need_cmd sort
- need_cmd mktemp
-}
-
-say() {
- echo "generate-re-export-test: $1"
-}
-
-say_err() {
- say "$1" >&2
-}
-
-err() {
- echo "$1" >&2
- exit 1
-}
-
-need_cmd() {
- if ! command -v "$1" > /dev/null 2>&1
- then err "need '$1' (command not found)"
- fi
-}
-
-#
-# Main script
-#
-main "$@"
-exit 0
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.