-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathjcpan
More file actions
executable file
·74 lines (69 loc) · 2.47 KB
/
jcpan
File metadata and controls
executable file
·74 lines (69 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
#
# jcpan - CPAN Client for PerlOnJava (Unix wrapper)
# Runs the standard cpan script with jperl
#
# Supports --jobs N for parallel test execution:
# jcpan --jobs 4 -t Module::Name
#
# Note: standard cpan uses -j for config file loading, so we use --jobs
# to avoid conflicts. All other flags are passed through to cpan.
#
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Parse --jobs option for parallel test jobs (consumed here, not passed to cpan)
ARGS=()
while [[ $# -gt 0 ]]; do
case "$1" in
--jobs)
if [[ -n "$2" && "$2" =~ ^[0-9]+$ ]]; then
export HARNESS_OPTIONS="j${2}"
shift 2
else
echo "Error: --jobs requires a numeric argument" >&2
exit 1
fi
;;
--jobs=*)
val="${1#--jobs=}"
if [[ "$val" =~ ^[0-9]+$ ]]; then
export HARNESS_OPTIONS="j${val}"
else
echo "Error: --jobs requires a numeric argument" >&2
exit 1
fi
shift
;;
*)
ARGS+=("$1")
shift
;;
esac
done
# Find cpan script - check development path first, then installed path
if [ -f "$SCRIPT_DIR/src/main/perl/bin/cpan" ]; then
CPAN_SCRIPT="$SCRIPT_DIR/src/main/perl/bin/cpan"
elif [ -f "$SCRIPT_DIR/bin/cpan" ]; then
CPAN_SCRIPT="$SCRIPT_DIR/bin/cpan"
else
echo "Error: cpan script not found" >&2
exit 1
fi
# Set default per-test timeout (300s) to kill hanging tests
# Tests that produce no output for this duration will be killed
# Override: JPERL_TEST_TIMEOUT=0 (disable) or JPERL_TEST_TIMEOUT=600 (10 min)
export JPERL_TEST_TIMEOUT="${JPERL_TEST_TIMEOUT:-300}"
# Expose the jperl launcher AND the jcpan launcher itself so distroprefs
# (e.g. Moose.yml) can run upstream tests against the bundled shims with
# `prove --exec jperl`, and bootstrap missing helper modules with
# `jcpan SomeModule`. We also prepend SCRIPT_DIR to PATH so shell-spawned
# subprocesses (CPAN's distroprefs commandlines, prove --exec, ...) find
# `jperl` and `jcpan` cross-platform without needing $JPERL_BIN tokens
# that don't expand in Windows cmd.exe.
export JPERL_BIN="$SCRIPT_DIR/jperl"
export JCPAN_BIN="${BASH_SOURCE[0]}"
case "$JCPAN_BIN" in
/*) ;; # already absolute
*) JCPAN_BIN="$SCRIPT_DIR/jcpan" ;;
esac
export PATH="$SCRIPT_DIR:$PATH"
exec "$SCRIPT_DIR/jperl" "$CPAN_SCRIPT" "${ARGS[@]}"