-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathjcpan
More file actions
executable file
·143 lines (131 loc) · 5.14 KB
/
Copy pathjcpan
File metadata and controls
executable file
·143 lines (131 loc) · 5.14 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/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
# Use --provider with -t for an explicit, non-installing upstream conformance
# run against a bundled provider:
# jcpan --provider -t Module::Name
# Use --strict-dependency-tests to run each dependency's own test surface and
# resolve its test-only prerequisites recursively.
#
# Note: standard cpan uses -j for config file loading, so we use --jobs
# to avoid conflicts. --notest is a friendly long-form alias for cpan's -T.
#
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Parse --jobs option for parallel test jobs (consumed here, not passed to cpan)
ARGS=()
NO_TEST=0
PROVIDER_CONFORMANCE=0
STRICT_DEPENDENCY_TESTS=0
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
;;
--notest)
NO_TEST=1
shift
;;
--provider)
PROVIDER_CONFORMANCE=1
shift
;;
--strict-dependency-tests)
STRICT_DEPENDENCY_TESTS=1
shift
;;
*)
ARGS+=("$1")
shift
;;
esac
done
if [[ "$PROVIDER_CONFORMANCE" -eq 1 ]]; then
export PERLONJAVA_PROVIDER_CONFORMANCE=1
fi
if [[ "$STRICT_DEPENDENCY_TESTS" -eq 1 ]]; then
export PERLONJAVA_STRICT_DEPENDENCY_TESTING=1
fi
if [[ "$NO_TEST" -eq 1 ]]; then
if [[ "${ARGS[0]:-}" == "install" ]]; then
ARGS=(-T -i "${ARGS[@]:1}")
else
ARGS=(-T "${ARGS[@]}")
fi
fi
# 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 (900s) 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=900 (15 min)
export JPERL_TEST_TIMEOUT="${JPERL_TEST_TIMEOUT:-900}"
# CPAN suites routinely contain parser and regex stress tests whose recursion
# depth is valid for Perl but exceeds the JVM's small default thread stack.
# Give test subprocesses the same bounded large-stack baseline used by the
# core compatibility runner. Preserve an explicit per-test override and any
# caller-supplied JVM options.
if [[ -z "${PERLONJAVA_TEST_JPERL_OPTS:-}" ]]; then
case " ${JPERL_OPTS:-} " in
*" -Xss"*) export PERLONJAVA_TEST_JPERL_OPTS="$JPERL_OPTS" ;;
*) export PERLONJAVA_TEST_JPERL_OPTS="${JPERL_OPTS:+$JPERL_OPTS }-Xss256m" ;;
esac
fi
# Enable the orphan-exit watchdog in every jperl this run spawns. If the
# parent jcpan / test_harness process is killed (e.g. SIGKILL'd by the
# user, or terminated by a CI step), each child JVM polls its initial
# parent PID every 2s and self-exits when that parent disappears.
# Without this, killing the harness leaves dozens of in-flight test
# JVMs reparented to PID 1, all spinning at 100% CPU until manually
# pkill'd. See AGENTS.md "ALWAYS WRAP jperl/jcpan IN timeout" rule.
export JPERL_ORPHAN_EXIT=1
# CPAN build tools may install copies of their own implementation modules into
# the user library. Keep PerlOnJava's narrow compatibility overlays ahead of
# those copies while jcpan and its child build processes run.
export PERLONJAVA_PREFER_BUNDLED_MODULES="Module/Build/Base.pm${PERLONJAVA_PREFER_BUNDLED_MODULES:+,$PERLONJAVA_PREFER_BUNDLED_MODULES}"
# CPAN test suites should run with deterministic semantics. User-interface
# color preferences such as NO_COLOR can change module behavior under test
# (for example Color::ANSI::Util), so do not pass them into jcpan runs.
unset NO_COLOR
unset ANSI_COLORS_DISABLED
# 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 PERLONJAVA_JCPAN_ARGS="${ARGS[*]}"
export PATH="$SCRIPT_DIR:$PATH"
exec "$SCRIPT_DIR/jperl" "$CPAN_SCRIPT" "${ARGS[@]}"