8339570: Add Tidy build support for JDK tests

Co-authored-by: Magnus Ihse Bursie <ihse@openjdk.org>
Reviewed-by: erikj, ihse
This commit is contained in:
Nizar Benalla 2024-10-21 10:13:18 +00:00
parent 239d84a82a
commit 5d5d88ab9a
6 changed files with 132 additions and 5 deletions

View File

@ -739,6 +739,11 @@ define SetupRunJtregTestBody
# Only the problem list for the current test root should be used.
$1_JTREG_PROBLEM_LIST := $$(filter $$($1_TEST_ROOT)%, $$($1_JTREG_PROBLEM_LIST))
# Pass along the path to the tidy html checker
ifneq ($$(TIDY), )
$1_JTREG_BASIC_OPTIONS += -Dtidy=$$(TIDY)
endif
ifneq ($(TEST_JOBS), 0)
$$(eval $$(call SetJtregValue,$1,JTREG_JOBS,$$(TEST_JOBS)))
else

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -202,6 +202,7 @@ FLAGS_POST_TOOLCHAIN
LIB_TESTS_SETUP_JTREG
LIB_TESTS_SETUP_JMH
LIB_TESTS_SETUP_JIB
LIB_TESTS_SETUP_TIDY
# Now we can test some aspects on the target using configure macros.
PLATFORM_SETUP_OPENJDK_TARGET_BITS

View File

@ -308,6 +308,32 @@ AC_DEFUN_ONCE([LIB_TESTS_SETUP_JIB],
AC_SUBST(JIB_HOME)
])
# Setup the tidy html checker
AC_DEFUN_ONCE([LIB_TESTS_SETUP_TIDY],
[
UTIL_LOOKUP_PROGS(TIDY, tidy)
if test "x$TIDY" != x; then
AC_MSG_CHECKING([if tidy is working properly])
tidy_output=`$TIDY --version 2>&1`
if ! $ECHO "$tidy_output" | $GREP -q "HTML Tidy" 2>&1 > /dev/null; then
AC_MSG_RESULT([no])
AC_MSG_NOTICE([$TIDY is not a valid tidy executable and will be ignored. Output from --version: $tidy_output])
TIDY=
elif ! $ECHO "$tidy_output" | $GREP -q "version" 2>&1 > /dev/null; then
AC_MSG_RESULT([no])
AC_MSG_NOTICE([$TIDY is missing a proper version number and will be ignored. Output from --version: $tidy_output])
TIDY=
else
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([for tidy version])
tidy_version=`$ECHO $tidy_output | $SED -e 's/.*version //g'`
AC_MSG_RESULT([$tidy_version])
fi
fi
AC_SUBST(TIDY)
])
################################################################################
#
# Check if building of the jtreg failure handler should be enabled.

View File

@ -743,6 +743,7 @@ MKDIR := @MKDIR@
MV := @MV@
NICE := @NICE@
PANDOC := @PANDOC@
TIDY := @TIDY@
PATCH := @PATCH@
PRINTF := @PRINTF@
READLINK := @READLINK@

View File

@ -415,7 +415,7 @@ var getJibProfilesProfiles = function (input, common, data) {
"linux-x64": {
target_os: "linux",
target_cpu: "x64",
dependencies: ["devkit", "gtest", "build_devkit", "graphviz", "pandoc"],
dependencies: ["devkit", "gtest", "build_devkit", "graphviz", "pandoc", "tidy"],
configure_args: concat(
(input.build_cpu == "x64" ? common.configure_args_64bit
: "--openjdk-target=x86_64-linux-gnu"),
@ -441,7 +441,7 @@ var getJibProfilesProfiles = function (input, common, data) {
"macosx-x64": {
target_os: "macosx",
target_cpu: "x64",
dependencies: ["devkit", "gtest", "graphviz", "pandoc"],
dependencies: ["devkit", "gtest", "graphviz", "pandoc", "tidy"],
configure_args: concat(common.configure_args_64bit, "--with-zlib=system",
"--with-macosx-version-max=11.00.00",
"--enable-compatible-cds-alignment",
@ -453,7 +453,7 @@ var getJibProfilesProfiles = function (input, common, data) {
"macosx-aarch64": {
target_os: "macosx",
target_cpu: "aarch64",
dependencies: ["devkit", "gtest", "graphviz", "pandoc"],
dependencies: ["devkit", "gtest", "graphviz", "pandoc", "tidy"],
configure_args: concat(common.configure_args_64bit,
"--with-macosx-version-max=11.00.00"),
},
@ -486,7 +486,7 @@ var getJibProfilesProfiles = function (input, common, data) {
"linux-aarch64": {
target_os: "linux",
target_cpu: "aarch64",
dependencies: ["devkit", "gtest", "build_devkit", "graphviz", "pandoc"],
dependencies: ["devkit", "gtest", "build_devkit", "graphviz", "pandoc", "tidy"],
configure_args: [
"--with-zlib=system",
"--disable-dtrace",
@ -1275,6 +1275,14 @@ var getJibProfilesDependencies = function (input, common) {
ext: "tar.gz",
revision: "3.4.2+1.0"
},
tidy: {
organization: common.organization,
ext: "tar.gz",
revision: "5.9.20+1",
environment_path: input.get("tidy", "home_path") + "/bin/tidy",
configure_args: "TIDY=" + input.get("tidy", "home_path") + "/bin/tidy",
module: "tidy-html-" + (input.target_os === "macosx" ? input.target_os : input.target_platform),
},
};
return dependencies;

View File

@ -0,0 +1,86 @@
#!/bin/bash
#
# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# Creates a tidy bundle in the build directory. A dependency that can be
# used to validate and correct HTML.
# wget, cmake and gcc are required to build tidy.
set -e
GITHUB_USER="htacg"
REPO_NAME="tidy-html5"
COMMIT_HASH="d08ddc2860aa95ba8e301343a30837f157977cba"
SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)"
INSTALL_PREFIX="${SCRIPT_DIR}/../../build/tidy/tidy/"
BUILD_DIR="build/cmake"
OS_NAME=$(uname -s)
OS_ARCH=$(uname -m)
DOWNLOAD_URL="https://github.com/$GITHUB_USER/$REPO_NAME/archive/$COMMIT_HASH.tar.gz"
OUTPUT_FILE="$REPO_NAME-$COMMIT_HASH.tar.gz"
wget "$DOWNLOAD_URL" -O "$OUTPUT_FILE"
tar -xzf "$OUTPUT_FILE"
rm -rf "$OUTPUT_FILE"
SRC_DIR="$REPO_NAME-$COMMIT_HASH"
mkdir -p "$SRC_DIR/$BUILD_DIR"
cd "$SRC_DIR/$BUILD_DIR"
case $OS_NAME in
Linux|Darwin)
echo "Building Tidy HTML5 for Unix-like platform ($OS_NAME)..."
CMAKE_ARCH_OPTIONS=""
if [ "$OS_NAME" == "Darwin" ]; then
if [[ "$OS_ARCH" == "arm64" || "$OS_ARCH" == "x86_64" ]]; then
CMAKE_ARCH_OPTIONS="-DCMAKE_OSX_ARCHITECTURES=x86_64;arm64"
fi
fi
cmake ../.. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" $CMAKE_ARCH_OPTIONS
make install
;;
*)
echo "Unsupported OS: $OS_NAME"
exit 1
;;
esac
cd "$SCRIPT_DIR"
rm -rf "$SRC_DIR"
cd "$INSTALL_PREFIX.."
PACKAGED_FILE="tidy-html5.tar.gz"
tar -czvf "$PACKAGED_FILE" -C "$INSTALL_PREFIX.." tidy
echo "Created $INSTALL_PREFIX..$PACKAGED_FILE"