Replace all Perl scripts with Rust
This commit is contained in:
parent
dad7ec15de
commit
dbeb1eb6a2
49
.github/workflows/test.yml
vendored
49
.github/workflows/test.yml
vendored
@ -17,7 +17,7 @@ jobs:
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "x86-64.+FreeBSD"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
expect_stripped: ""
|
||||
can_execute: false
|
||||
|
||||
- platform_name: Linux-x86_64
|
||||
@ -25,7 +25,7 @@ jobs:
|
||||
target: x86_64-unknown-linux-musl
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "ELF.+x86-64"
|
||||
expect_cross: "--no-expect-cross"
|
||||
expect_cross: ""
|
||||
expect_stripped: "--expect-stripped"
|
||||
can_execute: true
|
||||
|
||||
@ -35,7 +35,7 @@ jobs:
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "aarch64"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
expect_stripped: ""
|
||||
can_execute: true
|
||||
|
||||
- platform_name: Linux-aarch64 (no cache)
|
||||
@ -44,7 +44,7 @@ jobs:
|
||||
cache-cross-binary: false
|
||||
expect_file_re: "aarch64"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
expect_stripped: ""
|
||||
can_execute: true
|
||||
|
||||
- platform_name: Linux-aarch64 with cross v0.2.3
|
||||
@ -55,7 +55,7 @@ jobs:
|
||||
expect_file_re: "aarch64"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_cross_version: "0.2.3"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
expect_stripped: ""
|
||||
can_execute: true
|
||||
|
||||
- platform_name: Linux-aarch64 with cross v0.2.3 (no cache)
|
||||
@ -66,7 +66,7 @@ jobs:
|
||||
expect_file_re: "aarch64"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_cross_version: "0.2.3"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
expect_stripped: ""
|
||||
can_execute: true
|
||||
|
||||
- platform_name: Linux-aarch64 with cross 19be834
|
||||
@ -77,7 +77,7 @@ jobs:
|
||||
expect_file_re: "aarch64"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_cross_version: "19be834"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
expect_stripped: ""
|
||||
can_execute: true
|
||||
|
||||
- platform_name: Linux-aarch64 with cross 19be834
|
||||
@ -88,7 +88,7 @@ jobs:
|
||||
expect_file_re: "aarch64"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_cross_version: "19be834"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
expect_stripped: ""
|
||||
can_execute: true
|
||||
|
||||
- platform_name: Linux-arm
|
||||
@ -97,7 +97,7 @@ jobs:
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "32.+ARM"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
expect_stripped: ""
|
||||
can_execute: true
|
||||
|
||||
- platform_name: Linux-i586
|
||||
@ -106,7 +106,7 @@ jobs:
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "ELF.+80386"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
expect_stripped: ""
|
||||
can_execute: true
|
||||
|
||||
- platform_name: Linux-i686
|
||||
@ -115,7 +115,7 @@ jobs:
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "ELF.+80386"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
expect_stripped: ""
|
||||
can_execute: true
|
||||
|
||||
- platform_name: Linux-powerpc
|
||||
@ -124,7 +124,7 @@ jobs:
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "32.+PowerPC"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
expect_stripped: ""
|
||||
can_execute: true
|
||||
|
||||
- platform_name: Linux-powerpc64
|
||||
@ -133,7 +133,7 @@ jobs:
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "64.+PowerPC"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
expect_stripped: ""
|
||||
can_execute: true
|
||||
|
||||
- platform_name: Linux-powerpc64le
|
||||
@ -142,7 +142,7 @@ jobs:
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "64.+PowerPC"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
expect_stripped: ""
|
||||
can_execute: true
|
||||
|
||||
- platform_name: Linux-riscv64
|
||||
@ -151,7 +151,7 @@ jobs:
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "64.+RISC-V"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
expect_stripped: ""
|
||||
can_execute: true
|
||||
|
||||
- platform_name: Linux-s390x
|
||||
@ -160,7 +160,7 @@ jobs:
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "64.+S/390"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
expect_stripped: ""
|
||||
can_execute: true
|
||||
|
||||
- platform_name: NetBSD-x86_64
|
||||
@ -169,7 +169,7 @@ jobs:
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "x86-64.+NetBSD"
|
||||
expect_cross: "--expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
expect_stripped: ""
|
||||
can_execute: false
|
||||
|
||||
- platform_name: Windows-aarch64
|
||||
@ -177,8 +177,8 @@ jobs:
|
||||
target: aarch64-pc-windows-msvc
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "Aarch64.+Windows"
|
||||
expect_cross: "--no-expect-cross"
|
||||
expect_stripped: "--no-expect-stripped"
|
||||
expect_cross: ""
|
||||
expect_stripped: ""
|
||||
can_execute: false
|
||||
|
||||
- platform_name: Windows-i686
|
||||
@ -186,7 +186,7 @@ jobs:
|
||||
target: i686-pc-windows-msvc
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "80386.+Windows"
|
||||
expect_cross: "--no-expect-cross"
|
||||
expect_cross: ""
|
||||
expect_stripped: "--expect-stripped"
|
||||
can_execute: true
|
||||
|
||||
@ -203,7 +203,7 @@ jobs:
|
||||
target: x86_64-apple-darwin
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "Mach-O.+x86_64"
|
||||
expect_cross: "--no-expect-cross"
|
||||
expect_cross: ""
|
||||
expect_stripped: "--expect-stripped"
|
||||
can_execute: true
|
||||
|
||||
@ -212,7 +212,7 @@ jobs:
|
||||
target: aarch64-apple-darwin
|
||||
cache-cross-binary: true
|
||||
expect_file_re: "Mach-O.+arm64"
|
||||
expect_cross: "--no-expect-cross"
|
||||
expect_cross: ""
|
||||
expect_stripped: "--expect-stripped"
|
||||
can_execute: false
|
||||
|
||||
@ -285,7 +285,10 @@ jobs:
|
||||
- name: Check binary and cross on ${{ matrix.platform.platform_name }}
|
||||
shell: bash
|
||||
run: |
|
||||
tests/check-binary.pl \
|
||||
set -e
|
||||
set -x
|
||||
cargo run --manifest-path ./run-tests/Cargo.toml -- \
|
||||
--checkout-root "$PWD" \
|
||||
--target "${{ matrix.platform.target }}" \
|
||||
--expect-file-re "${{ matrix.platform.expect_file_re }}" \
|
||||
--expect-cross-version "${{ matrix.platform.expect_cross_version }}" \
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,4 +3,5 @@
|
||||
/package.json
|
||||
.\#*
|
||||
\#*\#
|
||||
run-tests/**/target/**
|
||||
test-project/**/target/**
|
||||
|
||||
52
git/setup.py
Executable file
52
git/setup.py
Executable file
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# This code was mostly written by Claude.ai.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def main() -> None:
|
||||
"""
|
||||
Main entry point to create a pre-commit hook symlink.
|
||||
"""
|
||||
symlink_hook("pre-commit")
|
||||
|
||||
|
||||
def symlink_hook(hook: str) -> None:
|
||||
"""
|
||||
Create a symlink for a Git hook if it doesn't already exist.
|
||||
|
||||
Args:
|
||||
hook: Name of the Git hook (e.g., 'pre-commit')
|
||||
"""
|
||||
# Path to the hook in .git/hooks
|
||||
dot_hook_path = os.path.join(".git", "hooks", hook)
|
||||
|
||||
# Path to the actual hook script
|
||||
file_hook_path = os.path.join("git", "hooks", f"{hook}.sh")
|
||||
|
||||
# Relative symlink path
|
||||
link_path = os.path.join("..", "..", file_hook_path)
|
||||
|
||||
# Check if the hook already exists
|
||||
if os.path.exists(dot_hook_path):
|
||||
# If it's already a symlink, check if it points to the correct location
|
||||
if os.path.islink(dot_hook_path):
|
||||
# If the existing symlink is correct, do nothing
|
||||
if os.readlink(dot_hook_path) == link_path:
|
||||
return
|
||||
|
||||
# If a hook exists and is not the expected symlink, warn and exit
|
||||
print(f"You already have a hook at {dot_hook_path}!", file=sys.stderr)
|
||||
return
|
||||
|
||||
# Create the symlink
|
||||
try:
|
||||
os.symlink(link_path, dot_hook_path)
|
||||
except OSError as e:
|
||||
print(f"Error creating symlink: {e}", file=sys.stderr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@ -3,6 +3,62 @@ exclude = [
|
||||
"tests/lib/**/*",
|
||||
]
|
||||
|
||||
[commands.clippy]
|
||||
type = "lint"
|
||||
include = "**/*.rs"
|
||||
invoke = "once"
|
||||
path-args = "none"
|
||||
working-dir.chdir-to = "run-tests"
|
||||
cmd = [
|
||||
"cargo",
|
||||
"clippy",
|
||||
"--color",
|
||||
"always",
|
||||
"--locked",
|
||||
"--all-targets",
|
||||
"--all-features",
|
||||
"--",
|
||||
"-D",
|
||||
"clippy::pedantic",
|
||||
]
|
||||
ok_exit_codes = 0
|
||||
lint_failure_exit_codes = 101
|
||||
expect_stderr = true
|
||||
labels = ["default"]
|
||||
|
||||
[commands."clippy --fix"]
|
||||
type = "tidy"
|
||||
include = "**/*.rs"
|
||||
invoke = "once"
|
||||
path-args = "none"
|
||||
working-dir.chdir-to = "run-tests"
|
||||
cmd = [
|
||||
"cargo",
|
||||
"clippy",
|
||||
"--fix",
|
||||
"--allow-dirty",
|
||||
"--locked",
|
||||
"--all-targets",
|
||||
"--all-features",
|
||||
"--",
|
||||
"-D",
|
||||
"clippy::pedantic",
|
||||
]
|
||||
ok_exit_codes = 0
|
||||
lint_failure_exit_codes = 101
|
||||
expect_stderr = true
|
||||
labels = ["default"]
|
||||
|
||||
[commands.rustfmt]
|
||||
type = "both"
|
||||
include = "**/*.rs"
|
||||
working-dir.chdir-to = "run-tests"
|
||||
cmd = ["rustfmt", "--edition", "2021"]
|
||||
lint_flags = "--check"
|
||||
ok_exit_codes = [0]
|
||||
lint_failure_exit_codes = [1]
|
||||
labels = ["default", "fast-tidy"]
|
||||
|
||||
[commands."ruff for linting"]
|
||||
type = "both"
|
||||
include = [ "**/*.py" ]
|
||||
@ -31,35 +87,6 @@ tidy_flags = "--write-changes"
|
||||
ok-exit-codes = 0
|
||||
lint-failure-exit-codes = 2
|
||||
|
||||
[commands.perltidy]
|
||||
type = "both"
|
||||
include = [ "**/*.{pl,pm,t,psgi}" ]
|
||||
exclude = "tests/lib/**"
|
||||
cmd = [ "perltidy", "--profile=$PRECIOUS_ROOT/perltidyrc" ]
|
||||
lint_flags = [ "--assert-tidy", "--no-standard-output", "--outfile=/dev/null" ]
|
||||
tidy_flags = [ "--backup-and-modify-in-place", "--backup-file-extension=/" ]
|
||||
ok_exit_codes = 0
|
||||
lint_failure_exit_codes = 2
|
||||
ignore_stderr = "Begin Error Output Stream"
|
||||
|
||||
[commands."ruff for linting"]
|
||||
type = "both"
|
||||
include = [ "**/*.py" ]
|
||||
cmd = "ruff"
|
||||
lint_flags = [ "check" ]
|
||||
tidy_flags = [ "check", "--fix" ]
|
||||
ok_exit_codes = 0
|
||||
lint_failure_exit_codes = 1
|
||||
|
||||
[commands."ruff for tidying"]
|
||||
type = "both"
|
||||
include = [ "**/*.py" ]
|
||||
cmd = "ruff"
|
||||
lint_flags = [ "format", "--check" ]
|
||||
tidy_flags = [ "format" ]
|
||||
ok_exit_codes = 0
|
||||
lint_failure_exit_codes = 1
|
||||
|
||||
[commands.prettier-md]
|
||||
type = "both"
|
||||
include = [ "**/*.md" ]
|
||||
|
||||
314
run-tests/Cargo.lock
generated
Normal file
314
run-tests/Cargo.lock
generated
Normal file
@ -0,0 +1,314 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
"anstyle-query",
|
||||
"anstyle-wincon",
|
||||
"colorchoice",
|
||||
"is_terminal_polyfill",
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
"strsim",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "is_executable"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4a1b5bad6f9072935961dfbf1cced2f3d129963d091b6f69f007fe04e758ae2"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.92"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
||||
|
||||
[[package]]
|
||||
name = "run-tests"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"is_executable",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.90"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
9
run-tests/Cargo.toml
Normal file
9
run-tests/Cargo.toml
Normal file
@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "run-tests"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.5.23", features = ["derive"] }
|
||||
is_executable = "1.0.4"
|
||||
regex = "1.11.1"
|
||||
155
run-tests/src/main.rs
Normal file
155
run-tests/src/main.rs
Normal file
@ -0,0 +1,155 @@
|
||||
// Mostly written by Claude.ai.
|
||||
|
||||
use clap::Parser;
|
||||
use is_executable::is_executable;
|
||||
use regex::Regex;
|
||||
use std::{
|
||||
env,
|
||||
path::{Path, PathBuf},
|
||||
process::Command,
|
||||
};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
struct Args {
|
||||
#[arg(long)]
|
||||
checkout_root: String,
|
||||
#[arg(long)]
|
||||
target: String,
|
||||
#[arg(long)]
|
||||
expect_file_re: Option<String>,
|
||||
#[arg(long)]
|
||||
expect_cross: bool,
|
||||
#[arg(long)]
|
||||
expect_cross_version: Option<String>,
|
||||
#[arg(long)]
|
||||
expect_stripped: bool,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = Args::parse();
|
||||
|
||||
let runner_temp = env::var("RUNNER_TEMP").expect("RUNNER_TEMP is not set");
|
||||
let runner_temp_path = PathBuf::from(runner_temp);
|
||||
|
||||
check_cross(
|
||||
&runner_temp_path,
|
||||
args.expect_cross,
|
||||
args.expect_cross_version.as_deref(),
|
||||
);
|
||||
|
||||
let checkout_root_path = PathBuf::from(args.checkout_root);
|
||||
let bin_paths = vec![
|
||||
checkout_root_path
|
||||
.join("target")
|
||||
.join(&args.target)
|
||||
.join("debug")
|
||||
.join("bin1"),
|
||||
checkout_root_path
|
||||
.join("target")
|
||||
.join(&args.target)
|
||||
.join("debug")
|
||||
.join("bin2"),
|
||||
checkout_root_path
|
||||
.join("subcrate")
|
||||
.join("target")
|
||||
.join(&args.target)
|
||||
.join("debug")
|
||||
.join("subcrate"),
|
||||
];
|
||||
|
||||
for mut bin_path in bin_paths {
|
||||
if cfg!(windows) {
|
||||
bin_path.set_extension("exe");
|
||||
}
|
||||
check_binary(
|
||||
&bin_path,
|
||||
args.expect_file_re.as_deref(),
|
||||
args.expect_stripped,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_cross(bin_dir: &Path, expect_cross: bool, expect_cross_version: Option<&str>) {
|
||||
let cross_path = bin_dir.join("cross");
|
||||
|
||||
if expect_cross {
|
||||
assert!(cross_path.is_file(), "`cross` exists");
|
||||
|
||||
if let Some(expected_version) = expect_cross_version {
|
||||
let output = Command::new(&cross_path)
|
||||
.arg("--version")
|
||||
.output()
|
||||
.expect("Failed to execute `cross` command");
|
||||
let version = String::from_utf8(output.stdout)
|
||||
.expect("`cross --version` stdout was not valid UTF-8");
|
||||
assert!(
|
||||
version.contains(expected_version),
|
||||
"`cross` version matches expected version"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
assert!(!cross_path.exists(), "`cross` was not downloaded");
|
||||
}
|
||||
}
|
||||
|
||||
fn check_binary(bin_path: &PathBuf, expect_file_re: Option<&str>, expect_stripped: bool) {
|
||||
assert!(bin_path.exists(), "Binary at {} exists", bin_path.display());
|
||||
assert!(
|
||||
bin_path.is_file(),
|
||||
"Binary at {} is a file",
|
||||
bin_path.display()
|
||||
);
|
||||
|
||||
assert!(
|
||||
is_executable(bin_path),
|
||||
"Binary at {} is executable",
|
||||
bin_path.display()
|
||||
);
|
||||
|
||||
let output = Command::new("file")
|
||||
.arg("--brief")
|
||||
.arg(bin_path)
|
||||
.output()
|
||||
.expect("Failed to execute `file` command");
|
||||
let file_output = String::from_utf8_lossy(&output.stdout);
|
||||
|
||||
if let Some(file_re) = expect_file_re {
|
||||
let re = Regex::new(file_re).expect("Invalid regex");
|
||||
assert!(
|
||||
re.is_match(&file_output),
|
||||
"`file` output for {} matches expected output",
|
||||
bin_path.display(),
|
||||
);
|
||||
}
|
||||
|
||||
// `file` on macOS doesn't report if the binary is stripped.
|
||||
if cfg!(target_os = "macos") {
|
||||
return;
|
||||
}
|
||||
|
||||
if expect_stripped {
|
||||
assert!(
|
||||
!file_output.contains("not stripped"),
|
||||
"`file` does not report {} as not stripped",
|
||||
bin_path.display(),
|
||||
);
|
||||
assert!(
|
||||
file_output.contains("stripped"),
|
||||
"`file` reports {} as stripped",
|
||||
bin_path.display(),
|
||||
);
|
||||
} else if cfg!(windows) {
|
||||
assert!(
|
||||
!file_output.contains("stripped"),
|
||||
"`file` does not report {} as stripped",
|
||||
bin_path.display(),
|
||||
);
|
||||
} else {
|
||||
assert!(
|
||||
file_output.contains("not stripped"),
|
||||
"`file` reports {} as not stripped",
|
||||
bin_path.display(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
|
||||
@ -1,114 +0,0 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
use v5.30;
|
||||
use strict;
|
||||
use warnings;
|
||||
no warnings 'experimental::signatures';
|
||||
use feature 'signatures';
|
||||
use autodie;
|
||||
|
||||
use FindBin qw( $Bin );
|
||||
use File::Spec;
|
||||
use lib File::Spec->catdir( $Bin, 'lib' );
|
||||
|
||||
use Getopt::Long;
|
||||
use IPC::System::Simple qw( capturex );
|
||||
use Path::Tiny qw( path );
|
||||
use Test::More;
|
||||
|
||||
sub main {
|
||||
my $target;
|
||||
my $expect_cross;
|
||||
my $expect_cross_version;
|
||||
my $expect_file_re;
|
||||
my $expect_stripped;
|
||||
|
||||
GetOptions(
|
||||
'target=s' => \$target,
|
||||
'expect-file-re=s' => \$expect_file_re,
|
||||
'expect-cross!' => \$expect_cross,
|
||||
'expect-cross-version=s' => \$expect_cross_version,
|
||||
'expect-stripped!' => \$expect_stripped,
|
||||
);
|
||||
|
||||
check_cross(
|
||||
path( $ENV{RUNNER_TEMP} ),
|
||||
$expect_cross,
|
||||
$expect_cross_version
|
||||
);
|
||||
|
||||
for my $bin (
|
||||
path( qw( . target ), $target, qw( debug bin1 ) ),
|
||||
path( qw( . target ), $target, qw( debug bin2 ) ),
|
||||
path( qw( . subcrate target ), $target, qw( debug subcrate ) )
|
||||
) {
|
||||
check_binary( $bin, $expect_file_re, $expect_stripped );
|
||||
}
|
||||
|
||||
done_testing();
|
||||
}
|
||||
|
||||
sub check_cross ( $bin_dir, $expect_cross, $expect_cross_version ) {
|
||||
my $cross = $bin_dir->child('cross');
|
||||
if ($expect_cross) {
|
||||
ok( $cross->is_file && -x $cross, 'found `cross` in $PATH' );
|
||||
if ($expect_cross_version) {
|
||||
my $version = capturex( $cross, '--version' );
|
||||
like(
|
||||
$version, qr/\Q$expect_cross_version/,
|
||||
'cross version matches expected version'
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ok( !$cross->exists, 'did not find `cross` in $PATH' );
|
||||
}
|
||||
}
|
||||
|
||||
sub check_binary ( $bin, $expect_file_re, $expect_stripped ) {
|
||||
ok( $bin->exists, "Binary at $bin exists" )
|
||||
or return;
|
||||
ok( $bin->is_file, "Binary at $bin is a file" )
|
||||
or return;
|
||||
ok( -x $bin, "Binary at $bin is executable" )
|
||||
or return;
|
||||
|
||||
my $file = capturex( qw( file --brief ), $bin ) // q{};
|
||||
chomp $file;
|
||||
|
||||
like(
|
||||
$file, qr/$expect_file_re/,
|
||||
"`file` output for $bin matches expected output"
|
||||
);
|
||||
|
||||
# The file command on macOS doesn't report whether the binary is stripped
|
||||
# or not.
|
||||
return if $^O eq 'darwin';
|
||||
|
||||
if ($expect_stripped) {
|
||||
unlike(
|
||||
$file, qr/not stripped/,
|
||||
"`file` does not report $bin as not stripped"
|
||||
);
|
||||
like( $file, qr/stripped/, "`file` reports $bin as stripped" );
|
||||
}
|
||||
else {
|
||||
if ( $^O eq 'MSWin32' || $^O eq 'msys' ) {
|
||||
|
||||
# On Windows, unstripped binaries don't contain the word
|
||||
# "stripped" at all.
|
||||
unlike(
|
||||
$file, qr/stripped/,
|
||||
"`file` does not report $bin as stripped"
|
||||
);
|
||||
}
|
||||
else {
|
||||
like(
|
||||
$file, qr/not stripped/,
|
||||
"`file` reports $bin as not stripped"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user