Skip to content

Commit 5d5d88a

Browse files
nizarbenallamagicus
andcommitted
8339570: Add Tidy build support for JDK tests
Co-authored-by: Magnus Ihse Bursie <ihse@openjdk.org> Reviewed-by: erikj, ihse
1 parent 239d84a commit 5d5d88a

File tree

6 files changed

+132
-5
lines changed

6 files changed

+132
-5
lines changed

make/RunTests.gmk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,11 @@ define SetupRunJtregTestBody
739739
# Only the problem list for the current test root should be used.
740740
$1_JTREG_PROBLEM_LIST := $$(filter $$($1_TEST_ROOT)%, $$($1_JTREG_PROBLEM_LIST))
741741

742+
# Pass along the path to the tidy html checker
743+
ifneq ($$(TIDY), )
744+
$1_JTREG_BASIC_OPTIONS += -Dtidy=$$(TIDY)
745+
endif
746+
742747
ifneq ($(TEST_JOBS), 0)
743748
$$(eval $$(call SetJtregValue,$1,JTREG_JOBS,$$(TEST_JOBS)))
744749
else

make/autoconf/configure.ac

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -202,6 +202,7 @@ FLAGS_POST_TOOLCHAIN
202202
LIB_TESTS_SETUP_JTREG
203203
LIB_TESTS_SETUP_JMH
204204
LIB_TESTS_SETUP_JIB
205+
LIB_TESTS_SETUP_TIDY
205206

206207
# Now we can test some aspects on the target using configure macros.
207208
PLATFORM_SETUP_OPENJDK_TARGET_BITS

make/autoconf/lib-tests.m4

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,32 @@ AC_DEFUN_ONCE([LIB_TESTS_SETUP_JIB],
308308
AC_SUBST(JIB_HOME)
309309
])
310310

311+
# Setup the tidy html checker
312+
AC_DEFUN_ONCE([LIB_TESTS_SETUP_TIDY],
313+
[
314+
UTIL_LOOKUP_PROGS(TIDY, tidy)
315+
316+
if test "x$TIDY" != x; then
317+
AC_MSG_CHECKING([if tidy is working properly])
318+
tidy_output=`$TIDY --version 2>&1`
319+
if ! $ECHO "$tidy_output" | $GREP -q "HTML Tidy" 2>&1 > /dev/null; then
320+
AC_MSG_RESULT([no])
321+
AC_MSG_NOTICE([$TIDY is not a valid tidy executable and will be ignored. Output from --version: $tidy_output])
322+
TIDY=
323+
elif ! $ECHO "$tidy_output" | $GREP -q "version" 2>&1 > /dev/null; then
324+
AC_MSG_RESULT([no])
325+
AC_MSG_NOTICE([$TIDY is missing a proper version number and will be ignored. Output from --version: $tidy_output])
326+
TIDY=
327+
else
328+
AC_MSG_RESULT([yes])
329+
AC_MSG_CHECKING([for tidy version])
330+
tidy_version=`$ECHO $tidy_output | $SED -e 's/.*version //g'`
331+
AC_MSG_RESULT([$tidy_version])
332+
fi
333+
fi
334+
AC_SUBST(TIDY)
335+
])
336+
311337
################################################################################
312338
#
313339
# Check if building of the jtreg failure handler should be enabled.

make/autoconf/spec.gmk.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,7 @@ MKDIR := @MKDIR@
743743
MV := @MV@
744744
NICE := @NICE@
745745
PANDOC := @PANDOC@
746+
TIDY := @TIDY@
746747
PATCH := @PATCH@
747748
PRINTF := @PRINTF@
748749
READLINK := @READLINK@

make/conf/jib-profiles.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ var getJibProfilesProfiles = function (input, common, data) {
415415
"linux-x64": {
416416
target_os: "linux",
417417
target_cpu: "x64",
418-
dependencies: ["devkit", "gtest", "build_devkit", "graphviz", "pandoc"],
418+
dependencies: ["devkit", "gtest", "build_devkit", "graphviz", "pandoc", "tidy"],
419419
configure_args: concat(
420420
(input.build_cpu == "x64" ? common.configure_args_64bit
421421
: "--openjdk-target=x86_64-linux-gnu"),
@@ -441,7 +441,7 @@ var getJibProfilesProfiles = function (input, common, data) {
441441
"macosx-x64": {
442442
target_os: "macosx",
443443
target_cpu: "x64",
444-
dependencies: ["devkit", "gtest", "graphviz", "pandoc"],
444+
dependencies: ["devkit", "gtest", "graphviz", "pandoc", "tidy"],
445445
configure_args: concat(common.configure_args_64bit, "--with-zlib=system",
446446
"--with-macosx-version-max=11.00.00",
447447
"--enable-compatible-cds-alignment",
@@ -453,7 +453,7 @@ var getJibProfilesProfiles = function (input, common, data) {
453453
"macosx-aarch64": {
454454
target_os: "macosx",
455455
target_cpu: "aarch64",
456-
dependencies: ["devkit", "gtest", "graphviz", "pandoc"],
456+
dependencies: ["devkit", "gtest", "graphviz", "pandoc", "tidy"],
457457
configure_args: concat(common.configure_args_64bit,
458458
"--with-macosx-version-max=11.00.00"),
459459
},
@@ -486,7 +486,7 @@ var getJibProfilesProfiles = function (input, common, data) {
486486
"linux-aarch64": {
487487
target_os: "linux",
488488
target_cpu: "aarch64",
489-
dependencies: ["devkit", "gtest", "build_devkit", "graphviz", "pandoc"],
489+
dependencies: ["devkit", "gtest", "build_devkit", "graphviz", "pandoc", "tidy"],
490490
configure_args: [
491491
"--with-zlib=system",
492492
"--disable-dtrace",
@@ -1275,6 +1275,14 @@ var getJibProfilesDependencies = function (input, common) {
12751275
ext: "tar.gz",
12761276
revision: "3.4.2+1.0"
12771277
},
1278+
tidy: {
1279+
organization: common.organization,
1280+
ext: "tar.gz",
1281+
revision: "5.9.20+1",
1282+
environment_path: input.get("tidy", "home_path") + "/bin/tidy",
1283+
configure_args: "TIDY=" + input.get("tidy", "home_path") + "/bin/tidy",
1284+
module: "tidy-html-" + (input.target_os === "macosx" ? input.target_os : input.target_platform),
1285+
},
12781286
};
12791287

12801288
return dependencies;

make/devkit/createTidyBundle.sh

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
4+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5+
#
6+
# This code is free software; you can redistribute it and/or modify it
7+
# under the terms of the GNU General Public License version 2 only, as
8+
# published by the Free Software Foundation. Oracle designates this
9+
# particular file as subject to the "Classpath" exception as provided
10+
# by Oracle in the LICENSE file that accompanied this code.
11+
#
12+
# This code is distributed in the hope that it will be useful, but WITHOUT
13+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15+
# version 2 for more details (a copy is included in the LICENSE file that
16+
# accompanied this code).
17+
#
18+
# You should have received a copy of the GNU General Public License version
19+
# 2 along with this work; if not, write to the Free Software Foundation,
20+
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21+
#
22+
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23+
# or visit www.oracle.com if you need additional information or have any
24+
# questions.
25+
#
26+
27+
# Creates a tidy bundle in the build directory. A dependency that can be
28+
# used to validate and correct HTML.
29+
30+
# wget, cmake and gcc are required to build tidy.
31+
32+
set -e
33+
34+
GITHUB_USER="htacg"
35+
REPO_NAME="tidy-html5"
36+
COMMIT_HASH="d08ddc2860aa95ba8e301343a30837f157977cba"
37+
SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)"
38+
INSTALL_PREFIX="${SCRIPT_DIR}/../../build/tidy/tidy/"
39+
BUILD_DIR="build/cmake"
40+
41+
OS_NAME=$(uname -s)
42+
OS_ARCH=$(uname -m)
43+
44+
DOWNLOAD_URL="https://github.com/$GITHUB_USER/$REPO_NAME/archive/$COMMIT_HASH.tar.gz"
45+
OUTPUT_FILE="$REPO_NAME-$COMMIT_HASH.tar.gz"
46+
47+
wget "$DOWNLOAD_URL" -O "$OUTPUT_FILE"
48+
49+
tar -xzf "$OUTPUT_FILE"
50+
rm -rf "$OUTPUT_FILE"
51+
52+
SRC_DIR="$REPO_NAME-$COMMIT_HASH"
53+
54+
mkdir -p "$SRC_DIR/$BUILD_DIR"
55+
cd "$SRC_DIR/$BUILD_DIR"
56+
57+
case $OS_NAME in
58+
Linux|Darwin)
59+
echo "Building Tidy HTML5 for Unix-like platform ($OS_NAME)..."
60+
61+
CMAKE_ARCH_OPTIONS=""
62+
if [ "$OS_NAME" == "Darwin" ]; then
63+
if [[ "$OS_ARCH" == "arm64" || "$OS_ARCH" == "x86_64" ]]; then
64+
CMAKE_ARCH_OPTIONS="-DCMAKE_OSX_ARCHITECTURES=x86_64;arm64"
65+
fi
66+
fi
67+
68+
cmake ../.. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" $CMAKE_ARCH_OPTIONS
69+
make install
70+
;;
71+
72+
*)
73+
echo "Unsupported OS: $OS_NAME"
74+
exit 1
75+
;;
76+
esac
77+
78+
cd "$SCRIPT_DIR"
79+
rm -rf "$SRC_DIR"
80+
81+
cd "$INSTALL_PREFIX.."
82+
PACKAGED_FILE="tidy-html5.tar.gz"
83+
84+
tar -czvf "$PACKAGED_FILE" -C "$INSTALL_PREFIX.." tidy
85+
86+
echo "Created $INSTALL_PREFIX..$PACKAGED_FILE"

0 commit comments

Comments
 (0)