Add unit-test during build for nodejs22
Resolves: RHEL-88877
This commit is contained in:
parent
bb89f4e32a
commit
f2f6d62244
@ -167,6 +167,8 @@ Source202: nodejs.pc.in
|
||||
Source203: v8.pc.in
|
||||
Source204: nodejs22_abi.req
|
||||
Source205: nodejs22_abi.attr
|
||||
Source300: test-runner.sh
|
||||
Source301: test-should-pass.txt
|
||||
|
||||
Patch: 0001-Remove-unused-OpenSSL-config.patch
|
||||
|
||||
@ -807,6 +809,13 @@ install -Dpm0644 %{SOURCE204} %{buildroot}%{_rpmconfigdir}/fileattrs/nodejs%{nod
|
||||
|
||||
|
||||
%check
|
||||
#run unit test that should pass from list
|
||||
LD_LIBRARY_PATH=%{buildroot}%{_libdir} \
|
||||
bash %{SOURCE300} \
|
||||
%{buildroot}/%{_bindir}/node-%{nodejs_pkg_major} \
|
||||
%{_builddir}/node-v%{nodejs_version}/test/ \
|
||||
%{SOURCE301}
|
||||
|
||||
# Fail the build if the versions don't match
|
||||
LD_LIBRARY_PATH=%{buildroot}%{_libdir} %{buildroot}/%{_bindir}/node-%{nodejs_pkg_major} -e "require('assert').equal(process.versions.node, '%{nodejs_version}')"
|
||||
LD_LIBRARY_PATH=%{buildroot}%{_libdir} %{buildroot}/%{_bindir}/node-%{nodejs_pkg_major} -e "require('assert').equal(process.versions.v8.replace(/-node\.\d+$/, ''), '%{v8_version}')"
|
||||
|
||||
59
test-runner.sh
Executable file
59
test-runner.sh
Executable file
@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
|
||||
NODE_BIN="$1"
|
||||
PARENT_TEST_FOLDER="$2"
|
||||
TEST_LIST_FILE="$3"
|
||||
|
||||
# At most 10 min per test
|
||||
TIMEOUT_DURATION=600
|
||||
# Exit code
|
||||
FINAL_RESULT=0
|
||||
ARCH=$(uname -m)
|
||||
|
||||
echo "Started test run:"
|
||||
# Run the list of test
|
||||
while IFS= read -r test_line; do
|
||||
# ignore commented lines
|
||||
if [[ "$test_line" =~ ^# ]]; then
|
||||
continue
|
||||
fi
|
||||
# If test has specified ARCH which it should be skipped
|
||||
# Extract it
|
||||
TEST_PATH=$(echo "$test_line" | awk '{print $1}')
|
||||
IGNORE_ARCHES=$(echo "$test_line" |\
|
||||
awk '{for (i=2; i<=NF; i++) printf "%s ", $i; print ""}')
|
||||
|
||||
# Skip test for specified ARCH
|
||||
for ARCH_IGNORE in $IGNORE_ARCHES; do
|
||||
if [[ "$ARCH_IGNORE" == "$ARCH" ]]; then
|
||||
continue 2
|
||||
fi
|
||||
done
|
||||
|
||||
# Construct test path
|
||||
TEST_SCRIPT="$PARENT_TEST_FOLDER/$TEST_PATH"
|
||||
|
||||
if [ ! -f "$TEST_SCRIPT" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
TEST_OUTPUT=$(timeout "$TIMEOUT_DURATION" "$NODE_BIN" "$TEST_SCRIPT" 2>&1)
|
||||
TEST_RESULT=$?
|
||||
|
||||
# Handle test result
|
||||
if [ $TEST_RESULT -ne 0 ]; then
|
||||
FINAL_RESULT=1
|
||||
if [ $TEST_RESULT -eq 124 ]; then
|
||||
echo "Test timed out: $TEST_SCRIPT"
|
||||
else
|
||||
echo "Test failed: $TEST_SCRIPT"
|
||||
fi
|
||||
echo "Test failure message:"
|
||||
echo "$TEST_OUTPUT"
|
||||
fi
|
||||
done < "$TEST_LIST_FILE"
|
||||
|
||||
if [ $FINAL_RESULT -eq 0 ]; then
|
||||
echo "All tests succesfully passed."
|
||||
fi
|
||||
exit $FINAL_RESULT
|
||||
3836
test-should-pass.txt
Normal file
3836
test-should-pass.txt
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user