|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Copyright (c) 2025, 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. |
| 9 | +# |
| 10 | +# This code is distributed in the hope that it will be useful, but WITHOUT |
| 11 | +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 13 | +# version 2 for more details (a copy is included in the LICENSE file that |
| 14 | +# accompanied this code). |
| 15 | +# |
| 16 | +# You should have received a copy of the GNU General Public License version |
| 17 | +# 2 along with this work; if not, write to the Free Software Foundation, |
| 18 | +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | +# |
| 20 | +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 21 | +# or visit www.oracle.com if you need additional information or have any |
| 22 | +# questions. |
| 23 | + |
| 24 | +# |
| 25 | +# Filters output produced by running jpackage test(s). |
| 26 | +# |
| 27 | + |
| 28 | +set -eu |
| 29 | +set -o pipefail |
| 30 | + |
| 31 | + |
| 32 | +sed_inplace_option=-i |
| 33 | +sed_version_string=$(sed --version 2>&1 | head -1 || true) |
| 34 | +if [ "${sed_version_string#sed (GNU sed)}" != "$sed_version_string" ]; then |
| 35 | + # GNU sed, the default |
| 36 | + : |
| 37 | +elif [ "${sed_version_string#sed: illegal option}" != "$sed_version_string" ]; then |
| 38 | + # Macos sed |
| 39 | + sed_inplace_option="-i ''" |
| 40 | +else |
| 41 | + echo 'WARNING: Unknown sed variant, assume it is GNU compatible' |
| 42 | +fi |
| 43 | + |
| 44 | + |
| 45 | +filterFile () { |
| 46 | + local expressions=( |
| 47 | + # Strip leading log message timestamp `[19:33:44.713] ` |
| 48 | + -e 's/^\[[0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\}\.[0-9]\{3\}\] //' |
| 49 | + |
| 50 | + # Strip log message timestamps `[19:33:44.713]` |
| 51 | + -e 's/\[[0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\}\.[0-9]\{3\}\]//g' |
| 52 | + |
| 53 | + # Convert variable part of R/O directory path timestamp `#2025-07-24T16:38:13.3589878Z` |
| 54 | + -e 's/#[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}T[0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\}\.[0-9]\{1,\}Z/#<ts>Z/' |
| 55 | + |
| 56 | + # Strip variable part of temporary directory name `jdk.jpackage5060841750457404688` |
| 57 | + -e 's|\([\/]\)jdk\.jpackage[0-9]\{1,\}\b|\1jdk.jpackage|g' |
| 58 | + |
| 59 | + # Convert PID value `[PID: 131561]` |
| 60 | + -e 's/\[PID: [0-9]\{1,\}\]/[PID: <pid>]/' |
| 61 | + |
| 62 | + # Strip a warning message `Windows Defender may prevent jpackage from functioning` |
| 63 | + -e '/Windows Defender may prevent jpackage from functioning/d' |
| 64 | + |
| 65 | + # Convert variable part of test output directory `out-6268` |
| 66 | + -e 's|\bout-[0-9]\{1,\}\b|out-N|g' |
| 67 | + |
| 68 | + # Convert variable part of test summary `[ OK ] IconTest(AppImage, ResourceDirIcon, DefaultIcon).test; checks=39` |
| 69 | + -e 's/^\(.*\bchecks=\)[0-9]\{1,\}\(\r\{0,1\}\)$/\1N\2/' |
| 70 | + |
| 71 | + # Convert variable part of ldd output `libdl.so.2 => /lib64/libdl.so.2 (0x00007fbf63c81000)` |
| 72 | + -e 's/(0x[[:xdigit:]]\{1,\})$/(0xHEX)/' |
| 73 | + |
| 74 | + # Convert variable part of rpmbuild output `Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.CMO6a9` |
| 75 | + -e 's|/rpm-tmp\...*$|/rpm-tmp.V|' |
| 76 | + |
| 77 | + # Convert variable part of stack trace entry `at jdk.jpackage.test.JPackageCommand.execute(JPackageCommand.java:863)` |
| 78 | + -e 's/^\(.*\b\.java:\)[0-9]\{1,\}\()\r\{0,1\}\)$/\1N\2/' |
| 79 | + ) |
| 80 | + |
| 81 | + sed $sed_inplace_option "$1" "${expressions[@]}" |
| 82 | +} |
| 83 | + |
| 84 | + |
| 85 | +for f in "$@"; do |
| 86 | + filterFile "$f" |
| 87 | +done |
0 commit comments