mirror of https://gitee.com/openkylin/jtreg6.git
Import Upstream version 6.1+2
This commit is contained in:
commit
51326c6126
|
@ -0,0 +1,39 @@
|
||||||
|
name: Build and Test JTReg
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches-ignore:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
linux-x64:
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout the source
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
path: jtreg
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: build
|
||||||
|
working-directory: jtreg
|
||||||
|
shell: bash
|
||||||
|
run: bash make/build.sh --jdk ${JAVA_HOME_8_X64}
|
||||||
|
|
||||||
|
- name: upload artifact
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: jtreg
|
||||||
|
path: jtreg/build/images/jtreg
|
||||||
|
|
||||||
|
- name: test
|
||||||
|
working-directory: jtreg
|
||||||
|
shell: bash
|
||||||
|
run:
|
||||||
|
MAKE_ARGS=test
|
||||||
|
HEADLESS=1
|
||||||
|
JDK8HOME=${JAVA_HOME_8_X64}
|
||||||
|
bash make/build.sh --jdk ${JAVA_HOME_8_X64} --skip-download
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
/build/
|
||||||
|
/webrev
|
||||||
|
.DS_Store
|
||||||
|
/.idea/
|
|
@ -0,0 +1,5 @@
|
||||||
|
^(build|dist)/
|
||||||
|
nbproject/private/
|
||||||
|
plugins/idea/.idea/
|
||||||
|
plugins/idea/build/
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
9f51ef22f00a3d5b681472cacf3ce15868073103 jtreg4.1-b01
|
||||||
|
2cf779985e18ba2f79aaec88f543be9efecf352f jtreg4.1-b02
|
||||||
|
bd7a3ed1210fa61f92f066c65d5e589e2aa26813 jtreg4.1-b03
|
||||||
|
cbc1f04a52ea2488e8dc7715fc59a5a122be9851 jtreg4.1-b04
|
||||||
|
46b8c02be3b356c7f953dbfa18246b357b5e7101 jtreg4.1-b05
|
||||||
|
d47a6e238c3e0f6d8ca1a6640c182be14c45eab2 jtreg-4.1-b06
|
||||||
|
d47a6e238c3e0f6d8ca1a6640c182be14c45eab2 jtreg4.1-b06
|
||||||
|
8ab579624a503e1df21841070ae5f869c301de8f jtreg4.1-b07
|
||||||
|
d47a6e238c3e0f6d8ca1a6640c182be14c45eab2 jtreg-4.1-b06
|
||||||
|
0000000000000000000000000000000000000000 jtreg-4.1-b06
|
||||||
|
e08a5e0b79ba57743222bbea19c0bdb142968769 jtreg4.1-b08
|
||||||
|
c54815dea64cf7b011f8473c18d54a86b9a9d5af jtreg4.1-b09
|
||||||
|
8c3179c3ebdab7df35b8e9907bd8ad8bc5a9f9f8 jtreg4.1-b10
|
||||||
|
04f40c388713f11c1cfb2094556d4b024b9ab939 jtreg4.1-b11
|
||||||
|
79705dae19e74b0693cda9ece8eaf0984159ab97 jtreg4.1-b12
|
||||||
|
5e994d1f9840ba39b82977a56e02c4f702a1dcbd jtreg4.1-b13
|
||||||
|
1159c9f96a4470dec79e6fa71b4f1a4895c4b20f jtreg4.2-b01
|
||||||
|
dbccea90c34dacf7e0824d5e3d3e9e1e930a103a jtreg4.2-b02
|
||||||
|
45590e2d6af12da44cc160764a9b552516be8440 jtreg4.2-b03
|
||||||
|
585f794e105997ab44109d70dbaa1c072b03afcc jtreg4.2-b04
|
||||||
|
4b0cd55e7741825de6ea79e9d4338d2972460678 jtreg4.2-b05
|
||||||
|
2d96b4cf02660b1580542379d77492f68d3ca73b jtreg4.2-b06
|
||||||
|
26d8a4a47674c4ca304b9e290dccca1dd1c7224f jtreg4.2-b07
|
||||||
|
cce0ac75e87864ed365a420fb836a4430421ab0f jtreg4.2-b08
|
||||||
|
684f12eef4a8c2f42afe2abe3d79eead72efcc5f jtreg4.2-b09
|
||||||
|
746c6d1328721541d3b16154c25a0179fbf53f7c jtreg4.2-b10
|
||||||
|
a13ec77e7adcc4c9ed434e664abc350abaacc045 jtreg4.2-b11
|
||||||
|
652902f7fb0ed0b4f307d61a799caf50a6e609be jtreg4.2-b12
|
||||||
|
7a38f21e077821a5015792e85b3793c90c81b866 jtreg4.2-b13
|
||||||
|
ec37d2900cd42987270f98423a60eb6297bdc37b jtreg4.2-b14
|
||||||
|
d5a9216fad5ca01002e18526be2c31cafb43e178 jtreg4.2-b15
|
||||||
|
deee95d5d8ff6406b77c0d5b9297736eb7c98c6d jtreg4.2-b16
|
||||||
|
03c4dff80b0f55865c6e5fe0aa8ea94d0ca1a2ac jtreg5.0-b01
|
||||||
|
95aa601b8100c6c56a14d35cfe493372214b1d94 jtreg5.1-b01
|
|
@ -0,0 +1,31 @@
|
||||||
|
[general]
|
||||||
|
project=code-tools
|
||||||
|
comments=lax
|
||||||
|
jbs=CODETOOLS
|
||||||
|
|
||||||
|
[checks]
|
||||||
|
error=author,committer,reviewers,merge,issues,executable,symlink,message,whitespace
|
||||||
|
|
||||||
|
[repository]
|
||||||
|
tags=jtreg(?:4\.1-b[0-9]{2}|5\.[01]-b[0-9]{2}|6|-[6789](?:\.[0-9]+)?+[0-9]+)
|
||||||
|
branches=
|
||||||
|
|
||||||
|
[census]
|
||||||
|
version=0
|
||||||
|
domain=openjdk.org
|
||||||
|
|
||||||
|
[checks "whitespace"]
|
||||||
|
files=.*\.java|.*\.m|.*\.mm|.*\.gmk|.*\.m4|.*\.ac|Makefile
|
||||||
|
ignore-tabs=.*\.gmk|Makefile
|
||||||
|
|
||||||
|
[checks "merge"]
|
||||||
|
message=Merge
|
||||||
|
|
||||||
|
[checks "reviewers"]
|
||||||
|
ignore=duke
|
||||||
|
|
||||||
|
[checks "committer"]
|
||||||
|
role=committer
|
||||||
|
|
||||||
|
[checks "issues"]
|
||||||
|
pattern=^(79[0-9]{5}): (\S.*)$
|
|
@ -0,0 +1,8 @@
|
||||||
|
# Contributing to JTReg
|
||||||
|
|
||||||
|
JTReg is part of the OpenJDK [CodeTools] Project.
|
||||||
|
|
||||||
|
Please see <https://openjdk.java.net/contribute/> for how to contribute.
|
||||||
|
|
||||||
|
|
||||||
|
[CodeTools]: https://openjdk.java.net/projects/code-tools
|
|
@ -0,0 +1,18 @@
|
||||||
|
The following people have contributed to the development of jtreg.
|
||||||
|
|
||||||
|
Original Author:
|
||||||
|
Iris Clark
|
||||||
|
|
||||||
|
Tag Specification:
|
||||||
|
Mark Reinhold
|
||||||
|
|
||||||
|
Currently Maintained By:
|
||||||
|
Jonathan Gibbons
|
||||||
|
|
||||||
|
Other Contributors:
|
||||||
|
Brian Kurotsuchi
|
||||||
|
Dawn Phillips
|
||||||
|
Jessica Mauvais
|
||||||
|
Maurizio Cimadamore
|
||||||
|
Kumar Srinivasan
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
Copyright (c) 1996, 2012, 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.
|
||||||
|
|
||||||
|
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.
|
|
@ -0,0 +1,347 @@
|
||||||
|
The GNU General Public License (GPL)
|
||||||
|
|
||||||
|
Version 2, June 1991
|
||||||
|
|
||||||
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||||
|
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies of this license
|
||||||
|
document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your freedom to share
|
||||||
|
and change it. By contrast, the GNU General Public License is intended to
|
||||||
|
guarantee your freedom to share and change free software--to make sure the
|
||||||
|
software is free for all its users. This General Public License applies to
|
||||||
|
most of the Free Software Foundation's software and to any other program whose
|
||||||
|
authors commit to using it. (Some other Free Software Foundation software is
|
||||||
|
covered by the GNU Library General Public License instead.) You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not price. Our
|
||||||
|
General Public Licenses are designed to make sure that you have the freedom to
|
||||||
|
distribute copies of free software (and charge for this service if you wish),
|
||||||
|
that you receive source code or can get it if you want it, that you can change
|
||||||
|
the software or use pieces of it in new free programs; and that you know you
|
||||||
|
can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid anyone to deny
|
||||||
|
you these rights or to ask you to surrender the rights. These restrictions
|
||||||
|
translate to certain responsibilities for you if you distribute copies of the
|
||||||
|
software, or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether gratis or for
|
||||||
|
a fee, you must give the recipients all the rights that you have. You must
|
||||||
|
make sure that they, too, receive or can get the source code. And you must
|
||||||
|
show them these terms so they know their rights.
|
||||||
|
|
||||||
|
We protect your rights with two steps: (1) copyright the software, and (2)
|
||||||
|
offer you this license which gives you legal permission to copy, distribute
|
||||||
|
and/or modify the software.
|
||||||
|
|
||||||
|
Also, for each author's protection and ours, we want to make certain that
|
||||||
|
everyone understands that there is no warranty for this free software. If the
|
||||||
|
software is modified by someone else and passed on, we want its recipients to
|
||||||
|
know that what they have is not the original, so that any problems introduced
|
||||||
|
by others will not reflect on the original authors' reputations.
|
||||||
|
|
||||||
|
Finally, any free program is threatened constantly by software patents. We
|
||||||
|
wish to avoid the danger that redistributors of a free program will
|
||||||
|
individually obtain patent licenses, in effect making the program proprietary.
|
||||||
|
To prevent this, we have made it clear that any patent must be licensed for
|
||||||
|
everyone's free use or not licensed at all.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and modification
|
||||||
|
follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License applies to any program or other work which contains a notice
|
||||||
|
placed by the copyright holder saying it may be distributed under the terms of
|
||||||
|
this General Public License. The "Program", below, refers to any such program
|
||||||
|
or work, and a "work based on the Program" means either the Program or any
|
||||||
|
derivative work under copyright law: that is to say, a work containing the
|
||||||
|
Program or a portion of it, either verbatim or with modifications and/or
|
||||||
|
translated into another language. (Hereinafter, translation is included
|
||||||
|
without limitation in the term "modification".) Each licensee is addressed as
|
||||||
|
"you".
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not covered by
|
||||||
|
this License; they are outside its scope. The act of running the Program is
|
||||||
|
not restricted, and the output from the Program is covered only if its contents
|
||||||
|
constitute a work based on the Program (independent of having been made by
|
||||||
|
running the Program). Whether that is true depends on what the Program does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Program's source code as
|
||||||
|
you receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice and
|
||||||
|
disclaimer of warranty; keep intact all the notices that refer to this License
|
||||||
|
and to the absence of any warranty; and give any other recipients of the
|
||||||
|
Program a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy, and you may
|
||||||
|
at your option offer warranty protection in exchange for a fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Program or any portion of it, thus
|
||||||
|
forming a work based on the Program, and copy and distribute such modifications
|
||||||
|
or work under the terms of Section 1 above, provided that you also meet all of
|
||||||
|
these conditions:
|
||||||
|
|
||||||
|
a) You must cause the modified files to carry prominent notices stating
|
||||||
|
that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
b) You must cause any work that you distribute or publish, that in whole or
|
||||||
|
in part contains or is derived from the Program or any part thereof, to be
|
||||||
|
licensed as a whole at no charge to all third parties under the terms of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
c) If the modified program normally reads commands interactively when run,
|
||||||
|
you must cause it, when started running for such interactive use in the
|
||||||
|
most ordinary way, to print or display an announcement including an
|
||||||
|
appropriate copyright notice and a notice that there is no warranty (or
|
||||||
|
else, saying that you provide a warranty) and that users may redistribute
|
||||||
|
the program under these conditions, and telling the user how to view a copy
|
||||||
|
of this License. (Exception: if the Program itself is interactive but does
|
||||||
|
not normally print such an announcement, your work based on the Program is
|
||||||
|
not required to print an announcement.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If identifiable
|
||||||
|
sections of that work are not derived from the Program, and can be reasonably
|
||||||
|
considered independent and separate works in themselves, then this License, and
|
||||||
|
its terms, do not apply to those sections when you distribute them as separate
|
||||||
|
works. But when you distribute the same sections as part of a whole which is a
|
||||||
|
work based on the Program, the distribution of the whole must be on the terms
|
||||||
|
of this License, whose permissions for other licensees extend to the entire
|
||||||
|
whole, and thus to each and every part regardless of who wrote it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest your
|
||||||
|
rights to work written entirely by you; rather, the intent is to exercise the
|
||||||
|
right to control the distribution of derivative or collective works based on
|
||||||
|
the Program.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Program with the
|
||||||
|
Program (or with a work based on the Program) on a volume of a storage or
|
||||||
|
distribution medium does not bring the other work under the scope of this
|
||||||
|
License.
|
||||||
|
|
||||||
|
3. You may copy and distribute the Program (or a work based on it, under
|
||||||
|
Section 2) in object code or executable form under the terms of Sections 1 and
|
||||||
|
2 above provided that you also do one of the following:
|
||||||
|
|
||||||
|
a) Accompany it with the complete corresponding machine-readable source
|
||||||
|
code, which must be distributed under the terms of Sections 1 and 2 above
|
||||||
|
on a medium customarily used for software interchange; or,
|
||||||
|
|
||||||
|
b) Accompany it with a written offer, valid for at least three years, to
|
||||||
|
give any third party, for a charge no more than your cost of physically
|
||||||
|
performing source distribution, a complete machine-readable copy of the
|
||||||
|
corresponding source code, to be distributed under the terms of Sections 1
|
||||||
|
and 2 above on a medium customarily used for software interchange; or,
|
||||||
|
|
||||||
|
c) Accompany it with the information you received as to the offer to
|
||||||
|
distribute corresponding source code. (This alternative is allowed only
|
||||||
|
for noncommercial distribution and only if you received the program in
|
||||||
|
object code or executable form with such an offer, in accord with
|
||||||
|
Subsection b above.)
|
||||||
|
|
||||||
|
The source code for a work means the preferred form of the work for making
|
||||||
|
modifications to it. For an executable work, complete source code means all
|
||||||
|
the source code for all modules it contains, plus any associated interface
|
||||||
|
definition files, plus the scripts used to control compilation and installation
|
||||||
|
of the executable. However, as a special exception, the source code
|
||||||
|
distributed need not include anything that is normally distributed (in either
|
||||||
|
source or binary form) with the major components (compiler, kernel, and so on)
|
||||||
|
of the operating system on which the executable runs, unless that component
|
||||||
|
itself accompanies the executable.
|
||||||
|
|
||||||
|
If distribution of executable or object code is made by offering access to copy
|
||||||
|
from a designated place, then offering equivalent access to copy the source
|
||||||
|
code from the same place counts as distribution of the source code, even though
|
||||||
|
third parties are not compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
4. You may not copy, modify, sublicense, or distribute the Program except as
|
||||||
|
expressly provided under this License. Any attempt otherwise to copy, modify,
|
||||||
|
sublicense or distribute the Program is void, and will automatically terminate
|
||||||
|
your rights under this License. However, parties who have received copies, or
|
||||||
|
rights, from you under this License will not have their licenses terminated so
|
||||||
|
long as such parties remain in full compliance.
|
||||||
|
|
||||||
|
5. You are not required to accept this License, since you have not signed it.
|
||||||
|
However, nothing else grants you permission to modify or distribute the Program
|
||||||
|
or its derivative works. These actions are prohibited by law if you do not
|
||||||
|
accept this License. Therefore, by modifying or distributing the Program (or
|
||||||
|
any work based on the Program), you indicate your acceptance of this License to
|
||||||
|
do so, and all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Program or works based on it.
|
||||||
|
|
||||||
|
6. Each time you redistribute the Program (or any work based on the Program),
|
||||||
|
the recipient automatically receives a license from the original licensor to
|
||||||
|
copy, distribute or modify the Program subject to these terms and conditions.
|
||||||
|
You may not impose any further restrictions on the recipients' exercise of the
|
||||||
|
rights granted herein. You are not responsible for enforcing compliance by
|
||||||
|
third parties to this License.
|
||||||
|
|
||||||
|
7. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues), conditions
|
||||||
|
are imposed on you (whether by court order, agreement or otherwise) that
|
||||||
|
contradict the conditions of this License, they do not excuse you from the
|
||||||
|
conditions of this License. If you cannot distribute so as to satisfy
|
||||||
|
simultaneously your obligations under this License and any other pertinent
|
||||||
|
obligations, then as a consequence you may not distribute the Program at all.
|
||||||
|
For example, if a patent license would not permit royalty-free redistribution
|
||||||
|
of the Program by all those who receive copies directly or indirectly through
|
||||||
|
you, then the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Program.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under any
|
||||||
|
particular circumstance, the balance of the section is intended to apply and
|
||||||
|
the section as a whole is intended to apply in other circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any patents or
|
||||||
|
other property right claims or to contest validity of any such claims; this
|
||||||
|
section has the sole purpose of protecting the integrity of the free software
|
||||||
|
distribution system, which is implemented by public license practices. Many
|
||||||
|
people have made generous contributions to the wide range of software
|
||||||
|
distributed through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing to
|
||||||
|
distribute software through any other system and a licensee cannot impose that
|
||||||
|
choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to be a
|
||||||
|
consequence of the rest of this License.
|
||||||
|
|
||||||
|
8. If the distribution and/or use of the Program is restricted in certain
|
||||||
|
countries either by patents or by copyrighted interfaces, the original
|
||||||
|
copyright holder who places the Program under this License may add an explicit
|
||||||
|
geographical distribution limitation excluding those countries, so that
|
||||||
|
distribution is permitted only in or among countries not thus excluded. In
|
||||||
|
such case, this License incorporates the limitation as if written in the body
|
||||||
|
of this License.
|
||||||
|
|
||||||
|
9. The Free Software Foundation may publish revised and/or new versions of the
|
||||||
|
General Public License from time to time. Such new versions will be similar in
|
||||||
|
spirit to the present version, but may differ in detail to address new problems
|
||||||
|
or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program
|
||||||
|
specifies a version number of this License which applies to it and "any later
|
||||||
|
version", you have the option of following the terms and conditions either of
|
||||||
|
that version or of any later version published by the Free Software Foundation.
|
||||||
|
If the Program does not specify a version number of this License, you may
|
||||||
|
choose any version ever published by the Free Software Foundation.
|
||||||
|
|
||||||
|
10. If you wish to incorporate parts of the Program into other free programs
|
||||||
|
whose distribution conditions are different, write to the author to ask for
|
||||||
|
permission. For software which is copyrighted by the Free Software Foundation,
|
||||||
|
write to the Free Software Foundation; we sometimes make exceptions for this.
|
||||||
|
Our decision will be guided by the two goals of preserving the free status of
|
||||||
|
all derivatives of our free software and of promoting the sharing and reuse of
|
||||||
|
software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
|
||||||
|
THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
|
||||||
|
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE
|
||||||
|
PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
|
||||||
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
||||||
|
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE,
|
||||||
|
YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
|
||||||
|
ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE
|
||||||
|
PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
|
||||||
|
INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
|
||||||
|
BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||||
|
FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER
|
||||||
|
OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest possible
|
||||||
|
use to the public, the best way to achieve this is to make it free software
|
||||||
|
which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest to attach
|
||||||
|
them to the start of each source file to most effectively convey the exclusion
|
||||||
|
of warranty; and each file should have at least the "copyright" line and a
|
||||||
|
pointer to where the full notice is found.
|
||||||
|
|
||||||
|
One line to give the program's name and a brief idea of what it does.
|
||||||
|
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by the Free
|
||||||
|
Software Foundation; either version 2 of the License, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
This program 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 for
|
||||||
|
more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc., 59
|
||||||
|
Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program is interactive, make it output a short notice like this when it
|
||||||
|
starts in an interactive mode:
|
||||||
|
|
||||||
|
Gnomovision version 69, Copyright (C) year name of author Gnomovision comes
|
||||||
|
with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free
|
||||||
|
software, and you are welcome to redistribute it under certain conditions;
|
||||||
|
type 'show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands 'show w' and 'show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, the commands you use may be
|
||||||
|
called something other than 'show w' and 'show c'; they could even be
|
||||||
|
mouse-clicks or menu items--whatever suits your program.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary. Here
|
||||||
|
is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||||
|
'Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||||
|
|
||||||
|
signature of Ty Coon, 1 April 1989
|
||||||
|
|
||||||
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
|
This General Public License does not permit incorporating your program into
|
||||||
|
proprietary programs. If your program is a subroutine library, you may
|
||||||
|
consider it more useful to permit linking proprietary applications with the
|
||||||
|
library. If this is what you want to do, use the GNU Library General Public
|
||||||
|
License instead of this License.
|
||||||
|
|
||||||
|
|
||||||
|
"CLASSPATH" EXCEPTION TO THE GPL
|
||||||
|
|
||||||
|
Certain source files distributed by Sun Microsystems, Inc. are subject to
|
||||||
|
the following clarification and special exception to the GPL, but only where
|
||||||
|
Sun has expressly included in the particular source file's header the words
|
||||||
|
"Sun designates this particular file as subject to the "Classpath" exception
|
||||||
|
as provided by Sun in the LICENSE file that accompanied this code."
|
||||||
|
|
||||||
|
Linking this library statically or dynamically with other modules is making
|
||||||
|
a combined work based on this library. Thus, the terms and conditions of
|
||||||
|
the GNU General Public License cover the whole combination.
|
||||||
|
|
||||||
|
As a special exception, the copyright holders of this library give you
|
||||||
|
permission to link this library with independent modules to produce an
|
||||||
|
executable, regardless of the license terms of these independent modules,
|
||||||
|
and to copy and distribute the resulting executable under terms of your
|
||||||
|
choice, provided that you also meet, for each linked independent module,
|
||||||
|
the terms and conditions of the license of that module. An independent
|
||||||
|
module is a module which is not derived from or based on this library. If
|
||||||
|
you modify this library, you may extend this exception to your version of
|
||||||
|
the library, but you are not obligated to do so. If you do not wish to do
|
||||||
|
so, delete this exception statement from your version.
|
|
@ -0,0 +1,195 @@
|
||||||
|
# Building The Regression Test Harness for the OpenJDK platform: jtreg
|
||||||
|
|
||||||
|
(This information is also available at <http://openjdk.java.net/jtreg/build.html>)
|
||||||
|
|
||||||
|
jtreg depends on a number of external components:
|
||||||
|
JT Harness, TestNG, JUnit, AsmTools, Ant, and JCov.
|
||||||
|
|
||||||
|
The fundamental way to build jtreg is with GNU make, specifying where to find
|
||||||
|
those external components, but a script is also available that will download
|
||||||
|
appropriate copies of those components before building jtreg.
|
||||||
|
|
||||||
|
## Building jtreg with the build.sh script
|
||||||
|
|
||||||
|
This is the recommended way to build jtreg, for those that want a simple,
|
||||||
|
basic way to build jtreg.
|
||||||
|
|
||||||
|
*Note:* The _build.sh_ script supersedes the earlier _build-all.sh_ script.
|
||||||
|
|
||||||
|
The script is intended to be run in a Unix-like shell, such as `bash` on Linux or
|
||||||
|
Mac OS X, or with Cygwin or WSL on Windows. At a minimum, you must either set
|
||||||
|
the `JAVA_HOME` environment variable or specify the location of the JDK to be
|
||||||
|
used to build jtreg with the `--jdk` command-line option. It must be JDK 8 or later.
|
||||||
|
|
||||||
|
% cd jtreg-root-directory
|
||||||
|
% sh make/build.sh --jdk JDK-directory
|
||||||
|
|
||||||
|
If your shell is not compatible with `bash`, you may need to invoke `bash` explicitly:
|
||||||
|
|
||||||
|
% bash make/build.sh --jdk JDK-directory
|
||||||
|
|
||||||
|
The script will create a build sub-directory, download and build dependencies,
|
||||||
|
and finally build jtreg itself. The resulting image will be in
|
||||||
|
_build/images/jtreg_.
|
||||||
|
|
||||||
|
If you have access to the public Internet, no environment variables need to be
|
||||||
|
specified to get a standard build of jtreg. However, you can set environment
|
||||||
|
variables used to define the location of dependencies to be downloaded.
|
||||||
|
These are documented in _make/build.sh_ and normally specified in
|
||||||
|
_make/build-support/version-numbers_ and _make/build-support/*/version-numbers_.
|
||||||
|
|
||||||
|
## Building jtreg with GNU Make
|
||||||
|
|
||||||
|
The Makefile is in _make/Makefile_, and creates deliverables in the _build/_
|
||||||
|
directory, similar to OpenJDK. By default, the build file just builds an image
|
||||||
|
for jtreg. You can build jtreg from a Unix-like command shell with the following
|
||||||
|
commands:
|
||||||
|
|
||||||
|
% cd <jtreg-root-directory>
|
||||||
|
% make -C make
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
jtreg has a number of build dependencies. These can be set with values on the
|
||||||
|
make command line or with values in _make/Defs.gmk_. You can also include the
|
||||||
|
appropriate license files in the jtreg image, by setting the appropriate make
|
||||||
|
variables.
|
||||||
|
|
||||||
|
* JDK 1.8 (or better):
|
||||||
|
Set `JDKHOME` to the JDK or equivalent used to build jtreg. It must be
|
||||||
|
equivalent to JDK 8 or later.
|
||||||
|
|
||||||
|
* JT Harness:
|
||||||
|
See <https://wiki.openjdk.java.net/display/CodeTools/JT+Harness>.
|
||||||
|
Set `JTHARNESS_HOME` to the installed copy of the version of JT Harness to be
|
||||||
|
used. It should be version 6.0-b14 or better.
|
||||||
|
|
||||||
|
* Ant:
|
||||||
|
See <http://ant.apache.org/>. Set `ANTHOME` to an installed copy of Ant. It
|
||||||
|
should be version 1.10.x. or better.
|
||||||
|
|
||||||
|
* AsmTools:
|
||||||
|
See <https://wiki.openjdk.java.net/display/CodeTools/asmtools>.
|
||||||
|
Set `ASMTOOLS_HOME` to the installed copy of the version of AsmTools to be
|
||||||
|
used. It should be version 7.0-b09 or better.
|
||||||
|
|
||||||
|
Note: Do not confuse this component with ASM bytecode engineering library
|
||||||
|
available at <http://asm.ow2.org/>
|
||||||
|
|
||||||
|
* JUnit:
|
||||||
|
See <http://junit.org/>. The recommended version is currently JUnit 4.13.2.
|
||||||
|
JUnit has a dependency on Hamcrest. The recommended version is currently 2.2.
|
||||||
|
|
||||||
|
* TestNG:
|
||||||
|
See <http://testng.org/>. The recommended version is currently 7.3.0.
|
||||||
|
(Do not use 7.4.0 to run OpenJDK tests.)
|
||||||
|
TestNG has dependencies on JCommander and Google Guice.
|
||||||
|
The recommended version of JCommander is 1.78.
|
||||||
|
The recommended version of Google Guice is 4.2.3.
|
||||||
|
|
||||||
|
The following dependencies are optional.
|
||||||
|
|
||||||
|
* JCov:
|
||||||
|
See <https://wiki.openjdk.java.net/display/CodeTools/jcov>.
|
||||||
|
Set `JCOV_HOME` to the installed copy of the version of JCov to be used.
|
||||||
|
It should be version 3.0-b07 or better.
|
||||||
|
|
||||||
|
* JDK 1.5:
|
||||||
|
This is used when running some of the tests. Set `JDK5HOME` to run these
|
||||||
|
tests. It need not be set if you are just building jtreg.
|
||||||
|
|
||||||
|
* JDK 1.6:
|
||||||
|
This is used when running some of the tests. Set `JDK6HOME` to run these
|
||||||
|
tests. It need not be set if you are just building jtreg.
|
||||||
|
|
||||||
|
* JDK 1.7:
|
||||||
|
This is used when running some of the tests. Set `JDK7HOME` to run these
|
||||||
|
tests. It need not be set if you are just building jtreg.
|
||||||
|
|
||||||
|
* JDK 1.8:
|
||||||
|
This is used when running some of the tests. Set `JDK8HOME` to run these
|
||||||
|
tests. It need not be set if you are just building jtreg.
|
||||||
|
|
||||||
|
* JDK 9:
|
||||||
|
This is used when running some of the tests. Set `JDK9HOME` to run these
|
||||||
|
tests. It need not be set if you are just building jtreg.
|
||||||
|
|
||||||
|
* JDK 14:
|
||||||
|
This is used when running some of the tests. Set `JDK14HOME` to run these
|
||||||
|
tests. It need not be set if you are just building jtreg.
|
||||||
|
|
||||||
|
* JDK 18:
|
||||||
|
This is used when running some of the tests. Set `JDK18HOME` to run these
|
||||||
|
tests. It need not be set if you are just building jtreg.
|
||||||
|
|
||||||
|
The recommended versions are also defined in `make/build-support/version-numbers`.
|
||||||
|
|
||||||
|
## Running jtreg Self-Tests
|
||||||
|
|
||||||
|
The tests can be invoked with individual make targets, or collectively via the
|
||||||
|
`test` target.
|
||||||
|
|
||||||
|
Some of the tests need to pop up windows while they execute. No interaction with
|
||||||
|
these windows is normally required. Since this can be a problem on a headless
|
||||||
|
server machine, and an annoyance on a personal workstation, the tests will
|
||||||
|
attempt to use VNC to create a dummy X-server for use by the tests while they
|
||||||
|
are running. Various implementations of VNC are available, such as from
|
||||||
|
<http://www.realvnc.com/>. Using VNC is optional; it is not required in order to
|
||||||
|
run the tests.
|
||||||
|
|
||||||
|
By default, VNC will be used if `vncserver` is found on your execution path, or
|
||||||
|
if VNC_HOME points to an installed copy of VNC. To explicitly disable the use of
|
||||||
|
VNC, set the VNC environment variable to one of false, off, no, or 0. Unless
|
||||||
|
explicitly disabled, the tests will check the following:
|
||||||
|
|
||||||
|
* You must have a password set in _$HOME/.vnc/passwd_. This is the standard
|
||||||
|
location used by the vncserver command.
|
||||||
|
* If you set the environment variable `VNC_HOME`, it will be prepended to your
|
||||||
|
execution path to find vncserver.
|
||||||
|
* vncserver must be on your execution path, after `VNC_HOME` has been added,
|
||||||
|
if set.
|
||||||
|
|
||||||
|
If the tests find any issue with using VNC, it will not be used. If VNC is used
|
||||||
|
to create a dummy X server, the server will be terminated when the test is
|
||||||
|
complete.
|
||||||
|
|
||||||
|
The logic for using VNC is encapsulated within the script _make/display.sh_.
|
||||||
|
|
||||||
|
## Building jtreg with Ant
|
||||||
|
|
||||||
|
It is possible to build jtreg with Ant, but this is primarily intended as a
|
||||||
|
convenience while working on the jtreg source code. If you are building jtreg
|
||||||
|
to run OpenJDK tests, it is recommended that you build jtreg using the Makefile,
|
||||||
|
perhaps via the _build.sh_ wrapper script.
|
||||||
|
|
||||||
|
The build file is in _make/build.xml_; it creates intermediate files in the _build/_
|
||||||
|
directory and deliverables in the dist/ directory. By default, the build file
|
||||||
|
just builds jtreg, but does not run any tests. You can build jtreg from a
|
||||||
|
Unix-like command shell with the following commands:
|
||||||
|
|
||||||
|
% cd jtreg-root-directory
|
||||||
|
% ant -f make/build.xml
|
||||||
|
|
||||||
|
You can also use this build file when creating a NetBeans free form project with
|
||||||
|
an existing build file.
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
Some of the tasks that are used are listed as _Optional Tasks_ in the Ant
|
||||||
|
manual. You may need to make sure that these tasks are available for use by Ant.
|
||||||
|
For example, on Ubuntu Linux these tasks are in the `ant-optional` package.
|
||||||
|
|
||||||
|
### Running Tests
|
||||||
|
|
||||||
|
Some of the tests can be invoked with individual targets beginning
|
||||||
|
`-jtreg-test-`, or collectively via the `jtreg-test` target. (The use of
|
||||||
|
`jtreg-test` rather than `test` is to protect against interactions with JUnit in
|
||||||
|
older versions of NetBeans.)
|
||||||
|
|
||||||
|
## Using the IntelliJ IDE
|
||||||
|
|
||||||
|
The jtreg repo also contains a plugin for the IntelliJ IDE.
|
||||||
|
This is a convenience plugin which adds jtreg capabilities to the IntelliJ IDE.
|
||||||
|
With this plugin, OpenJDK developers can write, run, and debug jtreg tests
|
||||||
|
without leaving their IDE environment. For more details, see the file
|
||||||
|
[plugins/idea/README.md](plugins/idea/README.md) in this repo.
|
|
@ -0,0 +1,496 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 1996, 2018, 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
# include host-specific defs, if any
|
||||||
|
-include Defs-$(shell hostname).gmk
|
||||||
|
|
||||||
|
# TOPDIR = .. # now set in Makefile
|
||||||
|
ABSTOPDIR = $(shell cd $(TOPDIR); pwd)
|
||||||
|
|
||||||
|
# clobber settings from user's environment
|
||||||
|
JAVA_HOME=
|
||||||
|
CLASSPATH=
|
||||||
|
JAVA_COMPILER=
|
||||||
|
LD_LIBRARY_PATH=
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Support for Cygwin and MSYS2 (which may identify as MSYS, MINGW32 or MINGW64 (the default))
|
||||||
|
|
||||||
|
SYSTEM_UNAME := $(shell uname)
|
||||||
|
|
||||||
|
# Where is unwanted output to be delivered?
|
||||||
|
# On Windows, MKS uses the special file "NUL", cygwin uses the customary unix file.
|
||||||
|
ifeq ($(SYSTEM_UNAME), Windows_NT)
|
||||||
|
DEV_NULL = NUL
|
||||||
|
else
|
||||||
|
DEV_NULL = /dev/null
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(findstring CYGWIN,$(SYSTEM_UNAME)))
|
||||||
|
USING_CYGWIN = true
|
||||||
|
USING_CYGWIN_OR_USING_MSYS = true
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(findstring MSYS,$(SYSTEM_UNAME))$(findstring MINGW,$(SYSTEM_UNAME)))
|
||||||
|
USING_MSYS = true
|
||||||
|
USING_CYGWIN_OR_USING_MSYS = true
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef USING_CYGWIN_OR_USING_MSYS
|
||||||
|
define FullPath
|
||||||
|
$(shell cygpath -a -m $1 2> $(DEV_NULL))
|
||||||
|
endef
|
||||||
|
define PosixPath
|
||||||
|
$(shell cygpath -a -u $1 2> $(DEV_NULL))
|
||||||
|
endef
|
||||||
|
else
|
||||||
|
define FullPath
|
||||||
|
$(abspath $1)
|
||||||
|
endef
|
||||||
|
define PosixPath
|
||||||
|
$1
|
||||||
|
endef
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef BUILDDIR
|
||||||
|
BUILDDIR = $(TOPDIR)/build
|
||||||
|
endif
|
||||||
|
override BUILDDIR := $(call FullPath, $(BUILDDIR))
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Parameters to control what to build and test with.
|
||||||
|
|
||||||
|
#----- Java: http://openjdk.java.net/ http://jdk.java.net/
|
||||||
|
#
|
||||||
|
# Explicit JDK versions, for use as needed by tests, all optional for build.
|
||||||
|
# At a minimum, JDKHOME must be set, either directly or indirectly. (See below).
|
||||||
|
|
||||||
|
ifndef JDK5HOME
|
||||||
|
ifdef SLASHJAVA
|
||||||
|
JDK5HOME = $(SLASHJAVA)/re/jdk/1.5.0/archive/fcs/binaries/linux-i586
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
JDK5HOME := $(call FullPath,$(JDK5HOME))
|
||||||
|
|
||||||
|
ifndef JDK6HOME
|
||||||
|
ifdef SLASHJAVA
|
||||||
|
JDK6HOME = $(SLASHJAVA)/re/jdk/1.6.0/archive/fcs/binaries/linux-i586
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
JDK6HOME := $(call FullPath,$(JDK6HOME))
|
||||||
|
|
||||||
|
ifndef JDK7HOME
|
||||||
|
ifdef SLASHJAVA
|
||||||
|
JDK7HOME = $(SLASHJAVA)/re/jdk/1.7.0/archive/fcs/binaries/linux-i586
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
JDK7HOME := $(call FullPath,$(JDK7HOME))
|
||||||
|
|
||||||
|
ifndef JDK8HOME
|
||||||
|
ifdef SLASHJAVA
|
||||||
|
JDK8HOME = $(SLASHJAVA)/re/jdk/1.8.0/promoted/latest/binaries/linux-i586
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
JDK8HOME := $(call FullPath,$(JDK8HOME))
|
||||||
|
|
||||||
|
ifndef JDK9HOME
|
||||||
|
ifdef SLASHJAVA
|
||||||
|
JDK9HOME = $(SLASHJAVA)/re/jdk/9/promoted/latest/binaries/linux-i586
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
JDK9HOME := $(call FullPath,$(JDK9HOME))
|
||||||
|
|
||||||
|
# The JDK used to build jtreg and to run most tests.
|
||||||
|
# It should be set to JDK 8 or later.
|
||||||
|
# If not set, it defaults to $(JDK8HOME), or to $(J2SEHOME) for backwards
|
||||||
|
# compatibility
|
||||||
|
|
||||||
|
ifndef JDKHOME
|
||||||
|
ifdef JDK8HOME
|
||||||
|
JDKHOME = $(JDK8HOME)
|
||||||
|
else
|
||||||
|
ifdef J2SEHOME
|
||||||
|
JDKHOME = $(J2SEHOME)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# derived values
|
||||||
|
JDKJAVA = $(JDKHOME)/bin/java
|
||||||
|
JDKJAVAC = $(JDKHOME)/bin/javac
|
||||||
|
JAR = $(JDKHOME)/bin/jar
|
||||||
|
|
||||||
|
# Only use -source -target, to support legacy platforms, when building with JDK 8
|
||||||
|
# Otherwise, use default values for $JDKHOME/bin/javac
|
||||||
|
SUPPORT_OLD_SOURCE_TARGET = $(shell $(JDKJAVAC) -version 2>&1 | grep '[8]' > /dev/null && echo true )
|
||||||
|
ifneq ($(SUPPORT_OLD_SOURCE_TARGET),)
|
||||||
|
OLD_JAVAC_SOURCE_TARGET = -source 1.2 -target 1.1
|
||||||
|
AGENT_JAVAC_SOURCE_TARGET = -source 5 -target 5
|
||||||
|
TOOL_JAVAC_SOURCE_TARGET = -source 8 -target 8
|
||||||
|
REGTEST_TOOL_PATCH_JAVA_BASE_OPTIONS =
|
||||||
|
else
|
||||||
|
EXTRA_LINT_OPTS = -rawtypes,-unchecked
|
||||||
|
REGTEST_TOOL_PATCH_JAVA_BASE_OPTIONS = --patch-module java.base=$(JAVADIR)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef JDK5HOME
|
||||||
|
JDK5_BOOTCLASSPATH = -bootclasspath $(JDK5HOME)/jre/lib/rt.jar
|
||||||
|
endif
|
||||||
|
ifdef JDK8HOME
|
||||||
|
JDK8_BOOTCLASSPATH = -bootclasspath $(JDK8HOME)/jre/lib/rt.jar
|
||||||
|
endif
|
||||||
|
|
||||||
|
# for files needed to run othervm tests on oldest supported platforms
|
||||||
|
REGTEST_OLD_JAVAC = $(JDKHOME)/bin/javac
|
||||||
|
REGTEST_OLD_JAVAC_OPTIONS = \
|
||||||
|
$(OLD_JAVAC_SOURCE_TARGET) $(JDK5_BOOTCLASSPATH) -Xlint:all,-options,-deprecation,$(EXTRA_LINT_OPTS) -Werror
|
||||||
|
|
||||||
|
# for files needed to run agentvm tests (on platforms back to JDK 1.5)
|
||||||
|
REGTEST_AGENT_JAVAC = $(JDKHOME)/bin/javac
|
||||||
|
REGTEST_AGENT_JAVAC_OPTIONS = \
|
||||||
|
$(AGENT_JAVAC_SOURCE_TARGET) $(JDK5_BOOTCLASSPATH) -Xlint:all,-options,-deprecation,$(EXTRA_LINT_OPTS) -Werror
|
||||||
|
|
||||||
|
# for files needed for jtreg tool
|
||||||
|
REGTEST_TOOL_JAVAC = $(JDKHOME)/bin/javac
|
||||||
|
REGTEST_TOOL_JAVAC_OPTIONS = \
|
||||||
|
$(TOOL_JAVAC_SOURCE_TARGET) $(JDK8_BOOTCLASSPATH) -Xlint:all,-options,-deprecation -Werror
|
||||||
|
|
||||||
|
#----- JavaTest: https://wiki.openjdk.java.net/display/CodeTools/JT+Harness
|
||||||
|
#
|
||||||
|
# At a minimum, JAVATEST_JAR must be set, either directly or indirectly.
|
||||||
|
# If not set explicitly, it defaults to values derived from JAVATEST_HOME,
|
||||||
|
# JTHARNESS_HOME or SLASH_JAVA.
|
||||||
|
# Set JTHARNESS_LICENSE and JTHARNESS_COPYRIGHT to include license and
|
||||||
|
# copyright files in the product image. If not set explicitly, these
|
||||||
|
# default to values derived from JAVATEST_HOME, JTHARNESS_HOME or SLASH_JAVA.
|
||||||
|
|
||||||
|
ifndef JTHARNESS_HOME
|
||||||
|
ifdef SLASHJAVA
|
||||||
|
JTHARNESS_HOME = $(SLASHJAVA)/re/jtharness/6.0/promoted/ea/b11/binaries/
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef JAVATEST_HOME
|
||||||
|
ifdef JTHARNESS_HOME
|
||||||
|
JAVATEST_HOME = $(JTHARNESS_HOME)
|
||||||
|
else
|
||||||
|
ifdef SLASHJAVA
|
||||||
|
JAVATEST_HOME = $(SLASHJAVA)/re/javatest/6.0/promoted/latest/binaries/javatest/
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef JAVATEST_JAR
|
||||||
|
ifdef JAVATEST_HOME
|
||||||
|
JAVATEST_JAR = $(JAVATEST_HOME)/lib/javatest.jar
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
JAVATEST_JAR := $(call FullPath,$(JAVATEST_JAR))
|
||||||
|
|
||||||
|
ifndef JTHARNESS_LICENSE
|
||||||
|
JTHARNESS_LICENSE = $(wildcard $(JTHARNESS_HOME)/legal/license.txt)
|
||||||
|
endif
|
||||||
|
JTHARNESS_LICENSE := $(call FullPath,$(JTHARNESS_LICENSE))
|
||||||
|
|
||||||
|
ifndef JTHARNESS_COPYRIGHT
|
||||||
|
JTHARNESS_COPYRIGHT = $(wildcard $(JTHARNESS_HOME)/legal/copyright.txt)
|
||||||
|
endif
|
||||||
|
JTHARNESS_COPYRIGHT := $(call FullPath,$(JTHARNESS_COPYRIGHT))
|
||||||
|
|
||||||
|
#----- JCov 3.0: https://wiki.openjdk.java.net/display/CodeTools/jcov
|
||||||
|
#
|
||||||
|
# JCov is optional.
|
||||||
|
# If provided, coverage-collection features in jtreg will be enabled.
|
||||||
|
#
|
||||||
|
# To include support for JCov, JCOV_JAR and JCOV_NETWORK_SAVER_JAR
|
||||||
|
# must be set. If not set explicitly, these default to values derived
|
||||||
|
# from JCOV_HOME or SLASH_JAVA.
|
||||||
|
# Set JCOV_LICENSE to include the license file in the product image.
|
||||||
|
# If not set explicitly, this defaults to a value derived from JCOV_HOME
|
||||||
|
# or SLASH_JAVA.
|
||||||
|
|
||||||
|
ifndef JCOV_HOME
|
||||||
|
ifdef SLASHJAVA
|
||||||
|
JCOV_HOME = $(SLASHJAVA)/re/jcov/3.0/promoted/fcs/latest/binaries/jcov_3.0/
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef JCOV_JAR
|
||||||
|
ifdef JCOV_HOME
|
||||||
|
JCOV_JAR = $(JCOV_HOME)/lib/jcov.jar
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
JCOV_JAR := $(call FullPath,$(JCOV_JAR))
|
||||||
|
|
||||||
|
ifndef JCOV_NETWORK_SAVER_JAR
|
||||||
|
ifdef JCOV_HOME
|
||||||
|
JCOV_NETWORK_SAVER_JAR = $(JCOV_HOME)/lib/jcov_network_saver.jar
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
JCOV_NETWORK_SAVER_JAR := $(call FullPath,$(JCOV_NETWORK_SAVER_JAR))
|
||||||
|
|
||||||
|
ifndef JCOV_LICENSE
|
||||||
|
ifdef JCOV_HOME
|
||||||
|
JCOV_LICENSE = $(wildcard $(JCOV_HOME)/LICENSE)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
JCOV_LICENSE := $(call FullPath,$(JCOV_LICENSE))
|
||||||
|
|
||||||
|
JCOV = $(JDK6HOME)/bin/java -jar $(JCOV_JAR)
|
||||||
|
|
||||||
|
#----- AsmTools 7.0: https://wiki.openjdk.java.net/display/CodeTools/asmtools
|
||||||
|
#
|
||||||
|
# AsmTools is required, to support the execution of tests using
|
||||||
|
# *.jasm and *.jcod files.
|
||||||
|
#
|
||||||
|
# ASMTOOLS_JAR must be set, either directly or indirectly.
|
||||||
|
# If not set explicitly, it defaults to a value derived from
|
||||||
|
# ASMTOOLS_HOME or SLASHJAVA.
|
||||||
|
# Set ASMTOOLS_LICENSE to include the license file in the product image.
|
||||||
|
# If not set explicitly, this defaults to a value derived from
|
||||||
|
# ASMTOOLS_HOME or SLASH_JAVA.
|
||||||
|
|
||||||
|
ifndef ASMTOOLS_HOME
|
||||||
|
ifdef SLASHJAVA
|
||||||
|
ASMTOOLS_HOME = $(SLASHJAVA)/re/asmtools/7.0/promoted/opensource/ea/b08/binaries/asmtools-7.0/
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef ASMTOOLS_JAR
|
||||||
|
ASMTOOLS_JAR = $(ASMTOOLS_HOME)/lib/asmtools.jar
|
||||||
|
endif
|
||||||
|
ASMTOOLS_JAR := $(call FullPath,$(ASMTOOLS_JAR))
|
||||||
|
|
||||||
|
ifndef ASMTOOLS_LICENSE
|
||||||
|
ASMTOOLS_LICENSE = $(wildcard $(ASMTOOLS_HOME)/LICENSE)
|
||||||
|
endif
|
||||||
|
ASMTOOLS_LICENSE := $(call FullPath,$(ASMTOOLS_LICENSE))
|
||||||
|
|
||||||
|
#----- JUnit 4.10: http://www.junit.org/
|
||||||
|
# https://sourceforge.net/projects/junit/files/junit/4.10/junit-4.10.jar/download
|
||||||
|
#
|
||||||
|
# JUnit is required, to support the execution of tests using JUnit
|
||||||
|
#
|
||||||
|
# JUNIT_JAR must be set, either directly or indirectly.
|
||||||
|
# If not set explicitly, it defaults to a value derived from
|
||||||
|
# JUNIT_HOME or SLASHJAVA.
|
||||||
|
# Set JUNIT_LICENSE to include the license file in the product image.
|
||||||
|
# If not set explicitly, this defaults to a value derived from
|
||||||
|
# JUNIT_HOME or SLASH_JAVA.
|
||||||
|
|
||||||
|
ifndef JUNIT_HOME
|
||||||
|
ifdef SLASHJAVA
|
||||||
|
JUNIT_HOME = $(SLASHJAVA)/devtools/share/junit/junit-4.10/
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef JUNIT_JAR
|
||||||
|
ifdef JUNIT_HOME
|
||||||
|
JUNIT_JAR = $(JUNIT_HOME)/junit-4.10.jar
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
JUNIT_JAR := $(call FullPath,$(JUNIT_JAR))
|
||||||
|
|
||||||
|
ifndef JUNIT_LICENSE
|
||||||
|
ifdef JUNIT_HOME
|
||||||
|
JUNIT_LICENSE = $(wildcard $(JUNIT_HOME)/LICENSE.txt)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
JUNIT_LICENSE := $(call FullPath,$(JUNIT_LICENSE))
|
||||||
|
|
||||||
|
#----- TestNG 6.9.5: see http://www.testng.org/
|
||||||
|
# http://testng.org/doc/download.html
|
||||||
|
#
|
||||||
|
# TestNG is required, to support the execution of tests using TestNG
|
||||||
|
#
|
||||||
|
# TESTNG_JAR must be set, either directly or indirectly.
|
||||||
|
# If not set explicitly, it defaults to a value derived from
|
||||||
|
# TESTNG_HOME or SLASHJAVA.
|
||||||
|
# Set TESTNG_LICENSE to include the license file in the product image.
|
||||||
|
# If not set explicitly, this defaults to a value derived from
|
||||||
|
# TESTNG_HOME or SLASH_JAVA.
|
||||||
|
|
||||||
|
ifndef TESTNG_HOME
|
||||||
|
ifdef SLASHJAVA
|
||||||
|
TESTNG_HOME = $(SLASHJAVA)/devtools/share/testng/testng-6.9.5
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
TESTNG_HOME := $(call FullPath,$(TESTNG_HOME))
|
||||||
|
|
||||||
|
ifndef TESTNG_JAR
|
||||||
|
ifdef TESTNG_HOME
|
||||||
|
TESTNG_JAR = $(TESTNG_HOME)/testng-6.9.5.jar
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
TESTNG_JAR := $(call FullPath,$(TESTNG_JAR))
|
||||||
|
|
||||||
|
ifndef TESTNG_LICENSE
|
||||||
|
TESTNG_LICENSE = $(wildcard $(TESTNG_HOME)/LICENSE.txt)
|
||||||
|
endif
|
||||||
|
TESTNG_LICENSE := $(call FullPath,$(JUNIT_LICENSE))
|
||||||
|
|
||||||
|
# TestNG requires jcommander, which may or may not be bundled with TESTNG_JAR.
|
||||||
|
# If it is not, set JCOMMANDER_JAR to an appropriate version
|
||||||
|
ifndef JCOMMANDER_JAR
|
||||||
|
ifdef TESTNG_HOME
|
||||||
|
JCOMMANDER_JAR = $(wildcard $(TESTNG_HOME)/jcommander-1.48.jar)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
ifdef JCOMMANDER_JAR
|
||||||
|
JCOMMANDER_JAR := $(call FullPath,$(JCOMMANDER_JAR))
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Newer versions of TestNG require Google Guice
|
||||||
|
ifdef GOOGLE_GUICE_JAR
|
||||||
|
GOOGLE_GUICE_JAR := $(call FullPath,$(GOOGLE_GUICE_JAR))
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Newer versions of JUnit require Hamcrest
|
||||||
|
ifdef HAMCREST_JAR
|
||||||
|
HAMCREST_JAR := $(call FullPath,$(HAMCREST_JAR))
|
||||||
|
endif
|
||||||
|
|
||||||
|
#----- Ant: http://ant.apache.org/
|
||||||
|
#
|
||||||
|
# Ant is required, to support the provision of a <jtreg> Ant task
|
||||||
|
#
|
||||||
|
# ANT_JAR must be set, either directly or indirectly.
|
||||||
|
# If not set explicitly, it defaults to a value derived from
|
||||||
|
# ANTHOME or SLASHJAVA. The jar file is just used when building
|
||||||
|
# jtreg, and is not included in the product image.
|
||||||
|
|
||||||
|
ifndef ANTHOME
|
||||||
|
ifdef SLASHJAVA
|
||||||
|
ANTHOME = $(SLASHJAVA)/devtools/share/ant/1.9.4
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef ANT_JAR
|
||||||
|
ifdef ANTHOME
|
||||||
|
ANT_JAR = $(ANTHOME)/lib/ant.jar
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
ANT_JAR := $(call FullPath,$(ANT_JAR))
|
||||||
|
|
||||||
|
ifdef ANTHOME
|
||||||
|
ANT = $(ANTHOME)/bin/ant
|
||||||
|
endif
|
||||||
|
|
||||||
|
#----- Unix commands
|
||||||
|
|
||||||
|
AWK = /usr/bin/awk
|
||||||
|
CAT = /bin/cat
|
||||||
|
CHMOD = /bin/chmod
|
||||||
|
CP = /bin/cp
|
||||||
|
DIFF = /usr/bin/diff
|
||||||
|
ECHO = /bin/echo
|
||||||
|
FIND = /usr/bin/find
|
||||||
|
GREP := $(shell if [ -r /bin/grep ]; then echo /bin/grep ; else echo /usr/bin/grep ; fi )
|
||||||
|
LN = /bin/ln
|
||||||
|
LS = /bin/ls
|
||||||
|
MKDIR = /bin/mkdir
|
||||||
|
MV = /bin/mv
|
||||||
|
PANDOC = $(shell if [ -r /usr/bin/pandoc ]; then \
|
||||||
|
echo /usr/bin/pandoc ; \
|
||||||
|
elif [ -r /usr/local/bin/pandoc ]; then \
|
||||||
|
echo /usr/local/bin/pandoc ; \
|
||||||
|
else \
|
||||||
|
echo /bin/echo "pandoc not available" ; \
|
||||||
|
fi )
|
||||||
|
PERL = /usr/bin/perl
|
||||||
|
PRINTF = /usr/bin/printf
|
||||||
|
RM = /bin/rm -rf
|
||||||
|
SED := $(shell if [ -r /bin/sed ]; then echo /bin/sed ; else echo /usr/bin/sed ; fi )
|
||||||
|
SH = /bin/sh
|
||||||
|
SORT = /usr/bin/sort
|
||||||
|
TEST = /usr/bin/test
|
||||||
|
TIDY = /usr/bin/tidy
|
||||||
|
TOUCH = /usr/bin/touch
|
||||||
|
UNZIP = /usr/bin/unzip
|
||||||
|
WC = /usr/bin/wc
|
||||||
|
ZIP = /usr/bin/zip
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Identification of parts of the system
|
||||||
|
SRCDIR = $(TOPDIR)/src
|
||||||
|
JAVADIR = $(SRCDIR)/share/classes
|
||||||
|
SRCDOCDIR = $(SRCDIR)/share/doc
|
||||||
|
SRCJTDOCDIR = $(SRCDIR)/share/doc/javatest
|
||||||
|
SRCJTREGDOCDIR = $(SRCDIR)/share/doc/javatest/regtest
|
||||||
|
SRCSHAREBINDIR = $(SRCDIR)/share/bin
|
||||||
|
TESTDIR = $(TOPDIR)/test
|
||||||
|
|
||||||
|
CLASSDIR = $(BUILDDIR)/classes
|
||||||
|
ABSCLASSDIR = $(cd $(CLASSDIR); pwd)
|
||||||
|
|
||||||
|
IMAGES_DIR = $(BUILDDIR)/images
|
||||||
|
JTREG_IMAGEDIR = $(IMAGES_DIR)/jtreg
|
||||||
|
JTREG_IMAGEDOCDIR = $(JTREG_IMAGEDIR)/doc
|
||||||
|
JTREG_IMAGEJARDIR = $(JTREG_IMAGEDIR)/lib
|
||||||
|
ABS_JTREG_IMAGEJARDIR = $(shell cd $(JTREG_IMAGEJARDIR); pwd)
|
||||||
|
|
||||||
|
# source bundle locations
|
||||||
|
IMAGESRC_SRCDIR = $(IMAGESRC_TOPDIR)/src/share/classes
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Version tags
|
||||||
|
#
|
||||||
|
# BUILD_* variables are normally set (overridden) by RE builds
|
||||||
|
BUILD_VERSION = 5.2
|
||||||
|
BUILD_MILESTONE = dev
|
||||||
|
BUILD_NUMBER = b00
|
||||||
|
|
||||||
|
# don't eval dates here directly, because that leads to unstable builds
|
||||||
|
#BUILD_YEAR:sh = /bin/date +"%Y"
|
||||||
|
BUILD_YEAR_CMD = /bin/date '+%Y'
|
||||||
|
#BUILD_DOCDATE:sh = /bin/date +"%B %d, %Y"
|
||||||
|
BUILD_DOCDATE_CMD = /bin/date +'%B %d, %Y'
|
||||||
|
#BUILD_ZIPDATE:sh = /bin/date '+%d %h %Y'
|
||||||
|
BUILD_ZIPDATE_CMD = /bin/date '+%d %h %Y'
|
||||||
|
BUILD_NONFCS_MILESTONE_sh = echo $(BUILD_MILESTONE) | sed -e 's/[fF][cC][sS]//'
|
||||||
|
BUILD_NONFCS_MILESTONE = $(BUILD_NONFCS_MILESTONE_sh:sh)
|
||||||
|
|
||||||
|
# munge the BUILD values suitable for use in the bundle name
|
||||||
|
ZIPSFX_VERSION_sh = echo '$(BUILD_VERSION)' | sed -e 's|\([^0-9][^0-9]*\)|_|g'
|
||||||
|
ZIPSFX_MILESTONE_sh = echo '$(BUILD_MILESTONE)'
|
||||||
|
ZIPSFX_BUILD_sh = echo '$(BUILD_NUMBER)'
|
||||||
|
ZIPSFX_NEWBUILD_sh = echo '$(BUILD_NUMBER)' | sed -e 's|[^[0-9]||g' | xargs printf "%d"
|
||||||
|
ZIPSFX_DATE_sh = echo "`$(BUILD_ZIPDATE_CMD)`" | /usr/bin/tr -s '[A-Z] ' '[a-z]_'
|
||||||
|
|
||||||
|
VERBOSE_ZIP_SUFFIX = $(shell $(ZIPSFX_VERSION_sh))-$(shell $(ZIPSFX_MILESTONE_sh))-bin-$(shell $(ZIPSFX_BUILD_sh))-$(shell $(ZIPSFX_DATE_sh))
|
||||||
|
|
||||||
|
ifdef BUILD_MILESTONE
|
||||||
|
NEW_VERBOSE_ZIP_SUFFIX = $(BUILD_VERSION)-$(BUILD_MILESTONE)+$(shell $(ZIPSFX_NEWBUILD_sh))_bin
|
||||||
|
else
|
||||||
|
NEW_VERBOSE_ZIP_SUFFIX = $(BUILD_VERSION)+$(shell $(ZIPSFX_NEWBUILD_sh))_bin
|
||||||
|
endif
|
|
@ -0,0 +1,116 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 1999, 2018, 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
TOPDIR = ..
|
||||||
|
|
||||||
|
include Defs.gmk
|
||||||
|
include Platform.gmk
|
||||||
|
|
||||||
|
default: build
|
||||||
|
|
||||||
|
all: build test
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
include jtdiff.gmk
|
||||||
|
include jtreg.gmk
|
||||||
|
include $(TOPDIR)/test/*.gmk
|
||||||
|
include $(TOPDIR)/test/*/*.gmk
|
||||||
|
include Rules.gmk
|
||||||
|
|
||||||
|
build: $(BUILDFILES)
|
||||||
|
|
||||||
|
test: $(INITIAL_TESTS) $(TESTS) $(FINAL_TESTS)
|
||||||
|
count=`echo $+ | wc -w` ; \
|
||||||
|
echo "All ($${count}) selected tests completed successfully"
|
||||||
|
|
||||||
|
quick-test: $(INITIAL_TESTS)
|
||||||
|
count=`echo $+ | wc -w` ; \
|
||||||
|
echo "All ($${count}) selected tests completed successfully"
|
||||||
|
|
||||||
|
images: $(VERBOSEZIPFILES)
|
||||||
|
|
||||||
|
new-images: $(NEWVERBOSEZIPFILES)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) $(BUILDDIR)
|
||||||
|
|
||||||
|
.NO_PARALLEL: clean
|
||||||
|
|
||||||
|
sanity:
|
||||||
|
ifdef JDK1_1HOME
|
||||||
|
@echo "JDK1_1HOME = $(JDK1_1HOME)"
|
||||||
|
endif
|
||||||
|
ifdef JDK5HOME
|
||||||
|
@echo "JDK5HOME = $(JDK5HOME)"
|
||||||
|
endif
|
||||||
|
ifdef JDK6HOME
|
||||||
|
@echo "JDK6HOME = $(JDK6HOME)"
|
||||||
|
endif
|
||||||
|
ifdef JDK7HOME
|
||||||
|
@echo "JDK7HOME = $(JDK7HOME)"
|
||||||
|
endif
|
||||||
|
ifdef JDK8HOME
|
||||||
|
@echo "JDK8HOME = $(JDK8HOME)"
|
||||||
|
endif
|
||||||
|
ifdef JDK9HOME
|
||||||
|
@echo "JDK9HOME = $(JDK9HOME)"
|
||||||
|
endif
|
||||||
|
ifdef JDK14HOME
|
||||||
|
@echo "JDK14HOME = $(JDK14HOME)"
|
||||||
|
endif
|
||||||
|
ifdef JDK18HOME
|
||||||
|
@echo "JDK18HOME = $(JDK18HOME)"
|
||||||
|
endif
|
||||||
|
@echo "JDKHOME = $(JDKHOME)"
|
||||||
|
@echo "JAVATEST_HOME = $(JAVATEST_HOME)"
|
||||||
|
ifneq ($(JTHARNESS_HOME), $(JAVATEST_HOME))
|
||||||
|
@echo "JTHARNESS_HOME = $(JTHARNESS_HOME)"
|
||||||
|
endif
|
||||||
|
@echo "JTHARNESS_LICENSE = $(JTHARNESS_LICENSE)"
|
||||||
|
@echo "JTHARNESS_COPYRIGHT = $(JTHARNESS_COPYRIGHT)"
|
||||||
|
@echo "JCOV_JAR = $(JCOV_JAR)"
|
||||||
|
@echo "JCOV_LICENSE = $(JCOV_LICENSE)"
|
||||||
|
@echo "ASMTOOLS_JAR = $(ASMTOOLS_JAR)"
|
||||||
|
@echo "ASMTOOLS_LICENSE = $(ASMTOOLS_LICENSE)"
|
||||||
|
@echo "ANTHOME = $(ANTHOME)"
|
||||||
|
@echo "ANT_JAR = $(ANT_JAR)"
|
||||||
|
@echo "JUNIT_JAR = $(JUNIT_JAR)"
|
||||||
|
@echo "JUNIT_LICENSE = $(JUNIT_LICENSE)"
|
||||||
|
@echo "TESTNG_HOME = $(TESTNG_HOME)"
|
||||||
|
@echo "TESTNG_JAR = $(TESTNG_JAR)"
|
||||||
|
@echo "TESTNG_LICENSE = $(TESTNG_LICENSE)"
|
||||||
|
@echo "JCOMMANDER_JAR = $(JCOMMANDER_JAR)"
|
||||||
|
@echo "GOOGLE_JUICE_JAR = $(GOOGLE_JUICE_JAR)"
|
||||||
|
@echo "HAMCREST_JAR = $(HAMCREST_JAR)"
|
||||||
|
@echo "BUILD_VERSION = $(BUILD_VERSION)"
|
||||||
|
@echo "BUILD_MILESTONE = $(BUILD_MILESTONE)"
|
||||||
|
@echo "BUILD_NUMBER = $(BUILD_NUMBER)"
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: default all build test images new-images clean sanity
|
||||||
|
|
|
@ -0,0 +1,177 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 1995, 2013, 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
# This file is an extract from jdk/test/Makefile to model the logic
|
||||||
|
# for determining the platform keys used for ProblemList.txt
|
||||||
|
|
||||||
|
CUT = cut
|
||||||
|
UNAME = uname
|
||||||
|
|
||||||
|
# Get OS name from uname
|
||||||
|
UNAME_S := $(shell $(UNAME) -s)
|
||||||
|
|
||||||
|
# Commands to run on paths to make mixed paths for java on windows
|
||||||
|
GETMIXEDPATH=$(ECHO)
|
||||||
|
|
||||||
|
# Location of developer shared files
|
||||||
|
SLASH_JAVA = /java
|
||||||
|
|
||||||
|
# path separator
|
||||||
|
PS = :
|
||||||
|
|
||||||
|
# Platform specific settings
|
||||||
|
ifeq ($(UNAME_S), SunOS)
|
||||||
|
OS_NAME = solaris
|
||||||
|
OS_ARCH := $(shell $(UNAME) -p)
|
||||||
|
OS_VERSION := $(shell $(UNAME) -r)
|
||||||
|
endif
|
||||||
|
ifeq ($(UNAME_S), Linux)
|
||||||
|
OS_NAME = linux
|
||||||
|
OS_ARCH := $(shell $(UNAME) -m)
|
||||||
|
# Check for unknown arch, try uname -p if uname -m says unknown
|
||||||
|
ifeq ($(OS_ARCH),unknown)
|
||||||
|
OS_ARCH := $(shell $(UNAME) -p)
|
||||||
|
endif
|
||||||
|
OS_VERSION := $(shell $(UNAME) -r)
|
||||||
|
endif
|
||||||
|
ifeq ($(UNAME_S), Darwin)
|
||||||
|
OS_NAME = macosx
|
||||||
|
OS_ARCH := $(shell $(UNAME) -m)
|
||||||
|
OS_VERSION := $(shell defaults read loginwindow SystemVersionStampAsString)
|
||||||
|
endif
|
||||||
|
ifeq ($(OS_NAME),)
|
||||||
|
OS_NAME = windows
|
||||||
|
# GNU Make or MKS overrides $(PROCESSOR_ARCHITECTURE) to always
|
||||||
|
# return "x86". Use the first word of $(PROCESSOR_IDENTIFIER) instead.
|
||||||
|
ifeq ($(PROCESSOR_IDENTIFIER),)
|
||||||
|
PROC_ARCH:=$(shell $(UNAME) -m)
|
||||||
|
else
|
||||||
|
PROC_ARCH:=$(word 1, $(PROCESSOR_IDENTIFIER))
|
||||||
|
endif
|
||||||
|
OS_ARCH:=$(PROC_ARCH)
|
||||||
|
SLASH_JAVA = J:
|
||||||
|
EXESUFFIX = .exe
|
||||||
|
# These need to be different depending on MKS or CYGWIN
|
||||||
|
ifeq ($(findstring cygdrive,$(shell (cd C:/ && pwd))), )
|
||||||
|
GETMIXEDPATH = dosname -s
|
||||||
|
OS_VERSION := $(shell $(UNAME) -r)
|
||||||
|
else
|
||||||
|
GETMIXEDPATH = cygpath -m -s
|
||||||
|
OS_VERSION := $(shell $(UNAME) -s | $(CUT) -d'-' -f2)
|
||||||
|
endif
|
||||||
|
PS = ;
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Only want major and minor numbers from os version
|
||||||
|
OS_VERSION := $(shell $(ECHO) "$(OS_VERSION)" | $(CUT) -d'.' -f1,2)
|
||||||
|
|
||||||
|
# Name to use for x86_64 arch (historically amd64, but should change someday)
|
||||||
|
#OS_ARCH_X64_NAME:=amd64
|
||||||
|
OS_ARCH_X64_NAME:=x64
|
||||||
|
|
||||||
|
# Alternate arch names (in case this arch is known by a second name)
|
||||||
|
# PROBLEM_LISTS may use either name.
|
||||||
|
#OS_ARCH2-amd64:=x64
|
||||||
|
OS_ARCH2-x64:=amd64
|
||||||
|
|
||||||
|
# Try and use the arch names consistently
|
||||||
|
OS_ARCH:=$(patsubst x64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
|
||||||
|
OS_ARCH:=$(patsubst X64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
|
||||||
|
OS_ARCH:=$(patsubst AMD64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
|
||||||
|
OS_ARCH:=$(patsubst amd64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
|
||||||
|
OS_ARCH:=$(patsubst x86_64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
|
||||||
|
OS_ARCH:=$(patsubst 8664,$(OS_ARCH_X64_NAME),$(OS_ARCH))
|
||||||
|
OS_ARCH:=$(patsubst EM64T,$(OS_ARCH_X64_NAME),$(OS_ARCH))
|
||||||
|
OS_ARCH:=$(patsubst em64t,$(OS_ARCH_X64_NAME),$(OS_ARCH))
|
||||||
|
OS_ARCH:=$(patsubst intel64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
|
||||||
|
OS_ARCH:=$(patsubst Intel64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
|
||||||
|
OS_ARCH:=$(patsubst INTEL64,$(OS_ARCH_X64_NAME),$(OS_ARCH))
|
||||||
|
OS_ARCH:=$(patsubst IA64,ia64,$(OS_ARCH))
|
||||||
|
OS_ARCH:=$(patsubst X86,i586,$(OS_ARCH))
|
||||||
|
OS_ARCH:=$(patsubst x86,i586,$(OS_ARCH))
|
||||||
|
OS_ARCH:=$(patsubst i386,i586,$(OS_ARCH))
|
||||||
|
OS_ARCH:=$(patsubst i486,i586,$(OS_ARCH))
|
||||||
|
OS_ARCH:=$(patsubst i686,i586,$(OS_ARCH))
|
||||||
|
OS_ARCH:=$(patsubst 386,i586,$(OS_ARCH))
|
||||||
|
OS_ARCH:=$(patsubst 486,i586,$(OS_ARCH))
|
||||||
|
OS_ARCH:=$(patsubst 586,i586,$(OS_ARCH))
|
||||||
|
OS_ARCH:=$(patsubst 686,i586,$(OS_ARCH))
|
||||||
|
|
||||||
|
# Default ARCH_DATA_MODEL settings
|
||||||
|
ARCH_DATA_MODEL-i586 = 32
|
||||||
|
ARCH_DATA_MODEL-$(OS_ARCH_X64_NAME) = 64
|
||||||
|
ARCH_DATA_MODEL-ia64 = 64
|
||||||
|
ARCH_DATA_MODEL-sparc = 32
|
||||||
|
ARCH_DATA_MODEL-sparcv9 = 64
|
||||||
|
|
||||||
|
# If ARCH_DATA_MODEL is not defined, try and pick a reasonable default
|
||||||
|
ifndef ARCH_DATA_MODEL
|
||||||
|
ARCH_DATA_MODEL:=$(ARCH_DATA_MODEL-$(OS_ARCH))
|
||||||
|
endif
|
||||||
|
ifndef ARCH_DATA_MODEL
|
||||||
|
ARCH_DATA_MODEL=32
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Platform directory name
|
||||||
|
PLATFORM_OS = $(OS_NAME)-$(OS_ARCH)
|
||||||
|
|
||||||
|
# Check ARCH_DATA_MODEL, adjust OS_ARCH accordingly on solaris
|
||||||
|
ARCH_DATA_MODEL_ERROR= \
|
||||||
|
ARCH_DATA_MODEL=$(ARCH_DATA_MODEL) cannot be used with $(PLATFORM_OS)
|
||||||
|
ifeq ($(ARCH_DATA_MODEL),64)
|
||||||
|
ifeq ($(PLATFORM_OS),solaris-i586)
|
||||||
|
OS_ARCH=$(OS_ARCH_X64_NAME)
|
||||||
|
endif
|
||||||
|
ifeq ($(PLATFORM_OS),solaris-sparc)
|
||||||
|
OS_ARCH=sparcv9
|
||||||
|
endif
|
||||||
|
ifeq ($(OS_ARCH),i586)
|
||||||
|
x:=$(warning "WARNING: $(ARCH_DATA_MODEL_ERROR)")
|
||||||
|
endif
|
||||||
|
ifeq ($(OS_ARCH),sparc)
|
||||||
|
x:=$(warning "WARNING: $(ARCH_DATA_MODEL_ERROR)")
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
ifeq ($(ARCH_DATA_MODEL),32)
|
||||||
|
ifeq ($(OS_ARCH),$(OS_ARCH_X64_NAME))
|
||||||
|
x:=$(warning "WARNING: $(ARCH_DATA_MODEL_ERROR)")
|
||||||
|
endif
|
||||||
|
ifeq ($(OS_ARCH),ia64)
|
||||||
|
x:=$(warning "WARNING: $(ARCH_DATA_MODEL_ERROR)")
|
||||||
|
endif
|
||||||
|
ifeq ($(OS_ARCH),sparcv9)
|
||||||
|
x:=$(warning "WARNING: $(ARCH_DATA_MODEL_ERROR)")
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
x:=$(warning "WARNING: $(ARCH_DATA_MODEL_ERROR)")
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Alternate OS_ARCH name (defaults to OS_ARCH)
|
||||||
|
OS_ARCH2:=$(OS_ARCH2-$(OS_ARCH))
|
||||||
|
ifeq ($(OS_ARCH2),)
|
||||||
|
OS_ARCH2:=$(OS_ARCH)
|
||||||
|
endif
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 1996, 2019, 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Copy resources (*.properties) into classes directory from source tree
|
||||||
|
|
||||||
|
$(CLASSDIR)/%.properties: $(JAVADIR)/%.properties
|
||||||
|
$(RM) -f $@
|
||||||
|
if [ ! -d $(@D) ] ; then $(MKDIR) -p $(@D) ; fi
|
||||||
|
$(CP) $(@:$(CLASSDIR)/%=$(JAVADIR)/%) $@
|
||||||
|
|
||||||
|
$(CLASSDIR)/%.gif: $(JAVADIR)/%.gif
|
||||||
|
$(RM) -f $@
|
||||||
|
if [ ! -d $(@D) ] ; then $(MKDIR) -p $(@D) ; fi
|
||||||
|
$(CP) $(@:$(CLASSDIR)/%=$(JAVADIR)/%) $@
|
||||||
|
|
||||||
|
$(CLASSDIR)/%.png: $(JAVADIR)/%.png
|
||||||
|
$(RM) -f $@
|
||||||
|
if [ ! -d $(@D) ] ; then $(MKDIR) -p $(@D) ; fi
|
||||||
|
$(CP) $(@:$(CLASSDIR)/%=$(JAVADIR)/%) $@
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------
|
||||||
|
|
||||||
|
$(CLASSDIR) $(BUILDDIR) $(BUILDDIR)/testClasses $(BUILDDIR)/testWork $(BUILDDIR)/testReport:
|
||||||
|
$(MKDIR) -p $@
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Build a JAR file containing the contents of any classes/* files
|
||||||
|
# listed in the FILES.JAR.%
|
||||||
|
|
||||||
|
# default copyright; override as necessary
|
||||||
|
JAR_COPYRIGHT = -C $(TOPDIR) COPYRIGHT
|
||||||
|
|
||||||
|
$(IMAGES_DIR)/%.jar: pkgsToFiles.sh
|
||||||
|
$(RM) $@ $(@:$(IMAGES_DIR)/%.jar=$(BUILDDIR)/jarData/%)
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(MKDIR) -p $(@:$(IMAGES_DIR)/%.jar=$(BUILDDIR)/jarData/%)
|
||||||
|
( if [ -n "$(JAR_MAINCLASS)" ]; then echo "Main-class: $(JAR_MAINCLASS)" ; fi ; \
|
||||||
|
if [ -n "$(JAR_CLASSPATH)" ]; then echo "Class-Path: $(JAR_CLASSPATH)" ; fi ; \
|
||||||
|
echo "$(@F:%.jar=%)-Name: $(@F:%.jar=%)" ; \
|
||||||
|
if [ -n "$(BUILD_VERSION_STRING)" ]; then echo "$(@F:%.jar=%)-VersionString: $(BUILD_VERSION_STRING)" ; fi ; \
|
||||||
|
echo "$(@F:%.jar=%)-Version: $(BUILD_VERSION)" ; \
|
||||||
|
echo "$(@F:%.jar=%)-Milestone: $(BUILD_MILESTONE)" ; \
|
||||||
|
echo "$(@F:%.jar=%)-Build: $(BUILD_NUMBER)" ; \
|
||||||
|
echo "$(@F:%.jar=%)-BuildJavaVersion: `$(JDKJAVA) -fullversion 2>&1 | awk '{print $$NF}' | \
|
||||||
|
sed -e 's|^"\(.*\)"$$|Java(TM) 2 SDK, Version \1|'`" ; \
|
||||||
|
echo "$(@F:%.jar=%)-BuildDate: `/bin/date +'%B %d, %Y'`" ; \
|
||||||
|
) \
|
||||||
|
> $(@:$(IMAGES_DIR)/%.jar=$(BUILDDIR)/jarData/%/manifest.txt)
|
||||||
|
sh pkgsToFiles.sh $(CLASSDIR) $($(@F:%.jar=PKGS.JAR.%)) > $(@:$(IMAGES_DIR)/%.jar=$(BUILDDIR)/jarData/%/includes.txt)
|
||||||
|
$(JAR) -cmf $(@:$(IMAGES_DIR)/%.jar=$(BUILDDIR)/jarData/%/manifest.txt) $@ \
|
||||||
|
$(JAR_COPYRIGHT) \
|
||||||
|
@$(@:$(IMAGES_DIR)/%.jar=$(BUILDDIR)/jarData/%/includes.txt) \
|
||||||
|
$(patsubst $(CLASSDIR)/%,-C $(CLASSDIR) %,$(sort $(FILES.JAR.$(@F:%.jar=%)))) \
|
||||||
|
$(JAR_EXTRAS)
|
||||||
|
$(CHMOD) a-w $@
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Build zips with verbose names
|
||||||
|
|
||||||
|
%-$(VERBOSE_ZIP_SUFFIX).zip: %.zip
|
||||||
|
$(CP) $(@:%-$(VERBOSE_ZIP_SUFFIX).zip=%.zip) $@
|
||||||
|
|
||||||
|
%-$(NEW_VERBOSE_ZIP_SUFFIX).zip: %.zip
|
||||||
|
$(RM) $@
|
||||||
|
$(LN) $(@:%-$(NEW_VERBOSE_ZIP_SUFFIX).zip=%.zip) $@
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# cancel implicit rules
|
||||||
|
|
||||||
|
%: %.o
|
||||||
|
%: %.obj
|
||||||
|
%: %.dll
|
||||||
|
%: %.c
|
||||||
|
%: %.cc
|
||||||
|
%: %.cpp
|
||||||
|
%: %.C
|
||||||
|
%: %.p
|
||||||
|
%: %.f
|
||||||
|
%: %.s
|
||||||
|
%: %.F
|
||||||
|
%: %.r
|
||||||
|
%: %.S
|
||||||
|
%: %.mod
|
||||||
|
%: %.sh
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020, 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
mydir="$(dirname ${BASH_SOURCE[0]})"
|
||||||
|
log_module="$(basename "${BASH_SOURCE[0]}")"
|
||||||
|
. "${mydir}/../build-common.sh"
|
||||||
|
. "${mydir}/version-numbers"
|
||||||
|
|
||||||
|
ASMTOOLS_SRC_TAG="${ASMTOOLS_SRC_TAG:-${DEFAULT_ASMTOOLS_SRC_TAG}}"
|
||||||
|
ASMTOOLS_SRC_ARCHIVE_CHECKSUM="${ASMTOOLS_SRC_ARCHIVE_CHECKSUM:-${DEFAULT_ASMTOOLS_SRC_ARCHIVE_CHECKSUM}}"
|
||||||
|
|
||||||
|
ANT_VERSION="${ANT_VERSION:-${DEFAULT_ANT_VERSION}}"
|
||||||
|
ANT_ARCHIVE_CHECKSUM="${ANT_ARCHIVE_CHECKSUM:-${DEFAULT_ANT_ARCHIVE_CHECKSUM}}"
|
||||||
|
|
||||||
|
setup_ant
|
||||||
|
|
||||||
|
setup_asmtools_src() {
|
||||||
|
check_arguments "${FUNCNAME}" 1 $#
|
||||||
|
|
||||||
|
local dir="$1"
|
||||||
|
|
||||||
|
local ASMTOOLS_LOCAL_SRC_ARCHIVE="${dir}/../source.zip"
|
||||||
|
if [ "${ASMTOOLS_SRC_TAG}" = "tip" -o "${ASMTOOLS_SRC_TAG}" = "master" ]; then
|
||||||
|
local BRANCH="master"
|
||||||
|
get_archive_no_checksum "${CODE_TOOLS_URL_BASE}/asmtools/archive/${BRANCH}.zip" "${ASMTOOLS_LOCAL_SRC_ARCHIVE}" "${dir}"
|
||||||
|
ASMTOOLS_SRC_DIR="${dir}/asmtools-${BRANCH}"
|
||||||
|
else
|
||||||
|
get_archive "${CODE_TOOLS_URL_BASE}/asmtools/archive/${ASMTOOLS_SRC_TAG}.zip" "${ASMTOOLS_LOCAL_SRC_ARCHIVE}" "${dir}" "${ASMTOOLS_SRC_ARCHIVE_CHECKSUM}"
|
||||||
|
ASMTOOLS_SRC_DIR="${dir}/asmtools-${ASMTOOLS_SRC_TAG}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
build_asmtools() {
|
||||||
|
check_arguments "${FUNCNAME}" 0 $#
|
||||||
|
|
||||||
|
local ASMTOOLS_SRC_DIR_BASE="${BUILD_DIR}/src"
|
||||||
|
setup_asmtools_src "${ASMTOOLS_SRC_DIR_BASE}"
|
||||||
|
|
||||||
|
local ASMTOOLS_DIST="${BUILD_DIR}/build"
|
||||||
|
"${ANT}" -DBUILD_DIR="$(native_path "${ASMTOOLS_DIST}")" -f "$(native_path "${ASMTOOLS_SRC_DIR}/build/build.xml")"
|
||||||
|
ASMTOOLS_JAR="${ASMTOOLS_DIST}/binaries/lib/asmtools.jar"
|
||||||
|
ASMTOOLS_LICENSE="${ASMTOOLS_SRC_DIR}/LICENSE"
|
||||||
|
}
|
||||||
|
build_asmtools
|
||||||
|
|
||||||
|
if [ ! x"$BUILD_RESULTS_FILE" = x"" ]; then
|
||||||
|
mkdir -p "$(dirname "${BUILD_RESULTS_FILE}")"
|
||||||
|
cat > "${BUILD_RESULTS_FILE}" << EOF
|
||||||
|
ASMTOOLS_JAR="${ASMTOOLS_JAR}"
|
||||||
|
ASMTOOLS_LICENSE="${ASMTOOLS_LICENSE}"
|
||||||
|
EOF
|
||||||
|
fi
|
|
@ -0,0 +1,30 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020, 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
DEFAULT_ASMTOOLS_SRC_TAG=7.0-b09
|
||||||
|
DEFAULT_ASMTOOLS_SRC_ARCHIVE_CHECKSUM=604f5e1aad1912968781dc72a1f86043e4e2dc20
|
||||||
|
|
||||||
|
DEFAULT_ANT_VERSION=1.10.8
|
||||||
|
DEFAULT_ANT_ARCHIVE_CHECKSUM=dbe187ce2963f9df8a67de8aaff3b0a437d06978
|
|
@ -0,0 +1,338 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020, 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
log_message() {
|
||||||
|
local level="$1"
|
||||||
|
shift
|
||||||
|
echo "[${log_module}][${level}] $@"
|
||||||
|
}
|
||||||
|
|
||||||
|
error() {
|
||||||
|
log_message "ERROR" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
info() {
|
||||||
|
log_message "INFO" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
##
|
||||||
|
# Helper used to ensure the correct number of arguments is passed to bash functions
|
||||||
|
check_arguments() {
|
||||||
|
local name="$1"
|
||||||
|
local expected="$2"
|
||||||
|
local actual="$3"
|
||||||
|
|
||||||
|
if [ ! "${expected}" = "${actual}" ]; then
|
||||||
|
error "Incorrect number of arguments to function '${name}' (expecting ${expected} but got ${actual})"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
##
|
||||||
|
# Print an absolute path
|
||||||
|
abspath() {
|
||||||
|
check_arguments "${FUNCNAME}" 1 $#
|
||||||
|
|
||||||
|
local path="$1"
|
||||||
|
|
||||||
|
if [[ ${path} = /* ]]; then
|
||||||
|
echo "${path}"
|
||||||
|
else
|
||||||
|
echo "$PWD/${path}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
##
|
||||||
|
# Set up the checksum tool to use
|
||||||
|
#
|
||||||
|
setup_shasum() {
|
||||||
|
if [ -n "${SHASUM:-}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$(which sha1sum)" ]; then
|
||||||
|
SHASUM="sha1sum"
|
||||||
|
SHASUM_OPTIONS=""
|
||||||
|
elif [ -n "$(which shasum)" ]; then
|
||||||
|
SHASUM="shasum"
|
||||||
|
SHASUM_OPTIONS="-a 1"
|
||||||
|
else
|
||||||
|
error "Can't find shasum or sha1sum"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
native_path() {
|
||||||
|
check_arguments "${FUNCNAME}" 1 $#
|
||||||
|
|
||||||
|
if [ $CYGWIN_OR_MSYS -eq 1 ]; then echo $(cygpath -w $1); else echo "$1"; fi
|
||||||
|
}
|
||||||
|
|
||||||
|
mixed_path() {
|
||||||
|
check_arguments "${FUNCNAME}" 1 $#
|
||||||
|
|
||||||
|
if [ $CYGWIN_OR_MSYS -eq 1 ]; then echo $(cygpath -m $1); else echo "$1"; fi
|
||||||
|
}
|
||||||
|
|
||||||
|
##
|
||||||
|
# Download a file using wget
|
||||||
|
#
|
||||||
|
# wget options can be provided through the WGET_OPTIONS environment
|
||||||
|
# variable
|
||||||
|
#
|
||||||
|
download_using_wget() {
|
||||||
|
check_arguments "${FUNCNAME}" 2 $#
|
||||||
|
|
||||||
|
local url="$1"
|
||||||
|
local destfile="$2"
|
||||||
|
|
||||||
|
set +e
|
||||||
|
"${WGET}" ${WGET_OPTIONS} "${url}" -O "${destfile}"
|
||||||
|
ret=$?
|
||||||
|
if [ ! ${ret} = 0 ]; then
|
||||||
|
error "wget exited with exit code ${ret}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
set -e
|
||||||
|
}
|
||||||
|
|
||||||
|
##
|
||||||
|
# Download a file using curl
|
||||||
|
#
|
||||||
|
# curl options can be provided through the CURL_OPTIONS environment
|
||||||
|
# variable
|
||||||
|
#
|
||||||
|
download_using_curl() {
|
||||||
|
check_arguments "${FUNCNAME}" 2 $#
|
||||||
|
|
||||||
|
local url="$1"
|
||||||
|
local destfile="$2"
|
||||||
|
|
||||||
|
set +e
|
||||||
|
"${CURL}" ${CURL_OPTIONS} "${url}" -o "${destfile}"
|
||||||
|
ret=$?
|
||||||
|
if [ ! ${ret} = 0 ]; then
|
||||||
|
error "curl exited with exit code ${ret}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
set -e
|
||||||
|
}
|
||||||
|
|
||||||
|
##
|
||||||
|
# Download a file
|
||||||
|
#
|
||||||
|
# Will attempt to skip the download if the SKIP_DOWNLOAD environment
|
||||||
|
# variable is set and the destination file already exists
|
||||||
|
#
|
||||||
|
download() {
|
||||||
|
check_arguments "${FUNCNAME}" 2 $#
|
||||||
|
|
||||||
|
local url="$1"
|
||||||
|
local destfile="$2"
|
||||||
|
|
||||||
|
if [ "${SKIP_DOWNLOAD:-}" != "" -a -r "${destfile}" ]; then
|
||||||
|
info "Skipping download of ${url}..."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
info "Downloading ${url} to ${destfile}"
|
||||||
|
mkdir -p "$(dirname "${destfile}")"
|
||||||
|
if [ -n "${WGET}" ]; then
|
||||||
|
download_using_wget "${url}" "${destfile}"
|
||||||
|
elif [ -n "${CURL}" ]; then
|
||||||
|
download_using_curl "${url}" "${destfile}"
|
||||||
|
else
|
||||||
|
error "Cannot find a suitable tool for downloading fils (tried 'wget' and 'curl')"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
##
|
||||||
|
# Checksum a file
|
||||||
|
#
|
||||||
|
checksum() {
|
||||||
|
check_arguments "${FUNCNAME}" 2 $#
|
||||||
|
|
||||||
|
local file="$1"
|
||||||
|
local expected="$2"
|
||||||
|
|
||||||
|
if [ -n "${SKIP_CHECKSUM_CHECK:-}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ x"${expected}" = x"" ]; then
|
||||||
|
error "Expected checksum unexpectedly empty.."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local actual="$("${SHASUM}" ${SHASUM_OPTIONS} "${dest}" | awk '{ print $1; }')"
|
||||||
|
if [ ! x"${actual}" = x"${expected}" ]; then
|
||||||
|
error "Checksum mismatch for ${dest}:"
|
||||||
|
error "Expected: ${expected}"
|
||||||
|
error "Actual : ${actual}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
##
|
||||||
|
# Download and checksum a file
|
||||||
|
#
|
||||||
|
download_and_checksum() {
|
||||||
|
check_arguments "${FUNCNAME}" 3 $#
|
||||||
|
|
||||||
|
local url="$1"
|
||||||
|
local dest="$2"
|
||||||
|
local shasum="$3"
|
||||||
|
|
||||||
|
download "${url}" "${dest}"
|
||||||
|
checksum "${dest}" "${shasum}"
|
||||||
|
}
|
||||||
|
|
||||||
|
##
|
||||||
|
# Unpack an archive
|
||||||
|
#
|
||||||
|
unpack() {
|
||||||
|
check_arguments "${FUNCNAME}" 2 $#
|
||||||
|
|
||||||
|
local file="$1"
|
||||||
|
local unpackdir="$2"
|
||||||
|
|
||||||
|
info "Unpacking $file in $unpackdir"
|
||||||
|
|
||||||
|
(
|
||||||
|
mkdir -p "${unpackdir}"
|
||||||
|
case ${file} in
|
||||||
|
*.tar.gz)
|
||||||
|
"${TAR_CMD}" -xzf "$1" -C "${unpackdir}"
|
||||||
|
;;
|
||||||
|
*.zip)
|
||||||
|
"${UNZIP_CMD}" -q "$1" -d "${unpackdir}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
error "Unknown archive type for file '${file}'"
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
##
|
||||||
|
# Download and unpack an archive without performing a checksum check
|
||||||
|
#
|
||||||
|
get_archive_no_checksum() {
|
||||||
|
check_arguments "${FUNCNAME}" 3 $#
|
||||||
|
|
||||||
|
local url="$1"
|
||||||
|
local destfile="$2"
|
||||||
|
local unpackdir="$3"
|
||||||
|
|
||||||
|
rm -rf "${unpackdir}"/*
|
||||||
|
download "${url}" "${destfile}"
|
||||||
|
unpack "${destfile}" "${unpackdir}"
|
||||||
|
}
|
||||||
|
|
||||||
|
##
|
||||||
|
# Download, checksum, and unpack an archive
|
||||||
|
#
|
||||||
|
get_archive() {
|
||||||
|
check_arguments "${FUNCNAME}" 4 $#
|
||||||
|
|
||||||
|
local url="$1"
|
||||||
|
local destfile="$2"
|
||||||
|
local unpackdir="$3"
|
||||||
|
local shasum="$4"
|
||||||
|
|
||||||
|
rm -rf "${unpackdir}"/*
|
||||||
|
download_and_checksum "${url}" "${destfile}" "${shasum}"
|
||||||
|
unpack "${destfile}" "${unpackdir}"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
##
|
||||||
|
# Set up the ANT (and possibly ANT_JAR) environment variable(s)
|
||||||
|
#
|
||||||
|
setup_ant() {
|
||||||
|
check_arguments "${FUNCNAME}" 0 $#
|
||||||
|
|
||||||
|
if [ -n "${ANT:-}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${ANT_ARCHIVE_URL:-}" ]; then
|
||||||
|
if [ -n "${ANT_ARCHIVE_URL_BASE:-}" ]; then
|
||||||
|
ANT_ARCHIVE_URL="${ANT_ARCHIVE_URL_BASE}/apache-ant-${ANT_VERSION}-bin.zip"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
local ANT_DEPS_DIR="${DEPS_DIR}/ant"
|
||||||
|
|
||||||
|
if [ -n "${ANT_ARCHIVE_URL:-}" ]; then
|
||||||
|
local ANT_LOCAL_ARCHIVE_FILE="${DEPS_DIR}/$(basename "${ANT_ARCHIVE_URL}")"
|
||||||
|
get_archive "${ANT_ARCHIVE_URL}" "${ANT_LOCAL_ARCHIVE_FILE}" "${ANT_DEPS_DIR}" "${ANT_ARCHIVE_CHECKSUM}"
|
||||||
|
ANT="$(find "${ANT_DEPS_DIR}" -path '*/bin/ant')"
|
||||||
|
ANT_JAR="$(dirname "${ANT}")/../lib/ant.jar"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
error "Neither ANT_ARCHIVE_URL or ANT_ARCHIVE_URL_BASE is set"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -u
|
||||||
|
|
||||||
|
if [ -z "${mydir:-}" ]; then
|
||||||
|
error "mydir not set in caller (line/file): $(caller)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -z "${log_module:-}" ]; then
|
||||||
|
error "log_module not set in caller (line/file): $(caller)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
ROOT="$(abspath ${ROOT:-${mydir}/..})"
|
||||||
|
BUILD_DIR="$(abspath "${BUILD_DIR:-${ROOT}/build}")"
|
||||||
|
DEPS_DIR="${BUILD_DIR}/deps"
|
||||||
|
|
||||||
|
export TAR_CMD="${TAR_CMD:-tar}"
|
||||||
|
export TAR_OPTIONS="${TAR_OPTIONS:-}"
|
||||||
|
export UNZIP_CMD="${UNZIP_CMD:-unzip}"
|
||||||
|
export UNZIP_OPTIONS="${UNZIP_OPTIONS:--q} -u"
|
||||||
|
export WGET="${WGET:-$(which wget)}"
|
||||||
|
export WGET_OPTIONS="${WGET_OPTIONS:--q}"
|
||||||
|
export CURL="${CURL:-$(which curl)}"
|
||||||
|
export CURL_OPTIONS="${CURL_OPTIONS:--s -f -L}"
|
||||||
|
|
||||||
|
export MAVEN_REPO_URL_BASE="${MAVEN_REPO_URL_BASE:-https://repo1.maven.org/maven2}"
|
||||||
|
export CODE_TOOLS_URL_BASE="${CODE_TOOLS_URL_BASE:-https://git.openjdk.java.net}"
|
||||||
|
export ANT_ARCHIVE_URL_BASE="${ANT_ARCHIVE_URL_BASE:-https://archive.apache.org/dist/ant/binaries}"
|
||||||
|
|
||||||
|
setup_shasum
|
||||||
|
|
||||||
|
##
|
||||||
|
# Support for Cygwin and MSYS2 (which may identify as MSYS, MINGW32 or MINGW64 (the default))
|
||||||
|
#
|
||||||
|
case $(uname) in CYGWIN*|MSYS*|MINGW*) CYGWIN_OR_MSYS=1 ;; *) CYGWIN_OR_MSYS=0 ;; esac
|
||||||
|
info "CYGWIN_OR_MSYS=$CYGWIN_OR_MSYS"
|
|
@ -0,0 +1,167 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020, 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
mydir="$(dirname ${BASH_SOURCE[0]})"
|
||||||
|
log_module="$(basename "${BASH_SOURCE[0]}")"
|
||||||
|
|
||||||
|
. "${mydir}/../build-common.sh"
|
||||||
|
. "${mydir}/version-numbers"
|
||||||
|
|
||||||
|
JCOV_SRC_TAG="${JCOV_SRC_TAG:-${DEFAULT_JCOV_SRC_TAG}}"
|
||||||
|
JCOV_SRC_ARCHIVE_CHECKSUM="${JCOV_SRC_ARCHIVE_CHECKSUM:-${DEFAULT_JCOV_SRC_ARCHIVE_CHECKSUM}}"
|
||||||
|
|
||||||
|
ANT_VERSION="${ANT_VERSION:-${DEFAULT_ANT_VERSION}}"
|
||||||
|
ANT_ARCHIVE_CHECKSUM="${ANT_ARCHIVE_CHECKSUM:-${DEFAULT_ANT_ARCHIVE_CHECKSUM}}"
|
||||||
|
|
||||||
|
ASM_VERSION="${ASM_VERSION:-${DEFAULT_ASM_VERSION}}"
|
||||||
|
ASM_URL_BASE="${ASM_URL_BASE:-${MAVEN_REPO_URL_BASE}}"
|
||||||
|
ASM_JAR_CHECKSUM="${ASM_JAR_CHECKSUM:-${DEFAULT_ASM_JAR_CHECKSUM}}"
|
||||||
|
ASM_TREE_JAR_CHECKSUM="${ASM_TREE_JAR_CHECKSUM:-${DEFAULT_ASM_TREE_JAR_CHECKSUM}}"
|
||||||
|
ASM_UTIL_JAR_CHECKSUM="${ASM_UTIL_JAR_CHECKSUM:-${DEFAULT_ASM_UTIL_JAR_CHECKSUM}}"
|
||||||
|
|
||||||
|
JTHARNESS_SRC_TAG="${JTHARNESS_SRC_TAG:-${DEFAULT_JTHARNESS_SRC_TAG}}"
|
||||||
|
JTHARNESS_SRC_ARCHIVE_CHECKSUM="${JTHARNESS_SRC_ARCHIVE_CHECKSUM:-${DEFAULT_JTHARNESS_SRC_ARCHIVE_CHECKSUM}}"
|
||||||
|
|
||||||
|
setup_ant
|
||||||
|
info "ANT: ${ANT}"
|
||||||
|
|
||||||
|
setup_jcov_src() {
|
||||||
|
check_arguments "${FUNCNAME}" 1 $#
|
||||||
|
|
||||||
|
local dir="$1"
|
||||||
|
|
||||||
|
# Build jcov
|
||||||
|
local JCOV_LOCAL_SRC_ARCHIVE="${dir}/../source.zip"
|
||||||
|
if [ "${JCOV_SRC_TAG}" = "tip" -o "${JCOV_SRC_TAG}" = "master" ]; then
|
||||||
|
local BRANCH="master"
|
||||||
|
get_archive_no_checksum "${CODE_TOOLS_URL_BASE}/jcov/archive/${BRANCH}.zip" "${JCOV_LOCAL_SRC_ARCHIVE}" "${dir}"
|
||||||
|
JCOV_SRC_DIR="${dir}/jcov-${BRANCH}"
|
||||||
|
else
|
||||||
|
get_archive "${CODE_TOOLS_URL_BASE}/jcov/archive/${JCOV_SRC_TAG}.zip" "${JCOV_LOCAL_SRC_ARCHIVE}" "${dir}" "${JCOV_SRC_ARCHIVE_CHECKSUM}"
|
||||||
|
JCOV_SRC_DIR="${dir}/jcov-${JCOV_SRC_TAG}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_asm() {
|
||||||
|
check_arguments "${FUNCNAME}" 0 $#
|
||||||
|
|
||||||
|
local ASM_DEPS_DIR="${DEPS_DIR}/asm"
|
||||||
|
|
||||||
|
ASM_JAR="${ASM_DEPS_DIR}/asm-${ASM_VERSION}.jar"
|
||||||
|
download_and_checksum "${ASM_URL_BASE}/org/ow2/asm/asm/${ASM_VERSION}/asm-${ASM_VERSION}.jar" "${ASM_JAR}" "${ASM_JAR_CHECKSUM}"
|
||||||
|
|
||||||
|
ASM_TREE_JAR="${ASM_DEPS_DIR}/asm-tree-${ASM_VERSION}.jar"
|
||||||
|
download_and_checksum "${ASM_URL_BASE}/org/ow2/asm/asm-tree/${ASM_VERSION}/asm-tree-${ASM_VERSION}.jar" "${ASM_TREE_JAR}" "${ASM_TREE_JAR_CHECKSUM}"
|
||||||
|
|
||||||
|
ASM_UTIL_JAR="${ASM_DEPS_DIR}/asm-utils-${ASM_VERSION}.jar"
|
||||||
|
download_and_checksum "${ASM_URL_BASE}/org/ow2/asm/asm-util/${ASM_VERSION}/asm-util-${ASM_VERSION}.jar" "${ASM_UTIL_JAR}" "${ASM_UTIL_JAR_CHECKSUM}"
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_jtharness_javatest_jar() {
|
||||||
|
check_arguments "${FUNCNAME}" 0 $#
|
||||||
|
|
||||||
|
if [ -n "${JTHARNESS_JAVATEST_JAR:-}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
JTHARNESS_JAVATEST_JAR="$(find "${DEPS_DIR}" -name jtharness.jar)"
|
||||||
|
if [ -n "${JTHARNESS_JAVATEST_JAR}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${JTHARNESS_ARCHIVE_URL:-}" ]; then
|
||||||
|
if [ -n "${JTHARNESS_ARCHIVE_URL_BASE:-}" ]; then
|
||||||
|
JTHARNESS_ARCHIVE_URL="${JTHARNESS_ARCHIVE_URL_BASE}/${JTHARNESS_VERSION}/${JTHARNESS_BUILD_NUMBER}/${JTHARNESS_FILE}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${JTHARNESS_ARCHIVE_URL:-}" ]; then
|
||||||
|
local JTHARNESS_DEPS_DIR="${DEPS_DIR}/jtharness"
|
||||||
|
local JTHARNESS_LOCAL_ARCHIVE_FILE="${DEPS_DIR}/$(basename "${JTHARNESS_ARCHIVE_URL}")"
|
||||||
|
get_archive "${JTHARNESS_ARCHIVE_URL}" "${JTHARNESS_LOCAL_ARCHIVE_FILE}" "${JTHARNESS_DEPS_DIR}" "${JTHARNESS_ARCHIVE_CHECKSUM}"
|
||||||
|
JTHARNESS_JAVATEST_JAR="${JTHARNESS_DEPS_DIR}/${JTHARNESS_ARCHIVE_DIR_NAME}/lib/javatest.jar"
|
||||||
|
JTHARNESS_LICENSE="$(dirname "${JTHARNESS_JAVATEST_JAR}")/../legal/license.txt"
|
||||||
|
JTHARNESS_COPYRIGHT="$(dirname "${JTHARNESS_JAVATEST_JAR}")/../legal/copyright.txt"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
info "Neither JTHARNESS_ARCHIVE_URL or JTHARNESS_ARCHIVE_URL_BASE is set, building from source"
|
||||||
|
export JTHARNESS_BUILD_RESULTS_FILE="${BUILD_DIR}/deps/jtharness.results"
|
||||||
|
(
|
||||||
|
export BUILD_DIR="${BUILD_DIR}/deps/jtharness"
|
||||||
|
export BUILD_RESULTS_FILE="${JTHARNESS_BUILD_RESULTS_FILE}"
|
||||||
|
export JTHARNESS_SRC_TAG="${JTHARNESS_SRC_TAG}"
|
||||||
|
export JTHARNESS_SRC_ARCHIVE_CHECKSUM="${JTHARNESS_SRC_ARCHIVE_CHECKSUM}"
|
||||||
|
export ANT="${ANT}"
|
||||||
|
bash "${mydir}/../jtharness/build.sh"
|
||||||
|
)
|
||||||
|
ret=$?
|
||||||
|
if [ ! $ret = 0 ]; then
|
||||||
|
exit ${ret}
|
||||||
|
fi
|
||||||
|
. "${JTHARNESS_BUILD_RESULTS_FILE}"
|
||||||
|
}
|
||||||
|
|
||||||
|
build_jcov() {
|
||||||
|
check_arguments "${FUNCNAME}" 0 $#
|
||||||
|
|
||||||
|
setup_asm
|
||||||
|
setup_jtharness_javatest_jar
|
||||||
|
|
||||||
|
local JCOV_SRC_DIR_BASE="${BUILD_DIR}/src"
|
||||||
|
setup_jcov_src "${JCOV_SRC_DIR_BASE}"
|
||||||
|
|
||||||
|
local JCOV_DIST="${BUILD_DIR}/build"
|
||||||
|
(
|
||||||
|
cd "${JCOV_SRC_DIR}/build"
|
||||||
|
"${ANT}" -Dresult.dir="$(native_path "${JCOV_DIST}")" \
|
||||||
|
-Dasm.jar="$(native_path "${ASM_JAR}")" \
|
||||||
|
-Dasm.checksum="${ASM_JAR_CHECKSUM}" \
|
||||||
|
-Dasm.tree.jar="$(native_path "${ASM_TREE_JAR}")" \
|
||||||
|
-Dasm.tree.checksum="${ASM_TREE_JAR_CHECKSUM}" \
|
||||||
|
-Dasm.util.jar="$(native_path "${ASM_UTIL_JAR}")" \
|
||||||
|
-Dasm.util.checksum="${ASM_UTIL_JAR_CHECKSUM}" \
|
||||||
|
-Djavatestjar="$(native_path "${JTHARNESS_JAVATEST_JAR}")" \
|
||||||
|
-Dverify.strict= \
|
||||||
|
-f "$(native_path "${JCOV_SRC_DIR}/build/build.xml")"
|
||||||
|
)
|
||||||
|
|
||||||
|
local JCOV_DIST_JCOV_DIR="$(ls -d "${JCOV_DIST}/jcov"*)"
|
||||||
|
JCOV_JAR="${JCOV_DIST_JCOV_DIR}/jcov.jar"
|
||||||
|
JCOV_NETWORK_SAVER_JAR="${JCOV_DIST_JCOV_DIR}/jcov_network_saver.jar"
|
||||||
|
JCOV_LICENSE="${JCOV_SRC_DIR}/LICENSE"
|
||||||
|
}
|
||||||
|
build_jcov
|
||||||
|
|
||||||
|
if [ ! x"$BUILD_RESULTS_FILE" = x"" ]; then
|
||||||
|
mkdir -p "$(dirname "${BUILD_RESULTS_FILE}")"
|
||||||
|
cat > "${BUILD_RESULTS_FILE}" << EOF
|
||||||
|
JCOV_JAR="${JCOV_JAR}"
|
||||||
|
JCOV_NETWORK_SAVER_JAR="${JCOV_NETWORK_SAVER_JAR}"
|
||||||
|
JCOV_LICENSE="${JCOV_LICENSE}"
|
||||||
|
EOF
|
||||||
|
fi
|
|
@ -0,0 +1,38 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020, 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
DEFAULT_JCOV_SRC_TAG=jcov3.0-b07
|
||||||
|
DEFAULT_JCOV_SRC_ARCHIVE_CHECKSUM=c5c26085750628d58de275b3f50a7409300c0497
|
||||||
|
|
||||||
|
DEFAULT_ANT_VERSION=1.10.8
|
||||||
|
DEFAULT_ANT_ARCHIVE_CHECKSUM=dbe187ce2963f9df8a67de8aaff3b0a437d06978
|
||||||
|
|
||||||
|
DEFAULT_ASM_VERSION=8.0
|
||||||
|
DEFAULT_ASM_JAR_CHECKSUM=d1a17d07c60e9e82c8b31b1d8f9ca98726418db4
|
||||||
|
DEFAULT_ASM_TREE_JAR_CHECKSUM=7b31ca94da9f57334a5aed79b40f2b88c5ee9f4f
|
||||||
|
DEFAULT_ASM_UTIL_JAR_CHECKSUM=b21996293fd49851ed9017cfde3191e49f77fbd0
|
||||||
|
|
||||||
|
DEFAULT_JTHARNESS_SRC_TAG=jt6.0-b13
|
||||||
|
DEFAULT_JTHARNESS_SRC_ARCHIVE_CHECKSUM=43936b2616476fcac8ee4bd0132e73c015119337
|
|
@ -0,0 +1,82 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020, 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
mydir="$(dirname ${BASH_SOURCE[0]})"
|
||||||
|
log_module="$(basename "${BASH_SOURCE[0]}")"
|
||||||
|
|
||||||
|
. "${mydir}/../build-common.sh"
|
||||||
|
. "${mydir}/version-numbers"
|
||||||
|
|
||||||
|
JTHARNESS_SRC_TAG="${JTHARNESS_SRC_TAG:-${DEFAULT_JTHARNESS_SRC_TAG}}"
|
||||||
|
JTHARNESS_SRC_ARCHIVE_CHECKSUM="${JTHARNESS_SRC_ARCHIVE_CHECKSUM:-${DEFAULT_JTHARNESS_SRC_ARCHIVE_CHECKSUM}}"
|
||||||
|
|
||||||
|
ANT_VERSION="${ANT_VERSION:-${DEFAULT_ANT_VERSION}}"
|
||||||
|
ANT_ARCHIVE_CHECKSUM="${ANT_ARCHIVE_CHECKSUM:-${DEFAULT_ANT_ARCHIVE_CHECKSUM}}"
|
||||||
|
|
||||||
|
setup_ant
|
||||||
|
info "ANT: ${ANT}"
|
||||||
|
|
||||||
|
setup_jtharness_source() {
|
||||||
|
check_arguments "${FUNCNAME}" 1 $#
|
||||||
|
|
||||||
|
local dir="$1"
|
||||||
|
|
||||||
|
# Build jtharness
|
||||||
|
local JTHARNESS_LOCAL_SRC_ARCHIVE="${dir}/../source.zip"
|
||||||
|
if [ "${JTHARNESS_SRC_TAG}" = "tip" -o "${JTHARNESS_SRC_TAG}" = "master" ]; then
|
||||||
|
local BRANCH="master"
|
||||||
|
get_archive_no_checksum "${CODE_TOOLS_URL_BASE}/jtharness/archive/${BRANCH}.zip" "${JTHARNESS_LOCAL_SRC_ARCHIVE}" "${dir}"
|
||||||
|
JTHARNESS_SRC_DIR="${dir}/jtharness-${BRANCH}"
|
||||||
|
else
|
||||||
|
get_archive "${CODE_TOOLS_URL_BASE}/jtharness/archive/${JTHARNESS_SRC_TAG}.zip" "${JTHARNESS_LOCAL_SRC_ARCHIVE}" "${dir}" "${JTHARNESS_SRC_ARCHIVE_CHECKSUM}"
|
||||||
|
JTHARNESS_SRC_DIR="${dir}/jtharness-${JTHARNESS_SRC_TAG}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
build_jtharness() {
|
||||||
|
check_arguments "${FUNCNAME}" 0 $#
|
||||||
|
|
||||||
|
local JTHARNESS_SRC_DIR_BASE="${BUILD_DIR}/src"
|
||||||
|
setup_jtharness_source "${JTHARNESS_SRC_DIR_BASE}"
|
||||||
|
|
||||||
|
local JTHARNESS_DIST="${BUILD_DIR}/build"
|
||||||
|
"${ANT}" -DBUILD_DIR="$(native_path "${JTHARNESS_DIST}")" -f "$(native_path "${JTHARNESS_SRC_DIR}/build/build.xml")"
|
||||||
|
|
||||||
|
JTHARNESS_JAVATEST_JAR="${JTHARNESS_DIST}/binaries/lib/javatest.jar"
|
||||||
|
JTHARNESS_LICENSE="${JTHARNESS_SRC_DIR}/legal/license.txt"
|
||||||
|
JTHARNESS_COPYRIGHT="${JTHARNESS_SRC_DIR}/legal/copyright.txt"
|
||||||
|
}
|
||||||
|
build_jtharness
|
||||||
|
|
||||||
|
if [ ! x"$BUILD_RESULTS_FILE" = x"" ]; then
|
||||||
|
mkdir -p "$(dirname "${BUILD_RESULTS_FILE}")"
|
||||||
|
cat > "${BUILD_RESULTS_FILE}" << EOF
|
||||||
|
JTHARNESS_JAVATEST_JAR="${JTHARNESS_JAVATEST_JAR}"
|
||||||
|
JTHARNESS_LICENSE="${JTHARNESS_LICENSE}"
|
||||||
|
JTHARNESS_COPYRIGHT="${JTHARNESS_COPYRIGHT}"
|
||||||
|
EOF
|
||||||
|
fi
|
|
@ -0,0 +1,30 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020, 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
DEFAULT_JTHARNESS_SRC_TAG=jt6.0-b14
|
||||||
|
DEFAULT_JTHARNESS_SRC_ARCHIVE_CHECKSUM=3a455d4cf2c184f7db2bc73d0c110a6bf668b2fc
|
||||||
|
|
||||||
|
DEFAULT_ANT_VERSION=1.10.8
|
||||||
|
DEFAULT_ANT_ARCHIVE_CHECKSUM=dbe187ce2963f9df8a67de8aaff3b0a437d06978
|
|
@ -0,0 +1,57 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020, 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
JTREG_VERSION=6.1
|
||||||
|
|
||||||
|
DEFAULT_ANT_VERSION=1.10.8
|
||||||
|
DEFAULT_ANT_ARCHIVE_CHECKSUM=dbe187ce2963f9df8a67de8aaff3b0a437d06978
|
||||||
|
DEFAULT_ANT_JAR_CHECKSUM=ae148abb0532b685c5eeb22fdec9d124e89be5de
|
||||||
|
|
||||||
|
DEFAULT_ASMTOOLS_SRC_TAG=7.0-b09
|
||||||
|
DEFAULT_ASMTOOLS_SRC_ARCHIVE_CHECKSUM=604f5e1aad1912968781dc72a1f86043e4e2dc20
|
||||||
|
|
||||||
|
DEFAULT_GOOGLE_GUICE_VERSION=4.2.3
|
||||||
|
DEFAULT_GOOGLE_GUICE_JAR_CHECKSUM=2ea992d6d7bdcac7a43111a95d182a4c42eb5ff7
|
||||||
|
|
||||||
|
DEFAULT_HAMCREST_VERSION=2.2
|
||||||
|
DEFAULT_HAMCREST_JAR_CHECKSUM=1820c0968dba3a11a1b30669bb1f01978a91dedc
|
||||||
|
|
||||||
|
DEFAULT_JCOMMANDER_VERSION=1.78
|
||||||
|
DEFAULT_JCOMMANDER_JAR_CHECKSUM=a3927de9bd6f351429bcf763712c9890629d8f51
|
||||||
|
|
||||||
|
DEFAULT_JCOV_SRC_TAG=jcov3.0-b07
|
||||||
|
DEFAULT_JCOV_SRC_ARCHIVE_CHECKSUM=c5c26085750628d58de275b3f50a7409300c0497
|
||||||
|
|
||||||
|
DEFAULT_JTHARNESS_SRC_TAG=jt6.0-b14
|
||||||
|
DEFAULT_JTHARNESS_SRC_ARCHIVE_CHECKSUM=3a455d4cf2c184f7db2bc73d0c110a6bf668b2fc
|
||||||
|
|
||||||
|
DEFAULT_JUNIT_VERSION=4.13.2
|
||||||
|
DEFAULT_JUNIT_JAR_CHECKSUM=8ac9e16d933b6fb43bc7f576336b8f4d7eb5ba12
|
||||||
|
DEFAULT_JUNIT_LICENSE_FILE=LICENSE-junit.txt
|
||||||
|
|
||||||
|
DEFAULT_TESTNG_VERSION=7.3.0
|
||||||
|
DEFAULT_TESTNG_JAR_CHECKSUM=a5069c3dfba58d23702f96c3d9f5081f5ce7136f
|
||||||
|
DEFAULT_TESTNG_LICENSE_VERSION=7.3.0
|
||||||
|
DEFAULT_TESTNG_LICENSE_CHECKSUM=c646d2cd1433560a4b43cb98e7273b59aac4563c
|
|
@ -0,0 +1,70 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2007, 2016, 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
# set locations here, or in ${root}/build.properties, or set on the
|
||||||
|
# ant command line
|
||||||
|
|
||||||
|
jtreg.build.resources = /opt
|
||||||
|
|
||||||
|
# JTHarness or JavaTest (should be should be 6.0 or better)
|
||||||
|
javatest.home = ${jtreg.build.resources}/jtharness/6.0
|
||||||
|
javatest.jar = ${javatest.home}/lib/javatest.jar
|
||||||
|
# the following is only true for older versions of JavaTest.
|
||||||
|
# can't use <available> to set it automatically for some reason
|
||||||
|
#javatest.includes.javahelp.ok = true
|
||||||
|
|
||||||
|
# JavaHelp (should be version 2.0 or better)
|
||||||
|
javahelp.home = ${jtreg.build.resources}/javahelp/2.0
|
||||||
|
jhall.jar = ${javahelp.home}/javahelp/lib/jhall.jar
|
||||||
|
jh.jar = ${javahelp.home}/javahelp/lib/jh.jar
|
||||||
|
|
||||||
|
# JUnit (should be 4.10 or better)
|
||||||
|
junit.jar = ${jtreg.build.resources}/junit/4.10/junit-4.10.jar
|
||||||
|
|
||||||
|
# TestNG (should be 6.9.5 or better)
|
||||||
|
testng.jar = ${jtreg.build.resources}/testng/6.9.5/testng-6.9.5.jar
|
||||||
|
|
||||||
|
# JCommander (should be recent, e.g. 1.48 or better)
|
||||||
|
# This is required by TestNG; if it is already included in testng.jar
|
||||||
|
# you do not have to specify it here. Otherwise uncomment and update the
|
||||||
|
# following line.
|
||||||
|
#jcommander.jar = ${jtreg.build.resources}/jcommander/1.48/jcommander-1.48.jar
|
||||||
|
|
||||||
|
# AsmTools (should be 6.0 or better)
|
||||||
|
asmtools.jar = ${jtreg.build.resources}/asmtools/6.0/lib/asmtools.jar
|
||||||
|
|
||||||
|
# jcov (should be 2.0 or better)
|
||||||
|
jcov.home = ${jtreg.build.resources}/jcov/2.0
|
||||||
|
|
||||||
|
# Ant (should be version 1.6.5 or better)
|
||||||
|
ant.home = ${jtreg.build.resources}/ant/1.7.1
|
||||||
|
ant.jar = ${ant.home}/lib/ant.jar
|
||||||
|
|
||||||
|
# checkstyle (should be version 5.4 or better)
|
||||||
|
checkstyle.home = ${jtreg.build.resources}/checkstyle/5.4
|
||||||
|
|
||||||
|
build.version = 5.0
|
||||||
|
build.milestone = dev
|
||||||
|
build.number = b00
|
|
@ -0,0 +1,936 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020, 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
# This script will download/build the dependencies for jtreg and then
|
||||||
|
# build jtreg. Downloaded files are verified against known/specified
|
||||||
|
# specified checksums.
|
||||||
|
|
||||||
|
# The default version to use when building jtreg can be found in the
|
||||||
|
# make/version-numbers file, where the default versions and
|
||||||
|
# corresponding known checksums for the dependencies are also
|
||||||
|
# specified. Almost all of the defaults can be overridden by setting
|
||||||
|
# the respective environment variables.
|
||||||
|
|
||||||
|
# For each of the dependency the following steps are applied and the
|
||||||
|
# first successful one is used:
|
||||||
|
#
|
||||||
|
# 1. Check if the dependency is available locally
|
||||||
|
# 2. Download a prebuilt version of the dependency
|
||||||
|
# 3. Build the dependency from source, downloading the source archive
|
||||||
|
# first
|
||||||
|
#
|
||||||
|
# In particular, when not found locally the dependencies will be
|
||||||
|
# handled as follows:
|
||||||
|
#
|
||||||
|
# * JUnit, TestNG, JCommander, and Ant jar are by default
|
||||||
|
# downloaded from Maven central.
|
||||||
|
# * JT Harness, JCov, and AsmTools are downloaded or built from
|
||||||
|
# source.
|
||||||
|
# * The JDK dependency is downloaded. No default URL is set.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Some noteworthy control variables:
|
||||||
|
#
|
||||||
|
# MAVEN_REPO_URL_BASE (e.g. "https://repo1.maven.org/maven2")
|
||||||
|
# The base URL for the maven central repository.
|
||||||
|
#
|
||||||
|
# CODE_TOOLS_URL_BASE (e.g. "https://git.openjdk.java.net")
|
||||||
|
# The base URL for the code tools source repositories.
|
||||||
|
#
|
||||||
|
# ANT_ARCHIVE_URL_BASE (e.g. "https://archive.apache.org/dist/ant/binaries")
|
||||||
|
# The base URL for Ant dist binaries.
|
||||||
|
#
|
||||||
|
# JTREG_VERSION (e.g. "5.2")
|
||||||
|
# JTREG_VERSION_STRING (e.g. "jtreg-5.2+8"
|
||||||
|
# JTREG_BUILD_NUMBER (e.g. "8")
|
||||||
|
# JTREG_BUILD_MILESTONE (e.g. "dev")
|
||||||
|
# The version information to use for when building jtreg.
|
||||||
|
#
|
||||||
|
# MAKE_ARGS (e.g. "-j4 all")
|
||||||
|
# Additional arguments to pass to make when building jtreg.
|
||||||
|
#
|
||||||
|
# WGET
|
||||||
|
# The wget-like executable to use when downloading files.
|
||||||
|
#
|
||||||
|
# WGET_OPTS (e.g. "-v")
|
||||||
|
# Additional arguments to pass to WGET when downloading files.
|
||||||
|
#
|
||||||
|
# CURL (e.g. "/path/to/my/wget")
|
||||||
|
# The curl-like executable to use when downloading files.
|
||||||
|
# Note: If available, wget will be preferred.
|
||||||
|
#
|
||||||
|
# CURL_OPTS (e.g. "-v")
|
||||||
|
# Additional arguments to pass to CURL when downloading files.
|
||||||
|
#
|
||||||
|
# SKIP_DOWNLOAD
|
||||||
|
# Skip the downloads if the file is already present locally.
|
||||||
|
#
|
||||||
|
# SKIP_CHECKSUM_CHECK
|
||||||
|
# Skip the checksum verification for downloaded files.
|
||||||
|
|
||||||
|
# The control variables for dependencies are on the following general
|
||||||
|
# form (not all of them are relevant for all dependencies):
|
||||||
|
#
|
||||||
|
# <dependency>_URL (e.g. JTHARNESS_ARCHIVE_URL)
|
||||||
|
# The full URL for the dependency.
|
||||||
|
#
|
||||||
|
# <dependency>_URL_BASE (e.g. JTHARNESS_ARCHIVE_URL_BASE)
|
||||||
|
# The base URL for the dependency. Requires additional dependency
|
||||||
|
# specific variables to be specified.
|
||||||
|
#
|
||||||
|
# <dependency>_CHECKSUM (e.g. JTHARNESS_ARCHIVE_CHECKSUM)
|
||||||
|
# The expected checksum of the download file.
|
||||||
|
#
|
||||||
|
# <dependency>_SRC_TAG (e.g. JTHARNESS_SRC_TAG)
|
||||||
|
# The SCM tag to use when building from source. The special value
|
||||||
|
# "tip" can be used to get the most recent version.
|
||||||
|
#
|
||||||
|
# <dependency>_SRC_ARCHIVE_CHECKSUM (e.g. JTHARNESS_SRC_ARCHIVE_CHECKSUM)
|
||||||
|
# The checksum of the source archive.
|
||||||
|
#
|
||||||
|
|
||||||
|
# The below outlines the details of how the dependencies are
|
||||||
|
# handled. For each dependency the steps are tried in order and the
|
||||||
|
# first successful one will be used.
|
||||||
|
#
|
||||||
|
# Ant
|
||||||
|
# Checksum variables:
|
||||||
|
# ANT_ARCHIVE_CHECKSUM: checksum of binary archive
|
||||||
|
#
|
||||||
|
# 1. ANT
|
||||||
|
# The path to the ant executable.
|
||||||
|
# 2a. ANT_ARCHIVE_URL
|
||||||
|
# The full URL for the archive.
|
||||||
|
# 2b. ANT_ARCHIVE_URL_BASE + ANT_VERSION
|
||||||
|
# The individual URL components used to construct the full URL.
|
||||||
|
#
|
||||||
|
# Ant jar
|
||||||
|
# Checksum variables:
|
||||||
|
# ANT_JAR_CHECKSUM: checksum of binary archive
|
||||||
|
#
|
||||||
|
# 1. ANT_JAR
|
||||||
|
# The path to ant.jar.
|
||||||
|
# 2a. ANT_JAR_URL
|
||||||
|
# The full URL for the jar.
|
||||||
|
# 2b. ANT_JAR_URL_BASE + ANT_JAR_VERSION
|
||||||
|
# The individual URL components used to construct the full URL.
|
||||||
|
#
|
||||||
|
# AsmTools
|
||||||
|
# Checksum variables:
|
||||||
|
# ASMTOOLS_ARCHIVE_CHECKSUM: checksum of binary archive
|
||||||
|
# ASMTOOLS_SRC_ARCHIVE_CHECKSUM: checksum of source archive
|
||||||
|
#
|
||||||
|
# 1. ASMTOOLS_JAR + ASMTOOLS_LICENSE
|
||||||
|
# The path to asmtools.jar and LICENSE respectively.
|
||||||
|
# 2a. ASMTOOLS_ARCHIVE_URL
|
||||||
|
# The full URL for the archive.
|
||||||
|
# 2b. ASMTOOLS_ARCHIVE_URL_BASE + ASMTOOLS_VERSION + ASMTOOLS_BUILD_NUMBER + ASMTOOLS_FILE
|
||||||
|
# The individual URL components used to construct the full URL.
|
||||||
|
# 3. ASMTOOLS_SRC_TAG
|
||||||
|
# The SCM repository tag to use when building from source.
|
||||||
|
#
|
||||||
|
# Google Guice (required by TestNG)
|
||||||
|
# Checksum variables:
|
||||||
|
# GOOGLE_GUICE_JAR_CHECKSUM: checksum of jar
|
||||||
|
#
|
||||||
|
# 1. GOOGLE_GUICE_JAR
|
||||||
|
# The path to guice.jar.
|
||||||
|
# 2a. GOOGLE_GUICE_JAR_URL
|
||||||
|
# The full URL for the jar.
|
||||||
|
# 2b. GOOGLE_GUICE_JAR_URL_BASE + GOOGLE_GUICE_VERSION
|
||||||
|
# The individual URL components used to construct the full URL.
|
||||||
|
#
|
||||||
|
# Hamcrest (required by JUnit)
|
||||||
|
# Checksum variables:
|
||||||
|
# HAMCREST_JAR_CHECKSUM: checksum of jar
|
||||||
|
#
|
||||||
|
# 1. HAMCREST_JAR
|
||||||
|
# The path to hamcrest.jar.
|
||||||
|
# 2a. HAMCREST_JAR_URL
|
||||||
|
# The full URL for the jar.
|
||||||
|
# 2b. HAMCREST_JAR_URL_BASE + HAMCREST_VERSION
|
||||||
|
# The individual URL components used to construct the full URL.
|
||||||
|
#
|
||||||
|
# JCommander (required by TestNG)
|
||||||
|
# Checksum variables:
|
||||||
|
# JCOMMANDER_JAR_CHECKSUM: checksum of jar
|
||||||
|
#
|
||||||
|
# 1. JCOMMANDER_JAR
|
||||||
|
# The path to jcommander.jar.
|
||||||
|
# 2a. JCOMMANDER_JAR_URL
|
||||||
|
# The full URL for the jar.
|
||||||
|
# 2b. JCOMMANDER_JAR_URL_BASE + JCOMMANDER_VERSION
|
||||||
|
# The individual URL components used to construct the full URL.
|
||||||
|
#
|
||||||
|
# JCov
|
||||||
|
# Checksum variables:
|
||||||
|
# JCOV_ARCHIVE_CHECKSUM: checksum of binary archive
|
||||||
|
# JCOV_SRC_ARCHIVE_CHECKSUM: checksum of source archive
|
||||||
|
#
|
||||||
|
# 1. JCOV_JAR + JCOV_NETWORK_SAVER_JAR + JCOV_LICENSE
|
||||||
|
# The path to jcov.jar, jcov_network_saver.jar, and LICENSE respectively.
|
||||||
|
# 2a. JCOV_ARCHIVE_URL
|
||||||
|
# The full URL for the archive.
|
||||||
|
# 2b. JCOV_ARCHIVE_URL_BASE + JCOV_VERSION + JCOV_BUILD_NUMBER + JCOV_FILE
|
||||||
|
# The individual URL components used to construct the full URL.
|
||||||
|
# 3. JCOV_SRC_TAG
|
||||||
|
# The SCM repository tag to use when building from source.
|
||||||
|
#
|
||||||
|
# JDK
|
||||||
|
# Checksum variables:
|
||||||
|
# JDK_ARCHIVE_CHECKSUM: checksum of binary archive
|
||||||
|
#
|
||||||
|
# 1. JAVA_HOME
|
||||||
|
# The path to the JDK.
|
||||||
|
# 2a. JDK_ARCHIVE_URL
|
||||||
|
# The full URL for the archive.
|
||||||
|
# 2b. JDK_ARCHIVE_URL_BASE + JDK_VERSION + JDK_BUILD_NUMBER + JDK_FILE
|
||||||
|
# The individual URL components used to construct the full URL.
|
||||||
|
#
|
||||||
|
# JT Harness
|
||||||
|
# Checksum variables:
|
||||||
|
# JTHARNESS_ARCHIVE_CHECKSUM: checksum of binary archive
|
||||||
|
# JTHARNESS_SRC_ARCHIVE_CHECKSUM: checksum of source archive
|
||||||
|
#
|
||||||
|
# 1. JTHARNESS_JAVATEST_JAR + JTHARNESS_LICENSE + JTHARNESS_COPYRIGHT
|
||||||
|
# The path to javatest.jar, license.txt, and copyright.txt respectively.
|
||||||
|
# 2a. JTHARNESS_ARCHIVE_URL
|
||||||
|
# The full URL for the archive.
|
||||||
|
# 2b. JTHARNESS_ARCHIVE_URL_BASE + JTHARNESS_VERSION + JTHARNESS_BUILD_NUMBER + JTHARNESS_FILE
|
||||||
|
# The individual URL components used to construct the full URL.
|
||||||
|
# 3. JTHARNESS_SRC_TAG
|
||||||
|
# The SCM repository tag to use when building from source.
|
||||||
|
#
|
||||||
|
# JUnit (requires HamCrest)
|
||||||
|
# Checksum variables:
|
||||||
|
# JUNIT_JAR_CHECKSUM: checksum of binary archive
|
||||||
|
#
|
||||||
|
# 1. JUNIT_JAR + JUNIT_LICENSE
|
||||||
|
# The path to asmtools.jar and LICENSE respectively.
|
||||||
|
# 2a. JUNIT_JAR_URL
|
||||||
|
# The full URL for the jar.
|
||||||
|
# 2b. JUNIT_JAR_URL_BASE + JUNIT_VERSION + JUNIT_FILE
|
||||||
|
# The individual URL components used to construct the full URL.
|
||||||
|
#
|
||||||
|
# TestNG (requires JCommander, Google Guice)
|
||||||
|
# Checksum variables:
|
||||||
|
# TESTNG_JAR_CHECKSUM: checksum of binary archive
|
||||||
|
# TESTNG_LICENSE_CHECKSUM: checksum of LICENSE file
|
||||||
|
#
|
||||||
|
# 1. TESTNG_JAR + TESTNG_LICENSE
|
||||||
|
# The path to testng.jar and LICENSE.txt respectively.
|
||||||
|
# 2a. TESTNG_JAR_URL
|
||||||
|
# The full URL for the jar.
|
||||||
|
# 2b. TESTNG_JAR_URL_BASE + TESTNG_VERSION + TESTNG_FILE
|
||||||
|
# The individual URL components used to construct the full URL.
|
||||||
|
#
|
||||||
|
|
||||||
|
mydir="$(dirname ${BASH_SOURCE[0]})"
|
||||||
|
log_module="$(basename "${BASH_SOURCE[0]}")"
|
||||||
|
. "${mydir}/build-support/build-common.sh"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $0 <options> [ [--] <make-options-and-targets> ]"
|
||||||
|
echo "--help"
|
||||||
|
echo " Show this message"
|
||||||
|
echo "--jdk /path/to/jdk"
|
||||||
|
echo " Path to JDK; must be JDK 8 or higher"
|
||||||
|
echo "--quiet | -q"
|
||||||
|
echo " Reduce the logging output."
|
||||||
|
echo "--show-default-versions"
|
||||||
|
echo " Show default versions of external components"
|
||||||
|
echo "--show-config-details"
|
||||||
|
echo " Show configuration details"
|
||||||
|
echo "--skip-checksum-check"
|
||||||
|
echo " Skip the checksum check for downloaded files."
|
||||||
|
echo "--skip-download"
|
||||||
|
echo " Skip downloading files if file already available"
|
||||||
|
echo "--skip-make"
|
||||||
|
echo " Skip running 'make' (just download dependencies if needed)"
|
||||||
|
echo "--version-numbers file"
|
||||||
|
echo " Provide an alternate file containing dependency version information"
|
||||||
|
echo "--"
|
||||||
|
echo " Subsequent arguments are for 'make'"
|
||||||
|
}
|
||||||
|
|
||||||
|
ensure_arg() {
|
||||||
|
check_arguments "${FUNCNAME}" 2 $#
|
||||||
|
local option="$1"
|
||||||
|
local arg_count="$2"
|
||||||
|
if [ "$2" -lt "2" ]; then
|
||||||
|
echo "The $option option requires an argument"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
process_args() {
|
||||||
|
while [ "$#" -gt 0 ]; do
|
||||||
|
case "$1" in
|
||||||
|
--help|-h ) HELP=1 ; shift ;;
|
||||||
|
--jdk ) ensure_arg "$1" $# ; JAVA_HOME="$2" ; shift ; shift ;;
|
||||||
|
--quiet|-q ) export QUIET=1 ; shift ;;
|
||||||
|
--show-config-details ) SHOW_CONFIG_DETAILS=1 ; shift ;;
|
||||||
|
--show-default-versions ) SHOW_DEFAULT_VERSIONS=1 ; shift ;;
|
||||||
|
--skip-checksum-check ) export SKIP_CHECKSUM_CHECK=1 ; shift ;;
|
||||||
|
--skip-download ) export SKIP_DOWNLOAD=1 ; shift ;;
|
||||||
|
--skip-make ) SKIP_MAKE=1 ; shift ;;
|
||||||
|
--version-numbers ) ensure_arg "$1" $# ; VERSION_NUMBERS="$2" ; shift ; shift ;;
|
||||||
|
-- ) shift ; MAKE_ARGS="$@" ; break ;;
|
||||||
|
-* ) error "unknown option: '$1'" ; exit 1 ;;
|
||||||
|
* ) MAKE_ARGS="$@" ; break ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
process_args "$@"
|
||||||
|
|
||||||
|
if [ -n "${HELP:-}" ]; then
|
||||||
|
usage
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
. "${VERSION_NUMBERS:-${mydir}/build-support/version-numbers}"
|
||||||
|
|
||||||
|
|
||||||
|
JTREG_VERSION="${JTREG_VERSION:-}"
|
||||||
|
|
||||||
|
ANT_VERSION="${ANT_VERSION:-${DEFAULT_ANT_VERSION}}"
|
||||||
|
ANT_ARCHIVE_CHECKSUM="${ANT_ARCHIVE_CHECKSUM:-${DEFAULT_ANT_ARCHIVE_CHECKSUM}}"
|
||||||
|
|
||||||
|
ANT_JAR_VERSION="${ANT_JAR_VERSION:-${ANT_VERSION}}"
|
||||||
|
ANT_JAR_URL_BASE="${ANT_JAR_URL_BASE:-${MAVEN_REPO_URL_BASE}}"
|
||||||
|
ANT_JAR_VERSION="${ANT_JAR_VERSION:-${DEFAULT_ANT_JAR_VERSION:-${ANT_VERSION}}}"
|
||||||
|
ANT_JAR_CHECKSUM="${ANT_JAR_CHECKSUM:-${DEFAULT_ANT_JAR_CHECKSUM}}"
|
||||||
|
|
||||||
|
# Not available in Maven
|
||||||
|
ASMTOOLS_SRC_TAG="${ASMTOOLS_SRC_TAG:-${DEFAULT_ASMTOOLS_SRC_TAG}}"
|
||||||
|
ASMTOOLS_SRC_ARCHIVE_CHECKSUM="${ASMTOOLS_SRC_ARCHIVE_CHECKSUM:-${DEFAULT_ASMTOOLS_SRC_ARCHIVE_CHECKSUM}}"
|
||||||
|
|
||||||
|
GOOGLE_GUICE_VERSION="${GOOGLE_GUICE_VERSION:-${DEFAULT_GOOGLE_GUICE_VERSION}}"
|
||||||
|
GOOGLE_GUICE_JAR_URL_BASE="${GOOGLE_GUICE_JAR_URL_BASE:-${MAVEN_REPO_URL_BASE}}"
|
||||||
|
GOOGLE_GUICE_JAR_CHECKSUM="${GOOGLE_GUICE_JAR_CHECKSUM:-${DEFAULT_GOOGLE_GUICE_JAR_CHECKSUM}}"
|
||||||
|
|
||||||
|
HAMCREST_VERSION="${HAMCREST_VERSION:-${DEFAULT_HAMCREST_VERSION}}"
|
||||||
|
HAMCREST_JAR_URL_BASE="${HAMCREST_JAR_URL_BASE:-${MAVEN_REPO_URL_BASE}}"
|
||||||
|
HAMCREST_JAR_CHECKSUM="${HAMCREST_JAR_CHECKSUM:-${DEFAULT_HAMCREST_JAR_CHECKSUM}}"
|
||||||
|
|
||||||
|
JCOMMANDER_VERSION="${JCOMMANDER_VERSION:-${DEFAULT_JCOMMANDER_VERSION}}"
|
||||||
|
JCOMMANDER_JAR_URL_BASE="${JCOMMANDER_JAR_URL_BASE:-${MAVEN_REPO_URL_BASE}}"
|
||||||
|
JCOMMANDER_JAR_CHECKSUM="${JCOMMANDER_JAR_CHECKSUM:-${DEFAULT_JCOMMANDER_JAR_CHECKSUM}}"
|
||||||
|
|
||||||
|
# Not available in Maven
|
||||||
|
JCOV_SRC_TAG="${JCOV_SRC_TAG:-${DEFAULT_JCOV_SRC_TAG}}"
|
||||||
|
JCOV_SRC_ARCHIVE_CHECKSUM="${JCOV_SRC_ARCHIVE_CHECKSUM:-${DEFAULT_JCOV_SRC_ARCHIVE_CHECKSUM}}"
|
||||||
|
|
||||||
|
# Not available in Maven
|
||||||
|
JTHARNESS_SRC_TAG="${JTHARNESS_SRC_TAG:-${DEFAULT_JTHARNESS_SRC_TAG}}"
|
||||||
|
JTHARNESS_SRC_ARCHIVE_CHECKSUM="${JTHARNESS_SRC_ARCHIVE_CHECKSUM:-${DEFAULT_JTHARNESS_SRC_ARCHIVE_CHECKSUM}}"
|
||||||
|
|
||||||
|
JUNIT_VERSION="${JUNIT_VERSION:-${DEFAULT_JUNIT_VERSION}}"
|
||||||
|
JUNIT_JAR_URL_BASE="${JUNIT_JAR_URL_BASE:-${MAVEN_REPO_URL_BASE}}"
|
||||||
|
JUNIT_JAR_CHECKSUM="${JUNIT_JAR_CHECKSUM:-${DEFAULT_JUNIT_JAR_CHECKSUM}}"
|
||||||
|
JUNIT_LICENSE_FILE="${JUNIT_LICENSE_FILE:-${DEFAULT_JUNIT_LICENSE_FILE}}"
|
||||||
|
|
||||||
|
TESTNG_VERSION="${TESTNG_VERSION:-${DEFAULT_TESTNG_VERSION}}"
|
||||||
|
TESTNG_JAR_URL_BASE="${TESTNG_JAR_URL_BASE:-${MAVEN_REPO_URL_BASE}}"
|
||||||
|
TESTNG_JAR_CHECKSUM="${TESTNG_JAR_CHECKSUM:-${DEFAULT_TESTNG_JAR_CHECKSUM}}"
|
||||||
|
TESTNG_LICENSE_VERSION="${TESTNG_LICENSE_VERSION:-${DEFAULT_TESTNG_LICENSE_VERSION:-${TESTNG_VERSION}}}"
|
||||||
|
TESTNG_LICENSE_CHECKSUM="${TESTNG_LICENSE_CHECKSUM:-${DEFAULT_TESTNG_LICENSE_CHECKSUM}}"
|
||||||
|
|
||||||
|
if [ "${SHOW_DEFAULT_VERSIONS:-}" != "" ]; then
|
||||||
|
find ${mydir} -name version-numbers | \
|
||||||
|
xargs cat | \
|
||||||
|
grep -v '^#' | \
|
||||||
|
grep -E 'DEFAULT.*(_VERSION|_SRC_TAG)' | \
|
||||||
|
sort -u
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${SHOW_CONFIG_DETAILS:-}" != "" ]; then
|
||||||
|
( set -o posix ; set ) | \
|
||||||
|
grep -E '^(ANT|ASM|ASMTOOLS|GOOGLE_GUICE|HAMCREST|JCOMMANDER|JCOV|JTHARNESS|JUNIT|TESTNG)_[A-Z_]*=' | \
|
||||||
|
sort -u
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
setup_java_home() {
|
||||||
|
check_arguments "${FUNCNAME}" 0 $#
|
||||||
|
|
||||||
|
if [ -n "${JAVA_HOME:-}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${JDK_ARCHIVE_URL:-}" ]; then
|
||||||
|
if [ -n "${JDK_ARCHIVE_URL_BASE:-}" ]; then
|
||||||
|
if [ -z "${JDK_VERSION:-}" ]; then
|
||||||
|
error "JDK_VERSION not set"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -z "${JDK_BUILD_NUMBER:-}" ]; then
|
||||||
|
error "JDK_BUILD_NUMBER not set"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -z "${JDK_FILE:-}" ]; then
|
||||||
|
error "JDK_FILE not set"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
JDK_ARCHIVE_URL="${JDK_ARCHIVE_URL_BASE}/${JDK_VERSION}/${JDK_BUILD_NUMBER}/${JDK_FILE}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
local JDK_DEPS_DIR="${DEPS_DIR}"
|
||||||
|
|
||||||
|
if [ -n "${JDK_ARCHIVE_URL:-}" ]; then
|
||||||
|
local JDK_LOCAL_ARCHIVE_FILE="${DEPS_DIR}/$(basename "${JDK_ARCHIVE_URL}")"
|
||||||
|
if [ -n "${JDK_ARCHIVE_CHECKSUM:-}" ]; then
|
||||||
|
get_archive "${JDK_ARCHIVE_URL}" "${JDK_LOCAL_ARCHIVE_FILE}" "${JDK_DEPS_DIR}" "${JDK_ARCHIVE_CHECKSUM}"
|
||||||
|
else
|
||||||
|
get_archive_no_checksum "${JDK_ARCHIVE_URL}" "${JDK_LOCAL_ARCHIVE_FILE}" "${JDK_DEPS_DIR}"
|
||||||
|
fi
|
||||||
|
local JDK_JAVAC="$(find "${JDK_DEPS_DIR}" -path '*/bin/javac')"
|
||||||
|
JAVA_HOME="$(dirname $(dirname "${JDK_JAVAC}"))"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
error "None of JAVA_HOME, JDK_ARCHIVE_URL or JDK_ARCHIVE_URL_BASE are set"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
sanity_check_java_home() {
|
||||||
|
if [ -z "${JAVA_HOME:-}" ]; then
|
||||||
|
error "No JAVA_HOME set"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "${JAVA_HOME}" ]; then
|
||||||
|
error "'${JAVA_HOME}' is not a directory"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -x "${JAVA_HOME}/bin/java" ]; then
|
||||||
|
error "Could not find an executable binary at '${JAVA_HOME}/bin/java'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local version=$(${JAVA_HOME}/bin/java -version 2>&1)
|
||||||
|
local vnum=$(echo "${version}" | \
|
||||||
|
grep -e ^java -e ^openjdk |
|
||||||
|
head -n 1 | \
|
||||||
|
sed -e 's/^[^0-9]*\(1\.\)*\([1-9][0-9]*\).*/\2/' )
|
||||||
|
if [ "${vnum:-0}" -lt "8" ]; then
|
||||||
|
error "JDK 8 or newer is required to build jtreg"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
setup_java_home
|
||||||
|
sanity_check_java_home
|
||||||
|
export JAVA_HOME
|
||||||
|
info "JAVA_HOME: ${JAVA_HOME}"
|
||||||
|
|
||||||
|
#----- Ant -----
|
||||||
|
setup_ant
|
||||||
|
info "ANT: ${ANT}"
|
||||||
|
|
||||||
|
#----- Ant jar -----
|
||||||
|
setup_ant_jar() {
|
||||||
|
check_arguments "${FUNCNAME}" 0 $#
|
||||||
|
|
||||||
|
if [ -n "${ANT_JAR:-}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${ANT_JAR_URL:-}" ]; then
|
||||||
|
if [ -n "${ANT_JAR_URL_BASE:-}" ]; then
|
||||||
|
if [ -z "${ANT_JAR_VERSION:-}" ]; then
|
||||||
|
error "ANT_JAR_VERSION not set"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
ANT_JAR_URL="${ANT_JAR_URL_BASE}/org/apache/ant/ant/${ANT_JAR_VERSION}/ant-${ANT_JAR_VERSION}.jar"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
local ANT_JAR_DEPS_DIR="${DEPS_DIR}/ant-jar"
|
||||||
|
|
||||||
|
if [ -n "${ANT_JAR_URL:-}" ]; then
|
||||||
|
ANT_JAR="${ANT_JAR_DEPS_DIR}/$(basename ${ANT_JAR_URL})"
|
||||||
|
download_and_checksum "${ANT_JAR_URL}" "${ANT_JAR}" "${ANT_JAR_CHECKSUM}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
error "None of ANT_JAR, ANT_JAR_URL or ANT_JAR_URL_BASE are set"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
setup_ant_jar
|
||||||
|
info "ANT_JAR: ${ANT_JAR}"
|
||||||
|
|
||||||
|
#----- JT Harness -----
|
||||||
|
setup_jtharness_javatest_jar() {
|
||||||
|
check_arguments "${FUNCNAME}" 0 $#
|
||||||
|
|
||||||
|
if [ -n "${JTHARNESS_JAVATEST_JAR:-}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${JTHARNESS_ARCHIVE_URL:-}" ]; then
|
||||||
|
if [ -n "${JTHARNESS_ARCHIVE_URL_BASE:-}" ]; then
|
||||||
|
JTHARNESS_ARCHIVE_URL="${JTHARNESS_ARCHIVE_URL_BASE}/${JTHARNESS_VERSION}/${JTHARNESS_BUILD_NUMBER}/${JTHARNESS_FILE}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
local JTHARNESS_DEPS_DIR="${DEPS_DIR}/jtharness"
|
||||||
|
|
||||||
|
if [ -n "${JTHARNESS_ARCHIVE_URL:-}" ]; then
|
||||||
|
local JTHARNESS_LOCAL_ARCHIVE_FILE="${DEPS_DIR}/$(basename "${JTHARNESS_ARCHIVE_URL}")"
|
||||||
|
get_archive "${JTHARNESS_ARCHIVE_URL}" "${JTHARNESS_LOCAL_ARCHIVE_FILE}" "${JTHARNESS_DEPS_DIR}" "${JTHARNESS_ARCHIVE_CHECKSUM}"
|
||||||
|
JTHARNESS_JAVATEST_JAR="$(find "${JTHARNESS_DEPS_DIR}" -path '*/lib/javatest.jar')"
|
||||||
|
JTHARNESS_LICENSE="$(dirname "${JTHARNESS_JAVATEST_JAR}")/../legal/license.txt"
|
||||||
|
JTHARNESS_COPYRIGHT="$(dirname "${JTHARNESS_JAVATEST_JAR}")/../legal/copyright.txt"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
info "None of JTHARNESS_JAVATEST_JAR, JTHARNESS_ARCHIVE_URL or JTHARNESS_ARCHIVE_URL_BASE are set; building from source"
|
||||||
|
export JTHARNESS_BUILD_RESULTS_FILE="${DEPS_DIR}/jtharness.results"
|
||||||
|
(
|
||||||
|
export BUILD_DIR="${JTHARNESS_DEPS_DIR}"
|
||||||
|
export BUILD_RESULTS_FILE="${JTHARNESS_BUILD_RESULTS_FILE}"
|
||||||
|
export JTHARNESS_SRC_TAG="${JTHARNESS_SRC_TAG}"
|
||||||
|
export JTHARNESS_SRC_ARCHIVE_CHECKSUM="${JTHARNESS_SRC_ARCHIVE_CHECKSUM}"
|
||||||
|
export ANT="${ANT}"
|
||||||
|
bash "${mydir}/build-support/jtharness/build.sh"
|
||||||
|
)
|
||||||
|
ret=$?
|
||||||
|
if [ ! $ret = 0 ]; then
|
||||||
|
exit ${ret}
|
||||||
|
fi
|
||||||
|
. "${JTHARNESS_BUILD_RESULTS_FILE}"
|
||||||
|
}
|
||||||
|
setup_jtharness_javatest_jar
|
||||||
|
info "JTHARNESS_JAVATEST_JAR: ${JTHARNESS_JAVATEST_JAR}"
|
||||||
|
|
||||||
|
#----- JT Harness License and Copyright -----
|
||||||
|
setup_jtharness_license_and_copyright() {
|
||||||
|
check_arguments "${FUNCNAME}" 0 $#
|
||||||
|
|
||||||
|
if [ -n "${JTHARNESS_LICENSE:-}" -a -n "${JTHARNESS_COPYRIGHT:-}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${JTHARNESS_SRC:-}" ]; then
|
||||||
|
local JTHARNESS_SRC_DEPS_DIR="${DEPS_DIR}/jtharness-src"
|
||||||
|
local JTHARNESS_LOCAL_SRC_ARCHIVE="${JTHARNESS_SRC_DEPS_DIR}/source.zip"
|
||||||
|
get_archive "${CODE_TOOLS_URL_BASE}/jtharness/archive/${JTHARNESS_SRC_VERSION}.zip" "${JTHARNESS_LOCAL_SRC_ARCHIVE}" "${JTHARNESS_SRC_DEPS_DIR}" "${JTHARNESS_SRC_ARCHIVE_CHECKSUM}"
|
||||||
|
JTHARNESS_SRC="${JTHARNESS_SRC_DEPS_DIR}/jtharness-${JTHARNESS_SRC_VERSION}"
|
||||||
|
fi
|
||||||
|
JTHARNESS_LICENSE="${JTHARNESS_SRC}/legal/license.txt"
|
||||||
|
JTHARNESS_COPYRIGHT="${JTHARNESS_SRC}/legal/copyright.txt"
|
||||||
|
}
|
||||||
|
setup_jtharness_license_and_copyright
|
||||||
|
info "JTHARNESS_LICENSE: ${JTHARNESS_LICENSE}"
|
||||||
|
info "JTHARNESS_COPYRIGHT: ${JTHARNESS_COPYRIGHT}"
|
||||||
|
|
||||||
|
#----- JCov -----
|
||||||
|
setup_jcov() {
|
||||||
|
check_arguments "${FUNCNAME}" 0 $#
|
||||||
|
|
||||||
|
if [ -n "${JCOV_JAR:-}" -a -n "${JCOV_NETWORK_SAVER_JAR:-}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${JCOV_ARCHIVE_URL:-}" ]; then
|
||||||
|
if [ -n "${JCOV_ARCHIVE_URL_BASE:-}" ]; then
|
||||||
|
JCOV_ARCHIVE_URL="${JCOV_ARCHIVE_URL_BASE}/${JCOV_VERSION}/${JCOV_BUILD_NUMBER}/${JCOV_FILE}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
local JCOV_DEPS_DIR="${DEPS_DIR}/jcov"
|
||||||
|
|
||||||
|
if [ -n "${JTHARNESS_ARCHIVE_URL:-}" ]; then
|
||||||
|
local JCOV_LOCAL_ARCHIVE_FILE="${DEPS_DIR}/$(basename "${JCOV_ARCHIVE_URL}")"
|
||||||
|
get_archive "${JCOV_ARCHIVE_URL}" "${JCOV_LOCAL_ARCHIVE_FILE}" "${JCOV_DEPS_DIR}" "${JCOV_ARCHIVE_CHECKSUM}"
|
||||||
|
JCOV_JAR="${JCOV_DEPS_DIR}/jcov_${JCOV_VERSION}/lib/jcov.jar"
|
||||||
|
JCOV_NETWORK_SAVER_JAR="${JCOV_DEPS_DIR}/jcov_${JCOV_VERSION}/lib/jcov_network_saver.jar"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
info "None of JCOV_JAR, JCOV_ARCHIVE_URL or JCOV_ARCHIVE_URL_BASE are set; building from source"
|
||||||
|
export JCOV_BUILD_RESULTS_FILE="${DEPS_DIR}/jcov.results"
|
||||||
|
(
|
||||||
|
export BUILD_DIR="${JCOV_DEPS_DIR}"
|
||||||
|
export BUILD_RESULTS_FILE="${JCOV_BUILD_RESULTS_FILE}"
|
||||||
|
export JCOV_SRC_TAG="${JCOV_SRC_TAG}"
|
||||||
|
export JCOV_SRC_ARCHIVE_CHECKSUM="${JCOV_SRC_ARCHIVE_CHECKSUM}"
|
||||||
|
export ANT="${ANT}"
|
||||||
|
export JTHARNESS_JAVATEST_JAR="${JTHARNESS_JAVATEST_JAR}"
|
||||||
|
bash "${mydir}/build-support/jcov/build.sh"
|
||||||
|
)
|
||||||
|
ret=$?
|
||||||
|
if [ ! $ret = 0 ]; then
|
||||||
|
exit ${ret}
|
||||||
|
fi
|
||||||
|
. "${JCOV_BUILD_RESULTS_FILE}"
|
||||||
|
}
|
||||||
|
setup_jcov
|
||||||
|
info "JCOV_JAR: ${JCOV_JAR}"
|
||||||
|
info "JCOV_NETWORK_SAVER_JAR: ${JCOV_NETWORK_SAVER_JAR}"
|
||||||
|
|
||||||
|
#----- JCov License -----
|
||||||
|
# TODO: File issue to include LICENSE in the jcov binary bundle
|
||||||
|
setup_jcov_license() {
|
||||||
|
check_arguments "${FUNCNAME}" 0 $#
|
||||||
|
|
||||||
|
if [ -n "${JCOV_LICENSE:-}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${JCOV_SRC:-}" ]; then
|
||||||
|
local JCOV_SRC_DEPS_DIR="${DEPS_DIR}/jcov-src"
|
||||||
|
local JCOV_LOCAL_SRC_ARCHIVE_FILE="${JCOV_SRC_DEPS_DIR}/source.zip"
|
||||||
|
get_archive "${CODE_TOOLS_URL_BASE}/jcov/archive/${JCOV_SRC_TAG}.zip" "${JCOV_LOCAL_SRC_ARCHIVE_FILE}" "${JCOV_SRC_DEPS_DIR}" "${JCOV_SRC_ARCHIVE_CHECKSUM}"
|
||||||
|
JCOV_SRC="${JCOV_SRC_DEPS_DIR}/jcov-${JCOV_SRC_TAG}"
|
||||||
|
fi
|
||||||
|
JCOV_LICENSE="${JCOV_SRC}/LICENSE"
|
||||||
|
}
|
||||||
|
setup_jcov_license
|
||||||
|
info "JCOV_LICENSE: ${JCOV_LICENSE}"
|
||||||
|
|
||||||
|
#----- AsmTools -----
|
||||||
|
setup_asmtools() {
|
||||||
|
check_arguments "${FUNCNAME}" 0 $#
|
||||||
|
|
||||||
|
if [ -n "${ASMTOOLS_JAR:-}" -a -n "${ASMTOOLS_LICENSE:-}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${ASMTOOLS_ARCHIVE_URL:-}" ]; then
|
||||||
|
if [ -n "${ASMTOOLS_ARCHIVE_URL_BASE:-}" ]; then
|
||||||
|
if [ -z "${ASMTOOLS_VERSION:-}" ]; then
|
||||||
|
error "ASMTOOLS_VERSION not set"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -z "${ASMTOOLS_BUILD_NUMBER:-}" ]; then
|
||||||
|
error "ASMTOOLS_BUILD_NUMBER not set"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -z "${ASMTOOLS_FILE:-}" ]; then
|
||||||
|
error "ASMTOOLS_FILE not set"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
ASMTOOLS_ARCHIVE_URL="${ASMTOOLS_ARCHIVE_URL_BASE}/${ASMTOOLS_VERSION}/${ASMTOOLS_BUILD_NUMBER}/${ASMTOOLS_FILE}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
local ASMTOOLS_DEPS_DIR="${DEPS_DIR}/asmtools"
|
||||||
|
|
||||||
|
if [ -n "${ASMTOOLS_ARCHIVE_URL:-}" ]; then
|
||||||
|
local ASMTOOLS_LOCAL_ARCHIVE_FILE="${DEPS_DIR}/$(basename "${ASMTOOLS_ARCHIVE_URL}")"
|
||||||
|
get_archive "${ASMTOOLS_ARCHIVE_URL}" "${ASMTOOLS_LOCAL_ARCHIVE_FILE}" "${ASMTOOLS_DEPS_DIR}" "${ASMTOOLS_ARCHIVE_CHECKSUM}"
|
||||||
|
ASMTOOLS_JAR="$(find "${ASMTOOLS_DEPS_DIR}" -name asmtools.jar)"
|
||||||
|
ASMTOOLS_LICENSE="$(dirname "${ASMTOOLS_JAR}")/../LICENSE"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
info "None of ASMTOOLS_JAR, ASMTOOLS_ARCHIVE_URL or ASMTOOLS_ARCHIVE_URL_BASE are set; building from source"
|
||||||
|
export ASMTOOLS_BUILD_RESULTS_FILE="${DEPS_DIR}/asmtools.results"
|
||||||
|
(
|
||||||
|
export BUILD_DIR="${ASMTOOLS_DEPS_DIR}"
|
||||||
|
export BUILD_RESULTS_FILE="${ASMTOOLS_BUILD_RESULTS_FILE}"
|
||||||
|
export ANT="${ANT}"
|
||||||
|
export ASMTOOLS_SRC_TAG="${ASMTOOLS_SRC_TAG}"
|
||||||
|
bash "${mydir}/build-support/asmtools/build.sh"
|
||||||
|
)
|
||||||
|
ret=$?
|
||||||
|
if [ ! $ret = 0 ]; then
|
||||||
|
exit ${ret}
|
||||||
|
fi
|
||||||
|
. "${ASMTOOLS_BUILD_RESULTS_FILE}"
|
||||||
|
}
|
||||||
|
setup_asmtools
|
||||||
|
info "ASMTOOLS_JAR: ${ASMTOOLS_JAR}"
|
||||||
|
info "ASMTOOLS_LICENSE: ${ASMTOOLS_LICENSE}"
|
||||||
|
|
||||||
|
#----- JUnit -----
|
||||||
|
setup_junit() {
|
||||||
|
check_arguments "${FUNCNAME}" 0 $#
|
||||||
|
|
||||||
|
if [ -n "${JUNIT_JAR:-}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${JUNIT_JAR_URL:-}" ]; then
|
||||||
|
if [ -n "${JUNIT_JAR_URL_BASE:-}" ]; then
|
||||||
|
JUNIT_JAR_URL="${JUNIT_JAR_URL_BASE}/junit/junit/${JUNIT_VERSION}/junit-${JUNIT_VERSION}.jar"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
local JUNIT_DEPS_DIR="${DEPS_DIR}/junit"
|
||||||
|
|
||||||
|
if [ -n "${JUNIT_JAR_URL:-}" ]; then
|
||||||
|
JUNIT_JAR="${JUNIT_DEPS_DIR}/$(basename ${JUNIT_JAR_URL})"
|
||||||
|
download_and_checksum "${JUNIT_JAR_URL}" "${JUNIT_JAR}" "${JUNIT_JAR_CHECKSUM}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
error "None of JUNIT_JAR, JUNIT_JAR_URL or JUNIT_JAR_URL_BASE is set"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
setup_junit
|
||||||
|
info "JUNIT_JAR ${JUNIT_JAR}"
|
||||||
|
|
||||||
|
#----- JUnit license -----
|
||||||
|
setup_junit_license() {
|
||||||
|
check_arguments "${FUNCNAME}" 0 $#
|
||||||
|
|
||||||
|
if [ -n "${JUNIT_LICENSE:-}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local JUNIT_LICENSE_DEPS_DIR="${DEPS_DIR}/junit-license"
|
||||||
|
"${UNZIP_CMD}" ${UNZIP_OPTIONS} "${JUNIT_JAR}" ${JUNIT_LICENSE_FILE} -d "${JUNIT_LICENSE_DEPS_DIR}"
|
||||||
|
JUNIT_LICENSE="${JUNIT_LICENSE_DEPS_DIR}/${JUNIT_LICENSE_FILE}"
|
||||||
|
}
|
||||||
|
setup_junit_license
|
||||||
|
info "JUNIT_LICENSE: ${JUNIT_LICENSE}"
|
||||||
|
|
||||||
|
#----- TestNG -----
|
||||||
|
setup_testng() {
|
||||||
|
check_arguments "${FUNCNAME}" 0 $#
|
||||||
|
|
||||||
|
if [ -n "${TESTNG_JAR:-}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${TESTNG_JAR_URL:-}" ]; then
|
||||||
|
if [ -n "${TESTNG_JAR_URL_BASE:-}" ]; then
|
||||||
|
TESTNG_JAR_URL="${TESTNG_JAR_URL_BASE}/org/testng/testng/${TESTNG_VERSION}/testng-${TESTNG_VERSION}.jar"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
local TESTNG_DEPS_DIR="${DEPS_DIR}/testng"
|
||||||
|
|
||||||
|
if [ -n "${TESTNG_JAR_URL:-}" ]; then
|
||||||
|
TESTNG_JAR="${TESTNG_DEPS_DIR}/$(basename "${TESTNG_JAR_URL}")"
|
||||||
|
download_and_checksum "${TESTNG_JAR_URL}" "${TESTNG_JAR}" "${TESTNG_JAR_CHECKSUM}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
error "None of TESTNG_JAR, TESTNG_JAR_URL or TESTNG_JAR_URL_BASE are set"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
setup_testng
|
||||||
|
info "TESTNG_JAR: ${TESTNG_JAR}"
|
||||||
|
|
||||||
|
#----- TestNG License -----
|
||||||
|
setup_testng_license() {
|
||||||
|
check_arguments "${FUNCNAME}" 0 $#
|
||||||
|
|
||||||
|
if [ -n "${TESTNG_LICENSE:-}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local TESTNG_LICENSE_DEPS_DIR="${DEPS_DIR}/testng-license"
|
||||||
|
TESTNG_LICENSE="${TESTNG_LICENSE_DEPS_DIR}/LICENSE.txt"
|
||||||
|
download_and_checksum "https://raw.githubusercontent.com/cbeust/testng/${TESTNG_LICENSE_VERSION}/LICENSE.txt" "${TESTNG_LICENSE}" "${TESTNG_LICENSE_CHECKSUM}"
|
||||||
|
}
|
||||||
|
setup_testng_license
|
||||||
|
info "TESTNG_LICENSE: ${TESTNG_LICENSE}"
|
||||||
|
|
||||||
|
#----- JCommander (required by TestNG) -----
|
||||||
|
setup_jcommander() {
|
||||||
|
check_arguments "${FUNCNAME}" 0 $#
|
||||||
|
|
||||||
|
if [ -n "${JCOMMANDER_JAR:-}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${JCOMMANDER_JAR_URL:-}" ]; then
|
||||||
|
if [ -n "${JCOMMANDER_JAR_URL_BASE:-}" ]; then
|
||||||
|
JCOMMANDER_JAR_URL="${JCOMMANDER_JAR_URL_BASE}/com/beust/jcommander/${JCOMMANDER_VERSION}/jcommander-${JCOMMANDER_VERSION}.jar"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
local JCOMMANDER_DEPS_DIR="${DEPS_DIR}/jcommander"
|
||||||
|
|
||||||
|
if [ -n "${JCOMMANDER_JAR_URL:-}" ]; then
|
||||||
|
JCOMMANDER_JAR="${JCOMMANDER_DEPS_DIR}/$(basename "${JCOMMANDER_JAR_URL}")"
|
||||||
|
download_and_checksum "${JCOMMANDER_JAR_URL}" "${JCOMMANDER_JAR}" "${JCOMMANDER_JAR_CHECKSUM}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
error "None of JCOMMANDER_JAR, JCOMMANDER_JAR_URL or JCOMMANDER_JAR_URL_BASE are set"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
setup_jcommander
|
||||||
|
info "JCOMMANDER_JAR: ${JCOMMANDER_JAR}"
|
||||||
|
|
||||||
|
#----- Google Guice (required by TestNG) -----
|
||||||
|
setup_google_guice() {
|
||||||
|
check_arguments "${FUNCNAME}" 0 $#
|
||||||
|
|
||||||
|
if [ -n "${GOOGLE_GUICE_JAR:-}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${GOOGLE_GUICE_JAR_URL:-}" ]; then
|
||||||
|
if [ -n "${GOOGLE_GUICE_JAR_URL_BASE:-}" ]; then
|
||||||
|
GOOGLE_GUICE_JAR_URL="${GOOGLE_GUICE_JAR_URL_BASE}/com/google/inject/guice/${GOOGLE_GUICE_VERSION}/guice-${GOOGLE_GUICE_VERSION}.jar"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
local GOOGLE_GUICE_DEPS_DIR="${DEPS_DIR}/guice"
|
||||||
|
|
||||||
|
if [ -n "${GOOGLE_GUICE_JAR_URL:-}" ]; then
|
||||||
|
GOOGLE_GUICE_JAR="${GOOGLE_GUICE_DEPS_DIR}/$(basename "${GOOGLE_GUICE_JAR_URL}")"
|
||||||
|
download_and_checksum "${GOOGLE_GUICE_JAR_URL}" "${GOOGLE_GUICE_JAR}" "${GOOGLE_GUICE_JAR_CHECKSUM}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
error "None of GOOGLE_GUICE_JAR, GOOGLE_GUICE_JAR_URL or GOOGLE_GUICE_JAR_URL_BASE are set"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
setup_google_guice
|
||||||
|
info "GOOGLE_GUICE_JAR: ${GOOGLE_GUICE_JAR}"
|
||||||
|
|
||||||
|
#----- HamCrest Core (required by JUnit) -----
|
||||||
|
setup_hamcrest() {
|
||||||
|
check_arguments "${FUNCNAME}" 0 $#
|
||||||
|
|
||||||
|
if [ -n "${HAMCREST_JAR:-}" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${HAMCREST_JAR_URL:-}" ]; then
|
||||||
|
if [ -n "${HAMCREST_JAR_URL_BASE:-}" ]; then
|
||||||
|
HAMCREST_JAR_URL="${HAMCREST_JAR_URL_BASE}/org/hamcrest/hamcrest/${HAMCREST_VERSION}/hamcrest-${HAMCREST_VERSION}.jar"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
local HAMCREST_DEPS_DIR="${DEPS_DIR}/hamcrest"
|
||||||
|
|
||||||
|
if [ -n "${HAMCREST_JAR_URL:-}" ]; then
|
||||||
|
HAMCREST_JAR="${HAMCREST_DEPS_DIR}/$(basename "${HAMCREST_JAR_URL}")"
|
||||||
|
download_and_checksum "${HAMCREST_JAR_URL}" "${HAMCREST_JAR}" "${HAMCREST_JAR_CHECKSUM}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
error "None of HAMCREST_JAR, HAMCREST_JAR_URL or HAMCREST_JAR_URL_BASE are set"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
setup_hamcrest
|
||||||
|
info "HAMCREST_JAR: ${HAMCREST_JAR}"
|
||||||
|
|
||||||
|
##
|
||||||
|
# The build version typically comes from the version-numbers file;
|
||||||
|
# It is expected that the build number will typically come from an external CI system.
|
||||||
|
#
|
||||||
|
setup_build_info() {
|
||||||
|
check_arguments "${FUNCNAME}" 0 $#
|
||||||
|
|
||||||
|
JTREG_BUILD_MILESTONE="${JTREG_BUILD_MILESTONE:-dev}"
|
||||||
|
JTREG_BUILD_NUMBER="${JTREG_BUILD_NUMBER:-0}"
|
||||||
|
|
||||||
|
if [ -z "${JTREG_VERSION_STRING:-}" ]; then
|
||||||
|
MILESTONE=""
|
||||||
|
if [ -n "${JTREG_BUILD_MILESTONE}" ]; then
|
||||||
|
MILESTONE="-${JTREG_BUILD_MILESTONE}"
|
||||||
|
fi
|
||||||
|
JTREG_VERSION_STRING="${JTREG_VERSION}${MILESTONE}+${JTREG_BUILD_NUMBER}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
setup_build_info
|
||||||
|
info "JTREG_VERSION: ${JTREG_VERSION}"
|
||||||
|
info "JTREG_BUILD_NUMBER: ${JTREG_BUILD_NUMBER}"
|
||||||
|
info "JTREG_BUILD_MILESTONE: ${JTREG_BUILD_MILESTONE}"
|
||||||
|
|
||||||
|
check_file() {
|
||||||
|
check_arguments "${FUNCNAME}" 1 $#
|
||||||
|
|
||||||
|
info "Checking $1"
|
||||||
|
if [ ! -f "$1" ]; then
|
||||||
|
error "Missing: $1"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_dir() {
|
||||||
|
check_arguments "${FUNCNAME}" 1 $#
|
||||||
|
|
||||||
|
info "Checking $1"
|
||||||
|
if [ ! -d "$1" ]; then
|
||||||
|
error "Missing: $1"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_file "${ANT}"
|
||||||
|
check_file "${ANT_JAR}"
|
||||||
|
check_file "${ASMTOOLS_JAR}"
|
||||||
|
check_file "${ASMTOOLS_LICENSE}"
|
||||||
|
check_file "${GOOGLE_GUICE_JAR}"
|
||||||
|
check_file "${HAMCREST_JAR}"
|
||||||
|
check_dir "${JAVA_HOME}"
|
||||||
|
check_file "${JCOMMANDER_JAR}"
|
||||||
|
check_file "${JCOV_JAR}"
|
||||||
|
check_file "${JCOV_LICENSE}"
|
||||||
|
check_file "${JCOV_NETWORK_SAVER_JAR}"
|
||||||
|
check_file "${JTHARNESS_COPYRIGHT}"
|
||||||
|
check_file "${JTHARNESS_JAVATEST_JAR}"
|
||||||
|
check_file "${JTHARNESS_LICENSE}"
|
||||||
|
check_file "${JUNIT_JAR}"
|
||||||
|
check_file "${JUNIT_LICENSE}"
|
||||||
|
check_file "${TESTNG_JAR}"
|
||||||
|
check_file "${TESTNG_LICENSE}"
|
||||||
|
|
||||||
|
if [ -n "${SKIP_MAKE:-}" ]; then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build jtreg
|
||||||
|
cd "${ROOT}/make"
|
||||||
|
make ANT="${ANT}" \
|
||||||
|
ANT_JAR="$(mixed_path "${ANT_JAR}")" \
|
||||||
|
ASMTOOLS_JAR="${ASMTOOLS_JAR}" \
|
||||||
|
ASMTOOLS_LICENSE="${ASMTOOLS_LICENSE}" \
|
||||||
|
BUILDDIR="${BUILD_DIR}" \
|
||||||
|
BUILD_MILESTONE="${JTREG_BUILD_MILESTONE}" \
|
||||||
|
BUILD_NUMBER="${JTREG_BUILD_NUMBER}" \
|
||||||
|
BUILD_VERSION="${JTREG_VERSION}" \
|
||||||
|
BUILD_VERSION_STRING="${JTREG_VERSION_STRING}" \
|
||||||
|
GOOGLE_GUICE_JAR="${GOOGLE_GUICE_JAR}" \
|
||||||
|
HAMCREST_JAR="${HAMCREST_JAR}" \
|
||||||
|
JAVATEST_JAR="$(mixed_path "${JTHARNESS_JAVATEST_JAR}")" \
|
||||||
|
JCOMMANDER_JAR="${JCOMMANDER_JAR}" \
|
||||||
|
JCOV_JAR="${JCOV_JAR}" \
|
||||||
|
JCOV_LICENSE="${JCOV_LICENSE}" \
|
||||||
|
JCOV_NETWORK_SAVER_JAR="${JCOV_NETWORK_SAVER_JAR}" \
|
||||||
|
JDKHOME="$(mixed_path ${JAVA_HOME})" \
|
||||||
|
JTHARNESS_COPYRIGHT="${JTHARNESS_COPYRIGHT}" \
|
||||||
|
JTHARNESS_LICENSE="${JTHARNESS_LICENSE}" \
|
||||||
|
JUNIT_JAR="$(mixed_path "${JUNIT_JAR}")" \
|
||||||
|
JUNIT_LICENSE="${JUNIT_LICENSE}" \
|
||||||
|
TESTNG_JAR="$(mixed_path "${TESTNG_JAR}")" \
|
||||||
|
TESTNG_LICENSE="${TESTNG_LICENSE}" \
|
||||||
|
${MAKE_ARGS:-}
|
|
@ -0,0 +1,405 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (c) 2007, 2017, 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project name="jtreg" default="build" basedir="..">
|
||||||
|
|
||||||
|
<!-- ********** system-specific values ********************************* -->
|
||||||
|
|
||||||
|
<property file="build.properties"/> <!-- for user overrides -->
|
||||||
|
<property file="make/build.properties"/>
|
||||||
|
|
||||||
|
<!-- ********** general useful values ********************************** -->
|
||||||
|
|
||||||
|
<property environment="env"/>
|
||||||
|
|
||||||
|
<property name="src.bin.dir" location="src/share/bin"/>
|
||||||
|
<property name="src.classes.dir" location="src/share/classes"/>
|
||||||
|
<property name="src.doc.dir" location="src/share/doc"/>
|
||||||
|
<property name="test.dir" location="test"/>
|
||||||
|
<property name="build.dir" location="build"/>
|
||||||
|
<property name="build.checkstyle.dir" value="${build.dir}/checkstyle"/>
|
||||||
|
<property name="build.classes.dir" location="${build.dir}/classes" />
|
||||||
|
<property name="dist.dir" location="dist" />
|
||||||
|
<property name="dist.jtreg.dir" location="${dist.dir}/jtreg" />
|
||||||
|
<property name="dist.jtreg.zip" location="${dist.dir}/jtreg.zip" />
|
||||||
|
<property name="make.checkstyle.dir" value="make/checkstyle"/>
|
||||||
|
|
||||||
|
<patternset id="helpset">
|
||||||
|
<include name="*.hs"/>
|
||||||
|
<include name="default/**"/>
|
||||||
|
<include name="images/**"/>
|
||||||
|
</patternset>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ********** top level and shared targets *************************** -->
|
||||||
|
|
||||||
|
<target name="build" depends="dist-jtreg"
|
||||||
|
description="default build target: build jtreg for distribution"/>
|
||||||
|
|
||||||
|
<target name="clean" description="remove all generated files">
|
||||||
|
<delete dir="${build.dir}"/>
|
||||||
|
<delete dir="${dist.dir}"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- ********** init *************************************************** -->
|
||||||
|
|
||||||
|
<target name="-init">
|
||||||
|
<tstamp>
|
||||||
|
<format property="build.date" pattern="MM/dd/yyyy"/>
|
||||||
|
<format property="build.date.time" pattern="MM/dd/yyyy hh:mm aa"/>
|
||||||
|
</tstamp>
|
||||||
|
<available property="javatest.ok" file="${javatest.home}/COPYRIGHT-javatest.html"/>
|
||||||
|
<available property="jtharness.ok" file="${javatest.home}/legal/copyright.txt"/>
|
||||||
|
<available property="junit.ok" file="${junit.jar}"/>
|
||||||
|
<available property="testng.ok" file="${testng.jar}"/>
|
||||||
|
<available property="jcommander.ok" file="${jcommander.jar}"/>
|
||||||
|
<available property="asmtools.ok" file="${asmtools.jar}"/>
|
||||||
|
<condition property="jcov.ok">
|
||||||
|
<and>
|
||||||
|
<available file="${jcov.home}/lib/jcov.jar"/>
|
||||||
|
<available file="${jcov.home}/lib/jcov_network_saver.jar"/>
|
||||||
|
</and>
|
||||||
|
</condition>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- ********** jtreg ************************************************** -->
|
||||||
|
|
||||||
|
<property name="src.jtreg.help" location="${src.doc.dir}/javatest/regtest/help"/>
|
||||||
|
<property name="build.jtreg.help" location="${build.classes.dir}/com/sun/javatest/regtest/help"/>
|
||||||
|
|
||||||
|
<patternset id="jtreg.packages">
|
||||||
|
<include name="com/sun/javatest/regtest/**"/>
|
||||||
|
<include name="com/sun/javatest/diff/**"/>
|
||||||
|
<include name="com/sun/javatest/diff/**"/>
|
||||||
|
<include name="java/lang/JTRegModuleHelper.*"/>
|
||||||
|
<include name="java/lang/reflect/JTRegModuleHelper.*"/>
|
||||||
|
</patternset>
|
||||||
|
|
||||||
|
<patternset id="jtreg.jdk11.files">
|
||||||
|
<include name="com/sun/javatest/regtest/agent/AppletWrapper.java"/>
|
||||||
|
<include name="com/sun/javatest/regtest/agent/GetSystemProperty.java"/>
|
||||||
|
<include name="com/sun/javatest/regtest/agent/MainWrapper.java"/>
|
||||||
|
<include name="com/sun/javatest/regtest/agent/RStatus.java"/>
|
||||||
|
<include name="com/sun/javatest/regtest/agent/StringArray.java"/>
|
||||||
|
</patternset>
|
||||||
|
|
||||||
|
<target name="dist-jtreg"
|
||||||
|
depends="import-javatest,import-junit,import-testng,import-asmtools,import-jcov,import-jtharness,jar-jtreg,-dist-jtreg.bin,-dist-jtreg.doc,-dist-jtreg.legal"
|
||||||
|
description="build jtreg for distribution">
|
||||||
|
<zip destfile="${dist.jtreg.zip}" filesOnly="true" basedir="${dist.dir}">
|
||||||
|
<include name="jtreg/"/>
|
||||||
|
</zip>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-dist-jtreg.bin" depends="jar-jtreg,-dist-jtreg.doc">
|
||||||
|
<copy file="${src.bin.dir}/jtreg.sh" tofile="${dist.jtreg.dir}/bin/jtreg"/>
|
||||||
|
<copy file="${src.bin.dir}/jtdiff.sh" tofile="${dist.jtreg.dir}/bin/jtdiff"/>
|
||||||
|
<chmod dir="${dist.jtreg.dir}" perm="+x">
|
||||||
|
<include name="bin/jtreg"/>
|
||||||
|
<include name="bin/jtdiff"/>
|
||||||
|
</chmod>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-dist-jtreg.doc" depends="-compile-jtreg.usage">
|
||||||
|
<mkdir dir="${dist.jtreg.dir}/doc/jtreg"/>
|
||||||
|
<copy todir="${dist.jtreg.dir}" file="${src.doc.dir}/javatest/regtest/README"/>
|
||||||
|
<copy todir="${dist.jtreg.dir}/doc/jtreg">
|
||||||
|
<fileset file="${src.doc.dir}/javatest/regtest/tag-spec.html"/>
|
||||||
|
<fileset file="${build.dir}/jtreg/usage.txt"/>
|
||||||
|
</copy>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-dist-jtreg.legal">
|
||||||
|
<copy todir="${dist.jtreg.dir}" file="COPYRIGHT"/>
|
||||||
|
<copy todir="${dist.jtreg.dir}" file="LICENSE"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="jar-jtreg" depends="-init,-check-jtreg.jar" unless="jtreg.jar.ok">
|
||||||
|
<mkdir dir="${dist.jtreg.dir}/lib"/>
|
||||||
|
<jar destfile="${dist.jtreg.dir}/lib/jtreg.jar"
|
||||||
|
basedir="${build.classes.dir}" >
|
||||||
|
<manifest>
|
||||||
|
<attribute name="Built-By" value="${user.name}"/>
|
||||||
|
<attribute name="Main-Class" value="com.sun.javatest.regtest.Main"/>
|
||||||
|
<attribute name="Class-Path" value="javatest.jar jh.jar junit.jar"/>
|
||||||
|
<attribute name="jtreg-Name" value="jtreg"/>
|
||||||
|
<attribute name="jtreg-Version" value="${build.version}"/>
|
||||||
|
<attribute name="jtreg-Milestone" value="${build.milestone}"/>
|
||||||
|
<attribute name="jtreg-Build" value="${build.number}"/>
|
||||||
|
<attribute name="jtreg-BuildJavaVersion" value="${java.version}"/>
|
||||||
|
<attribute name="jtreg-BuildDate" value="${build.date.time}"/>
|
||||||
|
</manifest>
|
||||||
|
<include name="COPYRIGHT"/>
|
||||||
|
<include name="buildInfo.txt"/>
|
||||||
|
<patternset refid="jtreg.packages"/>
|
||||||
|
</jar>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-check-jtreg.jar" depends="compile-jtreg">
|
||||||
|
<dependset>
|
||||||
|
<srcfileset dir="${build.classes.dir}">
|
||||||
|
<patternset refid="jtreg.packages"/>
|
||||||
|
</srcfileset>
|
||||||
|
<targetfilelist dir="${dist.jtreg.dir}/lib" files="jtreg.jar"/>
|
||||||
|
</dependset>
|
||||||
|
<available property="jtreg.jar.ok" file="${dist.jtreg.dir}/lib/jtreg.jar"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="compile-jtreg" depends="-compile-jtreg.classes,-compile-jtreg.resources"/>
|
||||||
|
|
||||||
|
<target name="-compile-jtreg.classes">
|
||||||
|
<mkdir dir="${build.classes.dir}"/>
|
||||||
|
<javac encoding="iso-8859-1" release="8"
|
||||||
|
debug="true" debuglevel="source,lines"
|
||||||
|
srcdir="${src.classes.dir}"
|
||||||
|
destdir="${build.classes.dir}"
|
||||||
|
classpath="${build.classes.dir}:${javatest.jar}:${junit.jar}:${testng.jar}"
|
||||||
|
includeantruntime="true">
|
||||||
|
<compilerarg line="-Xlint:all"/>
|
||||||
|
<patternset refid="jtreg.packages"/>
|
||||||
|
</javac>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-compile-jtreg.usage" depends="-compile-jtreg.classes,-ant-jct.utils">
|
||||||
|
<!-- generate the usage page from the command line help -->
|
||||||
|
<!-- have to set fork=true because otherwise output redirection gets screwed up -->
|
||||||
|
<mkdir dir="${build.dir}/jtreg"/>
|
||||||
|
<java fork="true" failonerror="true"
|
||||||
|
classname="com.sun.javatest.regtest.Main" classpath="${build.classes.dir}:${javatest.jar}:${junit.jar}:${jh.jar}"
|
||||||
|
output="${build.dir}/jtreg/usage.txt">
|
||||||
|
<jvmarg value="-Dprogram=jtreg"/>
|
||||||
|
<arg value="-help"/>
|
||||||
|
<arg value="all"/>
|
||||||
|
</java>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-compile-jtreg.resources">
|
||||||
|
<copy todir="${build.classes.dir}" file="COPYRIGHT"/>
|
||||||
|
<copy todir="${build.classes.dir}">
|
||||||
|
<fileset dir="${src.classes.dir}">
|
||||||
|
<patternset refid="jtreg.packages"/>
|
||||||
|
<include name="**/*.properties"/>
|
||||||
|
<exclude name="**/*.java"/>
|
||||||
|
</fileset>
|
||||||
|
</copy>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- ********** imports ************************************************ -->
|
||||||
|
|
||||||
|
<target name="import-javatest" depends="-init,import-javahelp" if="javatest.ok">
|
||||||
|
<copy todir="${dist.jtreg.dir}/doc/javatest" file="${javatest.home}/doc/javatest/javatestGUI.pdf"/>
|
||||||
|
<copy tofile="${dist.jtreg.dir}/legal/javatest/copyright.html" file="${javatest.home}/COPYRIGHT-javatest.html"/>
|
||||||
|
<copy file="${javatest.jar}" tofile="${dist.jtreg.dir}/lib/javatest.jar"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="import-junit" depends="-init" if="junit.ok">
|
||||||
|
<copy file="${junit.jar}" tofile="${dist.jtreg.dir}/lib/junit.jar"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="import-testng" depends="-init,import-jcommander" if="testng.ok">
|
||||||
|
<copy file="${testng.jar}" tofile="${dist.jtreg.dir}/lib/testng.jar"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="import-jcommander" depends="-init" if="jcommander.ok">
|
||||||
|
<copy file="${jcommander.jar}" tofile="${dist.jtreg.dir}/lib/jcommander.jar"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="import-asmtools" depends="-init" if="asmtools.ok">
|
||||||
|
<copy file="${asmtools.jar}" tofile="${dist.jtreg.dir}/lib/asmtools.jar"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="import-jcov" depends="-init" if="jcov.ok">
|
||||||
|
<copy file="${jcov.home}/lib/jcov.jar" tofile="${dist.jtreg.dir}/lib/jcov.jar"/>
|
||||||
|
<copy file="${jcov.home}/lib/jcov_network_saver.jar" tofile="${dist.jtreg.dir}/lib/jcov_network_saver.jar"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="import-jtharness" depends="-init,import-javahelp" if="jtharness.ok">
|
||||||
|
<copy todir="${dist.jtreg.dir}/legal/jtharness" file="${javatest.home}/legal/copyright.txt"/>
|
||||||
|
<copy todir="${dist.jtreg.dir}/legal/jtharness" file="${javatest.home}/legal/license.txt"/>
|
||||||
|
<copy file="${javatest.jar}" tofile="${dist.jtreg.dir}/lib/javatest.jar"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="import-javahelp" unless="javatest.includes.javahelp.ok">
|
||||||
|
<copy file="${jh.jar}" tofile="${dist.jtreg.dir}/lib/jh.jar"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- ********** jct-utils ********************************************** -->
|
||||||
|
|
||||||
|
<target name="-ant-jct.utils" depends="-compile-jct.utils">
|
||||||
|
<taskdef name="i18ncheck" classname="com.sun.jct.utils.i18ncheck.Main$$Ant" classpath="${build.classes.dir}" />
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-compile-jct.utils">
|
||||||
|
<mkdir dir="${build.classes.dir}"/>
|
||||||
|
<javac encoding="iso-8859-1" debug="true"
|
||||||
|
srcdir="${src.classes.dir}"
|
||||||
|
destdir="${build.classes.dir}"
|
||||||
|
includeantruntime="true">
|
||||||
|
<compilerarg value="-Xlint"/>
|
||||||
|
<include name="com/sun/jct/utils/i18ncheck/**"/>
|
||||||
|
</javac>
|
||||||
|
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="test-jtreg" depends="-test-jtreg.i18n,-test-jtreg.basic"
|
||||||
|
description="execute the main jtreg tests"/>
|
||||||
|
|
||||||
|
<target name="-test-jtreg.i18n" depends="dist-jtreg,-ant-jct.utils">
|
||||||
|
<!-- have to set fork=true because otherwise output redirection gets screwed up -->
|
||||||
|
<java fork="true" jar="${dist.jtreg.dir}/lib/jtreg.jar"
|
||||||
|
output="${build.dir}/jtreg.i18n" >
|
||||||
|
<sysproperty key="javatest.i18n.log" value="com.sun.javatest.regtest"/>
|
||||||
|
<arg value="-help"/>
|
||||||
|
</java>
|
||||||
|
<i18ncheck patternFile="make/i18n.pat">
|
||||||
|
<fileset dir="${src.classes.dir}/com/sun/javatest/regtest">
|
||||||
|
<include name="**/*.properties"/>
|
||||||
|
<include name="**/*.java"/>
|
||||||
|
</fileset>
|
||||||
|
<fileset file="${build.dir}/jtreg.i18n"/>
|
||||||
|
</i18ncheck>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-test-jtreg.basic" depends="dist-jtreg">
|
||||||
|
<delete dir="${build.dir}/basic"/>
|
||||||
|
<mkdir dir="${build.dir}/basic/classes"/>
|
||||||
|
<mkdir dir="${build.dir}/basic/report"/>
|
||||||
|
<mkdir dir="${build.dir}/basic/work/scratch"/>
|
||||||
|
<javac classpath="${dist.jtreg.dir}/lib/jtreg.jar"
|
||||||
|
srcdir="${test.dir}/basic"
|
||||||
|
destdir="${build.dir}/basic/classes"
|
||||||
|
includes="Basic.java">
|
||||||
|
<compilerarg value="-Xlint"/>
|
||||||
|
</javac>
|
||||||
|
<java classpath="${dist.jtreg.dir}/lib/jtreg.jar:${build.dir}/basic/classes" classname="Basic"
|
||||||
|
fork="true" dir="${build.dir}/basic/work/scratch" >
|
||||||
|
<sysproperty key="javatest.regtest.allowTrailingBuild" value="true"/>
|
||||||
|
<arg file="${test.dir}/share/basic"></arg>
|
||||||
|
<arg file="${build.dir}/basic/report"/>
|
||||||
|
<arg file="${build.dir}/basic/work"/>
|
||||||
|
<arg file="${java.home}/.."/>
|
||||||
|
<arg value="TESTJAVAHOME=${java.home},DISPLAY=${env.DISPLAY},HOME=${user.home}"/>
|
||||||
|
<arg value="-othervm"/>
|
||||||
|
</java>
|
||||||
|
<java fork="true" jar="${dist.jtreg.dir}/lib/jtreg.jar"
|
||||||
|
output="${build.dir}/jtreg/basic/report.out">
|
||||||
|
<arg value="-reportOnly"/>
|
||||||
|
<arg value="-automatic"/>
|
||||||
|
<arg value="-verbose"/>
|
||||||
|
<arg value="-reportDir"/>
|
||||||
|
<arg file="${build.dir}/basic/report2"/>
|
||||||
|
<arg value="-workDir"/>
|
||||||
|
<arg file="${build.dir}/basic/work"/>
|
||||||
|
<arg file="${test.dir}/share/basic"></arg>
|
||||||
|
</java>
|
||||||
|
<exec executable="grep" input="${build.dir}/jtreg/basic/report.out">
|
||||||
|
<arg value="-s"/>
|
||||||
|
<arg value="Test results: passed: 92; failed: 44; error: 87"/>
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- checkstyle -->
|
||||||
|
|
||||||
|
<target name="checkstyle" depends="-def-checkstyle"
|
||||||
|
description="Generates reports for code convention violations.">
|
||||||
|
<mkdir dir="${build.checkstyle.dir}"/>
|
||||||
|
|
||||||
|
<checkstyle config="${make.checkstyle.dir}/checkstyle-jtreg.xml"
|
||||||
|
failureProperty="checkstyle.failure" failOnViolation="false">
|
||||||
|
<formatter type="xml" tofile="${build.checkstyle.dir}/checkstyle_report.xml"/>
|
||||||
|
<fileset dir="src/share/classes/" includes="**/*.java, **/*.properties"/>
|
||||||
|
</checkstyle>
|
||||||
|
|
||||||
|
<!-- transform the output to a simple html -->
|
||||||
|
<xslt in="${build.checkstyle.dir}/checkstyle_report.xml"
|
||||||
|
out="${build.checkstyle.dir}/checkstyle_report.html"
|
||||||
|
style="${checkstyle.home}/contrib/checkstyle-simple.xsl"/>
|
||||||
|
|
||||||
|
<!-- transform the output to a very simple emacs friendly text file -->
|
||||||
|
<xslt in="${build.checkstyle.dir}/checkstyle_report.xml"
|
||||||
|
out="${build.checkstyle.dir}/checkstyle_report.tmp"
|
||||||
|
style="${make.checkstyle.dir}/checkstyle-emacs.xsl"/>
|
||||||
|
|
||||||
|
<!-- beautify remove extra lines -->
|
||||||
|
<move file="${build.checkstyle.dir}/checkstyle_report.tmp"
|
||||||
|
toFile="${build.checkstyle.dir}/checkstyle_report.emacs.txt">
|
||||||
|
<filterchain>
|
||||||
|
<ignoreblank/>
|
||||||
|
<replaceregex byline="true" pattern="^File:" replace="${line.separator}File:"/>
|
||||||
|
</filterchain>
|
||||||
|
</move>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- target can be invoked from an ide, the output of which can be used
|
||||||
|
to access and fix the errors directly.-->
|
||||||
|
<target name="checkstyle-ide" depends="checkstyle">
|
||||||
|
<concat>
|
||||||
|
<fileset file="${build.checkstyle.dir}/checkstyle_report.emacs.txt"/>
|
||||||
|
</concat>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-check-checkstyle.home" depends="-def-check">
|
||||||
|
<check name="checkstyle" property="checkstyle.home" marker="${checkstyle.name.version}.jar"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-def-checkstyle" unless="checkstyle.defined" depends="-check-checkstyle.home">
|
||||||
|
<taskdef resource="checkstyletask.properties">
|
||||||
|
<classpath>
|
||||||
|
<pathelement location="${checkstyle.home}/${checkstyle.name.version}-all.jar"/>
|
||||||
|
</classpath>
|
||||||
|
</taskdef>
|
||||||
|
<property name="checkstyle.defined" value="true"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-def-check">
|
||||||
|
<macrodef name="check">
|
||||||
|
<attribute name="name"/>
|
||||||
|
<attribute name="property"/>
|
||||||
|
<attribute name="marker" default=""/>
|
||||||
|
<sequential>
|
||||||
|
<fail message="Cannot locate @{name}: please set @{property} to its location">
|
||||||
|
<condition>
|
||||||
|
<not>
|
||||||
|
<isset property="@{property}"/>
|
||||||
|
</not>
|
||||||
|
</condition>
|
||||||
|
</fail>
|
||||||
|
<fail message="@{name} is not installed in ${@{property}}">
|
||||||
|
<condition>
|
||||||
|
<and>
|
||||||
|
<not>
|
||||||
|
<equals arg1="@{marker}" arg2=""/>
|
||||||
|
</not>
|
||||||
|
<not>
|
||||||
|
<available file="${@{property}}/@{marker}"/>
|
||||||
|
</not>
|
||||||
|
</and>
|
||||||
|
</condition>
|
||||||
|
</fail>
|
||||||
|
</sequential>
|
||||||
|
</macrodef>
|
||||||
|
</target>
|
||||||
|
</project>
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||||
|
<xsl:output method="text" omit-xml-declaration="yes"/>
|
||||||
|
|
||||||
|
<xsl:template match="/">
|
||||||
|
Coding Style Check Results
|
||||||
|
--------------------------
|
||||||
|
Total files checked: <xsl:number level="any" value="count(descendant::file)"/>
|
||||||
|
Files with errors: <xsl:number level="any" value="count(descendant::file[error])"/>
|
||||||
|
Total errors: <xsl:number level="any" value="count(descendant::error)"/>
|
||||||
|
Errors per file: <xsl:number level="any" value="count(descendant::error) div count(descendant::file)"/>
|
||||||
|
<xsl:apply-templates/>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="file[error]">
|
||||||
|
<xsl:apply-templates select="error"/>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="error">
|
||||||
|
<xsl:value-of select="../@name"/>:<xsl:value-of select="@line"/><xsl:text>: </xsl:text><xsl:value-of select="@message"/><xsl:text>
|
||||||
|
</xsl:text>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
</xsl:stylesheet>
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE module PUBLIC
|
||||||
|
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||||
|
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Checks for initial jtreg code conventions, we are starting with
|
||||||
|
imports and import orders and this will grow to encompass other
|
||||||
|
violations over time.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<module name="Checker">
|
||||||
|
|
||||||
|
<!-- Checks for whitespace. -->
|
||||||
|
<module name="FileTabCharacter">
|
||||||
|
<property name="fileExtensions" value=".java"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<!-- Miscellaneous other checks. -->
|
||||||
|
<module name="RegexpSingleline">
|
||||||
|
<property name="format" value="\s+$"/>
|
||||||
|
<property name="minimum" value="0"/>
|
||||||
|
<property name="maximum" value="0"/>
|
||||||
|
<property name="message" value="Line has trailing spaces."/>
|
||||||
|
<property name="fileExtensions" value=".java .html"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<module name="TreeWalker">
|
||||||
|
<!-- Checks for imports -->
|
||||||
|
<!--
|
||||||
|
<module name="AvoidStarImport"/>
|
||||||
|
<module name="IllegalImport"/>
|
||||||
|
-->
|
||||||
|
<module name="GenericWhitespace"/>
|
||||||
|
<module name="RedundantImport"/>
|
||||||
|
<module name="UnusedImports"/>
|
||||||
|
<module name="ImportOrder">
|
||||||
|
<property name="groups" value="java, javax, org, com"/>
|
||||||
|
<property name="ordered" value="true"/>
|
||||||
|
<property name="separated" value="true"/>
|
||||||
|
</module>
|
||||||
|
<module name="EmptyForInitializerPad">
|
||||||
|
<property name="option" value="space"/>
|
||||||
|
</module>
|
||||||
|
<module name="WhitespaceAfter"/>
|
||||||
|
</module>
|
||||||
|
</module>
|
|
@ -0,0 +1,37 @@
|
||||||
|
# Patterns for recognizing i18n strings in source code
|
||||||
|
# Each line is of the form
|
||||||
|
# regexp keys
|
||||||
|
# If the regexp matches within a line of source text, the keys give the
|
||||||
|
# names of the implied i18n keys. Use the standard \int syntax for referring
|
||||||
|
# to capture groups within the regexp. Note the regular expression should
|
||||||
|
# not contain space characters. If necessary, use \s to match space.
|
||||||
|
# For spec of regular expressions, see java.util.regex.Pattern
|
||||||
|
# See also com.sun.jct.utils.i18ncheck.Main
|
||||||
|
|
||||||
|
# i18n.getString("...",
|
||||||
|
(printMessage|getI18NString|writeI18N|i18n.getString|formatI18N|setI18NTitle)\("([^"]*)"(,|\)) \2
|
||||||
|
|
||||||
|
# new BadArgs(i18n, "...",
|
||||||
|
(Message.get|Fault|BadArgs|BadValue|println|printErrorMessage|printMessage|[eE]rror|showMessage|popupError|write|JavaTestError|\.log|super)\((msgs|i18n),\s"([^"]*)"(,|\)) \3
|
||||||
|
|
||||||
|
# uif.createMessageArea("...",
|
||||||
|
uif.createMessageArea\("([^"]*)"(,|\)) \1.txt
|
||||||
|
|
||||||
|
# uif.showXXYZDialog("...",
|
||||||
|
uif.show(YesNo|YesNoCancel|OKCancel|Information|CustomInfo)Dialog\("([^"]*)"(,|\)) \2.txt \2.title
|
||||||
|
|
||||||
|
# uif.showWaitDialog("...",
|
||||||
|
uif.createWaitDialog\("([^"]*)"(,|\)) \1.txt \1.title \1.desc \1.name
|
||||||
|
|
||||||
|
# showError("...",
|
||||||
|
showError\("([^"]*)"(,|\)) \1.err
|
||||||
|
|
||||||
|
# new FileType()
|
||||||
|
new\sFileType\(\) filetype.allFiles
|
||||||
|
|
||||||
|
# new FileType("...")
|
||||||
|
new\sFileType\("([^"]*)"\) filetype\1
|
||||||
|
|
||||||
|
# i18n: ...
|
||||||
|
i18n:\s*(\S+) \1
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 1999, 2016, 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# compile com.sun.javatest.diff
|
||||||
|
|
||||||
|
JAVAFILES.com.sun.javatest.diff := \
|
||||||
|
$(shell $(FIND) $(JAVADIR)/com/sun/javatest/diff -name \*.java )
|
||||||
|
|
||||||
|
$(BUILDDIR)/classes.com.sun.javatest.diff.ok: \
|
||||||
|
$(JAVAFILES.com.sun.javatest.diff) \
|
||||||
|
$(BUILDDIR)/classes.com.sun.javatest.regtest.ok
|
||||||
|
CLASSPATH="$(CLASSDIR)$(PS)$(JAVATEST_JAR)$(PS)$(ANT_JAR)" \
|
||||||
|
$(REGTEST_TOOL_JAVAC) $(REGTEST_TOOL_JAVAC_OPTIONS) \
|
||||||
|
-d $(CLASSDIR) \
|
||||||
|
-encoding ISO8859-1 \
|
||||||
|
$(JAVAFILES.com.sun.javatest.diff)
|
||||||
|
echo "classes built at `date`" > $@
|
||||||
|
|
||||||
|
TARGETS.com.sun.javatest.diff += $(BUILDDIR)/classes.com.sun.javatest.diff.ok
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# resources required for com.sun.javatest.diff
|
||||||
|
|
||||||
|
RESOURCES.com.sun.javatest.diff = \
|
||||||
|
$(CLASSDIR)/com/sun/javatest/diff/i18n.properties
|
||||||
|
|
||||||
|
TARGETS.com.sun.javatest.diff += $(RESOURCES.com.sun.javatest.diff)
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# include jtdiff in jtreg.jar
|
||||||
|
|
||||||
|
PKGS.JAR.jtreg += com.sun.javatest.diff
|
||||||
|
TARGETS.JAR.jtreg += $(TARGETS.com.sun.javatest.diff)
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# executable scripts
|
||||||
|
|
||||||
|
$(JTREG_IMAGEDIR)/bin/jtdiff: $(SRCSHAREBINDIR)/jtdiff.sh
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(RM) $@
|
||||||
|
$(CP) $< $@
|
||||||
|
$(CHMOD) a+x,a-w $@
|
||||||
|
|
||||||
|
TARGETS.ZIP.jtreg += \
|
||||||
|
$(JTREG_IMAGEDIR)/bin/jtdiff
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
TESTS += $(TESTS.jtdiff)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,460 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 1999, 2018, 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# compile com.sun.javatest.regtest
|
||||||
|
|
||||||
|
### The following files are required to run othervm tests
|
||||||
|
|
||||||
|
REGTEST-OTHERVM-CLASSES = AppletWrapper GetSystemProperty MainWrapper AStatus StringArray
|
||||||
|
JAVAFILES.com.sun.javatest.regtest-othervm = \
|
||||||
|
$(REGTEST-OTHERVM-CLASSES:%=$(JAVADIR)/com/sun/javatest/regtest/agent/%.java)
|
||||||
|
|
||||||
|
# TODO: set -bootclasspath to JDK 1.1 classes?
|
||||||
|
$(BUILDDIR)/classes.com.sun.javatest.regtest-othervm.ok: \
|
||||||
|
$(JAVAFILES.com.sun.javatest.regtest-othervm) \
|
||||||
|
$(call PosixPath,$(JAVATEST_JAR))
|
||||||
|
$(MKDIR) -p $(CLASSDIR)
|
||||||
|
CLASSPATH="$(CLASSDIR)$(PS)$(JAVATEST_JAR)" \
|
||||||
|
$(REGTEST_OLD_JAVAC) $(REGTEST_OLD_JAVAC_OPTIONS) \
|
||||||
|
-d $(CLASSDIR) \
|
||||||
|
-encoding ISO8859-1 \
|
||||||
|
$(JAVAFILES.com.sun.javatest.regtest-othervm)
|
||||||
|
echo "classes built at `date`" > $@
|
||||||
|
|
||||||
|
### The following files are required to run agentvm tests, as far back as JDK 1.5
|
||||||
|
|
||||||
|
JAVAFILES.com.sun.javatest.regtest-agentvm := \
|
||||||
|
$(filter-out $(JAVAFILES.com.sun.javatest.regtest-othervm), $(shell $(FIND) $(JAVADIR)/com/sun/javatest/regtest/agent -name \*.java ))
|
||||||
|
|
||||||
|
$(BUILDDIR)/classes.com.sun.javatest.regtest.agent.ok: \
|
||||||
|
$(JAVAFILES.com.sun.javatest.regtest-agentvm) \
|
||||||
|
$(BUILDDIR)/classes.com.sun.javatest.regtest-othervm.ok
|
||||||
|
CLASSPATH="$(CLASSDIR)$(PS)$(JAVATEST_JAR)$(PS)$(JUNIT_JAR)$(PS)$(TESTNG_JAR)" \
|
||||||
|
$(REGTEST_AGENT_JAVAC) $(REGTEST_AGENT_JAVAC_OPTIONS) \
|
||||||
|
-d $(CLASSDIR) \
|
||||||
|
-encoding ISO8859-1 \
|
||||||
|
$(JAVAFILES.com.sun.javatest.regtest-agentvm)
|
||||||
|
echo "classes built at `date`" > $@
|
||||||
|
|
||||||
|
### The following files are for the jtreg and jtdiff tools
|
||||||
|
|
||||||
|
JAVAFILES.com.sun.javatest.regtest-tools := \
|
||||||
|
$(shell $(FIND) $(JAVADIR)/com/sun/javatest/regtest -name agent -prune -o -name \*.java -print )
|
||||||
|
|
||||||
|
$(BUILDDIR)/classes.com.sun.javatest.regtest.ok: \
|
||||||
|
$(JAVAFILES.com.sun.javatest.regtest-tools) \
|
||||||
|
$(BUILDDIR)/classes.com.sun.javatest.regtest.agent.ok
|
||||||
|
CLASSPATH="$(CLASSDIR)$(PS)$(ANT_JAR)$(PS)$(JAVATEST_JAR)$(PS)$(JUNIT_JAR)$(PS)$(TESTNG_JAR)" \
|
||||||
|
$(REGTEST_TOOL_JAVAC) $(REGTEST_TOOL_JAVAC_OPTIONS) \
|
||||||
|
-d $(CLASSDIR) \
|
||||||
|
-encoding ISO8859-1 \
|
||||||
|
$(JAVAFILES.com.sun.javatest.regtest-tools)
|
||||||
|
echo "classes built at `date`" > $@
|
||||||
|
|
||||||
|
TARGETS.com.sun.javatest.regtest += $(BUILDDIR)/classes.com.sun.javatest.regtest.ok
|
||||||
|
|
||||||
|
|
||||||
|
JAVAFILES.java.lang := \
|
||||||
|
$(JAVADIR)/java/lang/JTRegModuleHelper.java
|
||||||
|
|
||||||
|
$(BUILDDIR)/classes.java.lang.ok: \
|
||||||
|
$(JAVAFILES.java.lang)
|
||||||
|
CLASSPATH= \
|
||||||
|
$(REGTEST_TOOL_JAVAC) $(REGTEST_TOOL_JAVAC_OPTIONS) $(REGTEST_TOOL_PATCH_JAVA_BASE_OPTIONS) \
|
||||||
|
-d $(CLASSDIR) \
|
||||||
|
-encoding ISO8859-1 \
|
||||||
|
$(JAVAFILES.java.lang)
|
||||||
|
echo "classes built at `date`" > $@
|
||||||
|
|
||||||
|
TARGETS.com.sun.javatest.regtest += $(BUILDDIR)/classes.java.lang.ok
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# resources required for com.sun.javatest.regtest
|
||||||
|
|
||||||
|
RESOURCES.com.sun.javatest.regtest = \
|
||||||
|
$(CLASSDIR)/com/sun/javatest/regtest/i18n.properties \
|
||||||
|
$(CLASSDIR)/com/sun/javatest/regtest/config/i18n.properties \
|
||||||
|
$(CLASSDIR)/com/sun/javatest/regtest/report/i18n.properties \
|
||||||
|
$(CLASSDIR)/com/sun/javatest/regtest/tool/i18n.properties \
|
||||||
|
$(CLASSDIR)/com/sun/javatest/regtest/tool/jtlogo.png
|
||||||
|
|
||||||
|
TARGETS.com.sun.javatest.regtest += $(RESOURCES.com.sun.javatest.regtest)
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Misc. doc files
|
||||||
|
|
||||||
|
JTREG_COPYRIGHT = $(JTREG_IMAGEDIR)/COPYRIGHT
|
||||||
|
JTREG_LICENSE = $(JTREG_IMAGEDIR)/LICENSE
|
||||||
|
JTREG_README = $(JTREG_IMAGEDIR)/README
|
||||||
|
JTREG_FAQ = $(JTREG_IMAGEDIR)/doc/jtreg/faq.html
|
||||||
|
JTREG_TAGSPEC = $(JTREG_IMAGEDIR)/doc/jtreg/tag-spec.html
|
||||||
|
JTREG_USAGE = $(JTREG_IMAGEDIR)/doc/jtreg/usage.txt
|
||||||
|
|
||||||
|
JTREG_DOCS = \
|
||||||
|
$(JTREG_COPYRIGHT) \
|
||||||
|
$(JTREG_FAQ) \
|
||||||
|
$(JTREG_LICENSE) \
|
||||||
|
$(JTREG_README) \
|
||||||
|
$(JTREG_TAGSPEC) \
|
||||||
|
$(JTREG_USAGE)
|
||||||
|
|
||||||
|
$(JTREG_COPYRIGHT): $(TOPDIR)/COPYRIGHT
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(RM) $@
|
||||||
|
$(CP) $< $@
|
||||||
|
|
||||||
|
$(JTREG_FAQ): $(SRCJTREGDOCDIR)/faq.md \
|
||||||
|
$(SRCJTREGDOCDIR)/faq-local-style.html \
|
||||||
|
$(SRCJTREGDOCDIR)/faq-intro.html
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(ECHO) '/<header>/{;:a;N;/<\/header>/!ba;};/<h1 class="title">/d' | tr ';' '\n' > $(BUILDDIR)/fixupheader
|
||||||
|
$(PANDOC) \
|
||||||
|
--standalone \
|
||||||
|
--include-in-header $(SRCJTREGDOCDIR)/faq-local-style.html \
|
||||||
|
--include-before $(SRCJTREGDOCDIR)/faq-intro.html \
|
||||||
|
--toc \
|
||||||
|
--to html5 \
|
||||||
|
--number-sections \
|
||||||
|
$(SRCJTREGDOCDIR)/faq.md | \
|
||||||
|
$(SED) \
|
||||||
|
-e 's/^code > span\.\([a-z][a-z] .*\)/code span.\1/' \
|
||||||
|
-e 's/-section-number">0./-section-number">/' \
|
||||||
|
-e 's/…/\…/g' \
|
||||||
|
-e 's/™/\™/g' \
|
||||||
|
-f $(BUILDDIR)/fixupheader \
|
||||||
|
> $(JTREG_FAQ)
|
||||||
|
|
||||||
|
|
||||||
|
$(JTREG_README): $(SRCJTREGDOCDIR)/README
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(RM) $@
|
||||||
|
$(CP) $< $@
|
||||||
|
|
||||||
|
$(JTREG_TAGSPEC): $(JTREG_IMAGEDIR)/doc/jtreg/%: $(SRCJTREGDOCDIR)/%
|
||||||
|
$(RM) $@
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(CP) $^ $@
|
||||||
|
|
||||||
|
$(JTREG_USAGE): $(BUILDDIR)/jtreg-usage.txt
|
||||||
|
$(CP) $^ $@
|
||||||
|
|
||||||
|
$(JTREG_LICENSE): $(TOPDIR)/LICENSE
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(CP) $^ $@
|
||||||
|
|
||||||
|
$(BUILDDIR)/jtreg-usage.txt: \
|
||||||
|
$(BUILDDIR)/classes.com.sun.javatest.regtest.ok \
|
||||||
|
$(BUILDDIR)/classes/com/sun/javatest/regtest/tool/i18n.properties
|
||||||
|
$(JDKJAVA) -cp "$(CLASSDIR)$(PS)$(JAVATEST_JAR)" \
|
||||||
|
-Dprogram=jtreg com.sun.javatest.regtest.Main -help all > $@
|
||||||
|
|
||||||
|
TARGETS.ZIP.jtreg += $(JTREG_DOCS)
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
ifdef JAVATEST_SRCDIR
|
||||||
|
JAVATEST_SRCFILES= \
|
||||||
|
$(JAVATEST_SRCDIR)/com/sun/javatest/InterviewParameters.java \
|
||||||
|
$(JAVATEST_SRCDIR)/com/sun/javatest/Parameters.java \
|
||||||
|
$(JAVATEST_SRCDIR)/com/sun/javatest/Status.java \
|
||||||
|
$(JAVATEST_SRCDIR)/com/sun/javatest/TestDescription.java \
|
||||||
|
$(JAVATEST_SRCDIR)/com/sun/javatest/TestResult.java \
|
||||||
|
$(JAVATEST_SRCDIR)/com/sun/javatest/TestResultTable.java \
|
||||||
|
$(JAVATEST_SRCDIR)/com/sun/javatest/WorkDirectory.java
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(JTREG_IMAGEDIR)/doc/api/index.html: \
|
||||||
|
$(JAVAFILES.com.sun.javatest.regtest-tools) \
|
||||||
|
$(JAVATEST_SRCFILES)
|
||||||
|
$(JDKHOME)/bin/javadoc -d $(@D) \
|
||||||
|
-encoding iso-8859-1 \
|
||||||
|
-sourcepath "$(JAVADIR)$(PS)$(JAVATEST_SRCDIR)" \
|
||||||
|
-classpath "$(ANT_JAR)$(PS)$(JAVATEST_JAR)$(PS)$(JUNIT_JAR)$(PS)$(TESTNG_JAR)" \
|
||||||
|
com.sun.javatest.regtest \
|
||||||
|
$(JAVATEST_SRCFILES)
|
||||||
|
|
||||||
|
$(JTREG_IMAGEDIR)/doc/devapi/index.html: \
|
||||||
|
$(JAVAFILES.com.sun.javatest.regtest-tools) \
|
||||||
|
$(JAVATEST_SRCFILES)
|
||||||
|
$(JDKHOME)/bin/javadoc -d $(@D) \
|
||||||
|
-encoding iso-8859-1 \
|
||||||
|
-sourcepath "$(JAVADIR)$(PS)$(JAVATEST_SRCDIR)" \
|
||||||
|
-classpath "$(ANT_JAR)$(PS)$(JAVATEST_JAR)$(PS)$(JUNIT_JAR)$(PS)$(TESTNG_JAR)" \
|
||||||
|
-subpackages com.sun.javatest.regtest \
|
||||||
|
-tag "implNote:a:Implementation Note:" \
|
||||||
|
$(JAVATEST_SRCFILES)
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# create jtreg.jar
|
||||||
|
|
||||||
|
PKGS.JAR.jtreg += \
|
||||||
|
com.sun.javatest.regtest \
|
||||||
|
com.sun.javatest.regtest.agent \
|
||||||
|
com.sun.javatest.regtest.config \
|
||||||
|
com.sun.javatest.regtest.exec \
|
||||||
|
com.sun.javatest.regtest.report \
|
||||||
|
com.sun.javatest.regtest.tool \
|
||||||
|
com.sun.javatest.regtest.util \
|
||||||
|
java.lang
|
||||||
|
TARGETS.JAR.jtreg += $(TARGETS.com.sun.javatest.regtest)
|
||||||
|
|
||||||
|
$(JTREG_IMAGEDIR)/lib/jtreg.jar: JAR_MAINCLASS = com.sun.javatest.regtest.Main
|
||||||
|
|
||||||
|
$(JTREG_IMAGEDIR)/lib/jtreg.jar: JAR_CLASSPATH = javatest.jar asmtools.jar
|
||||||
|
|
||||||
|
$(JTREG_IMAGEJARDIR)/jtreg.jar: \
|
||||||
|
$(JTREG_IMAGEDIR)/lib/javatest.jar \
|
||||||
|
$(TARGETS.JAR.jtreg)
|
||||||
|
|
||||||
|
ifdef JAVAHELP_JAR
|
||||||
|
$(JTREG_IMAGEJARDIR)/jtreg.jar: \
|
||||||
|
$(JTREG_IMAGEJARDIR)/jh.jar
|
||||||
|
endif
|
||||||
|
|
||||||
|
TARGETS.ZIP.jtreg += $(JTREG_IMAGEJARDIR)/jtreg.jar
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# import JavaTest or JT Harness
|
||||||
|
|
||||||
|
TARGETS.com.sun.javatest.regtest += $(RESOURCES.com.sun.javatest.regtest)
|
||||||
|
|
||||||
|
$(JTREG_IMAGEDIR)/lib/javatest.jar: $(call PosixPath,$(JAVATEST_JAR))
|
||||||
|
$(RM) -f $@
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(CP) $< $@
|
||||||
|
|
||||||
|
TARGETS.ZIP.jtreg += $(JTREG_IMAGEJARDIR)/javatest.jar
|
||||||
|
|
||||||
|
$(JTREG_IMAGEDIR)/legal/jtharness/license.txt: $(call PosixPath,$(JTHARNESS_LICENSE))
|
||||||
|
$(RM) -f $@
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(CP) $< $@
|
||||||
|
|
||||||
|
ifdef JTHARNESS_LICENSE
|
||||||
|
TARGETS.ZIP.jtreg += $(JTREG_IMAGEDIR)/legal/jtharness/license.txt
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(JTREG_IMAGEDIR)/legal/jtharness/copyright.txt: $(call PosixPath,$(JTHARNESS_COPYRIGHT))
|
||||||
|
$(RM) -f $@
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(CP) $< $@
|
||||||
|
|
||||||
|
ifdef JTHARNESS_COPYRIGHT
|
||||||
|
TARGETS.ZIP.jtreg += $(JTREG_IMAGEDIR)/legal/jtharness/copyright.txt
|
||||||
|
endif
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# import JUnit
|
||||||
|
|
||||||
|
$(JTREG_IMAGEDIR)/lib/junit.jar: $(call PosixPath,$(JUNIT_JAR))
|
||||||
|
$(RM) -f $@
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(CP) $< $@
|
||||||
|
|
||||||
|
TARGETS.ZIP.jtreg += $(JTREG_IMAGEJARDIR)/junit.jar
|
||||||
|
|
||||||
|
ifdef JUNIT_LICENSE
|
||||||
|
TARGETS.ZIP.jtreg += $(JTREG_IMAGEDIR)/legal/junit/LICENSE
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(JTREG_IMAGEDIR)/legal/junit/LICENSE: $(call PosixPath,$(JUNIT_LICENSE))
|
||||||
|
$(RM) -f $@
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(CP) $< $@
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# import TestNG
|
||||||
|
|
||||||
|
$(JTREG_IMAGEDIR)/lib/testng.jar: $(call PosixPath,$(TESTNG_JAR))
|
||||||
|
$(RM) $@
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(CP) $(TESTNG_JAR) $@
|
||||||
|
jquery=`$(JAR) tf $@ | $(GREP) 'jquery.*.js'` ; \
|
||||||
|
if [ -n "$$jquery" ]; then \
|
||||||
|
$(RM) $(BUILDDIR)/$$jquery ; $(MKDIR) -p `dirname $(BUILDDIR)/$$jquery` ; $(TOUCH) $(BUILDDIR)/$$jquery ; \
|
||||||
|
$(JAR) uf $@ -C $(BUILDDIR) $$jquery ; \
|
||||||
|
fi
|
||||||
|
- $(ZIP) -d $@ Version.java
|
||||||
|
|
||||||
|
TARGETS.ZIP.jtreg += $(JTREG_IMAGEJARDIR)/testng.jar
|
||||||
|
|
||||||
|
$(JTREG_IMAGEDIR)/lib/jcommander.jar: $(call PosixPath,$(JCOMMANDER_JAR))
|
||||||
|
$(RM) $@
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(CP) $(JCOMMANDER_JAR) $@
|
||||||
|
|
||||||
|
ifdef JCOMMANDER_JAR
|
||||||
|
TARGETS.ZIP.jtreg += $(JTREG_IMAGEJARDIR)/jcommander.jar
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(JTREG_IMAGEDIR)/lib/guice.jar: $(call PosixPath,$(GOOGLE_GUICE_JAR))
|
||||||
|
$(RM) $@
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(CP) $(GOOGLE_GUICE_JAR) $@
|
||||||
|
|
||||||
|
ifdef GOOGLE_GUICE_JAR
|
||||||
|
TARGETS.ZIP.jtreg += $(JTREG_IMAGEJARDIR)/guice.jar
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(JTREG_IMAGEDIR)/lib/hamcrest.jar: $(call PosixPath,$(HAMCREST_JAR))
|
||||||
|
$(RM) $@
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(CP) $(HAMCREST_JAR) $@
|
||||||
|
|
||||||
|
ifdef HAMCREST_JAR
|
||||||
|
TARGETS.ZIP.jtreg += $(JTREG_IMAGEJARDIR)/hamcrest.jar
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(JTREG_IMAGEDIR)/legal/testng/LICENSE: $(call PosixPath,$(TESTNG_LICENSE))
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(CP) $< $@
|
||||||
|
|
||||||
|
ifdef TESTNG_LICENSE
|
||||||
|
TARGETS.ZIP.jtreg += $(JTREG_IMAGEDIR)/legal/testng/LICENSE
|
||||||
|
endif
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# import JCov
|
||||||
|
|
||||||
|
$(JTREG_IMAGEDIR)/lib/jcov.jar: $(call PosixPath,$(JCOV_JAR))
|
||||||
|
$(RM) $@
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(CP) $< $@
|
||||||
|
|
||||||
|
ifdef JCOV_JAR
|
||||||
|
TARGETS.ZIP.jtreg += $(JTREG_IMAGEDIR)/lib/jcov.jar
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(JTREG_IMAGEDIR)/lib/jcov_network_saver.jar: $(call PosixPath,$(JCOV_NETWORK_SAVER_JAR))
|
||||||
|
$(RM) $@
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(CP) $< $@
|
||||||
|
|
||||||
|
ifdef JCOV_NETWORK_SAVER_JAR
|
||||||
|
TARGETS.ZIP.jtreg += $(JTREG_IMAGEDIR)/lib/jcov_network_saver.jar
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(JTREG_IMAGEDIR)/legal/jcov/LICENSE: $(call PosixPath,$(JCOV_LICENSE))
|
||||||
|
$(RM) -f $@
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(CP) $< $@
|
||||||
|
|
||||||
|
ifdef JCOV_LICENSE
|
||||||
|
TARGETS.ZIP.jtreg += $(JTREG_IMAGEDIR)/legal/jcov/LICENSE
|
||||||
|
endif
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# import AsmTools
|
||||||
|
|
||||||
|
$(JTREG_IMAGEDIR)/lib/asmtools.jar: $(call PosixPath,$(ASMTOOLS_JAR))
|
||||||
|
$(RM) $@
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(CP) $< $@
|
||||||
|
|
||||||
|
ifdef ASMTOOLS_JAR
|
||||||
|
TARGETS.ZIP.jtreg += $(JTREG_IMAGEDIR)/lib/asmtools.jar
|
||||||
|
$(JTREG_IMAGEDIR)/lib/jtreg.jar: $(JTREG_IMAGEDIR)/lib/asmtools.jar
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(JTREG_IMAGEDIR)/legal/asmtools/LICENSE: $(call PosixPath,$(ASMTOOLS_LICENSE))
|
||||||
|
$(RM) -f $@
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(CP) $< $@
|
||||||
|
|
||||||
|
ifdef ASMTOOLS_LICENSE
|
||||||
|
TARGETS.ZIP.jtreg += $(JTREG_IMAGEDIR)/legal/asmtools/LICENSE
|
||||||
|
endif
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# executable scripts
|
||||||
|
|
||||||
|
$(JTREG_IMAGEDIR)/bin/jtreg: $(SRCSHAREBINDIR)/jtreg.sh
|
||||||
|
$(MKDIR) -p $(@D)
|
||||||
|
$(RM) $@
|
||||||
|
$(CP) $< $@
|
||||||
|
$(CHMOD) a+x,a-w $@
|
||||||
|
|
||||||
|
TARGETS.ZIP.jtreg += \
|
||||||
|
$(JTREG_IMAGEDIR)/bin/jtreg
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# release info
|
||||||
|
|
||||||
|
# based on code in OpenJDK make/SourceRevision.gmk
|
||||||
|
ID_COMMAND := $(PRINTF) "git:%s%s\n" \
|
||||||
|
"$$(git log -n1 --format=%H | cut -c1-12)" \
|
||||||
|
"$$(if test -n "$$(git status --porcelain)"; then printf '+'; fi)"
|
||||||
|
|
||||||
|
$(JTREG_IMAGEDIR)/release:
|
||||||
|
echo "JTREG_VERSION=$(BUILD_VERSION) $(BUILD_NUMBER)" > $@
|
||||||
|
echo "BUILD_DATE=`/bin/date +'%B %d, %Y'`" >> $@
|
||||||
|
if [ -r $(TOPDIR)/.git ]; then \
|
||||||
|
echo "SOURCE=$$($(ID_COMMAND))" >> $@ ; \
|
||||||
|
elif [ -r $(TOPDIR)/.src-rev ]; then \
|
||||||
|
echo "SOURCE=\"$$($(CAT) $(TOPDIR)/.src-rev | $(SED) -e 's/:/:git:/' -e 's/ *$$//')\"" >> $@ ; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
TARGETS.ZIP.jtreg += \
|
||||||
|
$(JTREG_IMAGEDIR)/release
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# create jtreg.zip bundles
|
||||||
|
|
||||||
|
JTREG_ZIP = $(IMAGES_DIR)/jtreg.zip
|
||||||
|
|
||||||
|
$(JTREG_ZIP): $(TARGETS.ZIP.jtreg)
|
||||||
|
$(RM) $@
|
||||||
|
cd $(IMAGES_DIR); $(ZIP) -rq $@ $(@F:%.zip=%)
|
||||||
|
|
||||||
|
JTREG_ZIPFILES = $(JTREG_ZIP)
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUILDFILES += $(JTREG_ZIPFILES)
|
||||||
|
|
||||||
|
VERBOSEZIPFILES += $(JTREG_ZIPFILES:%.zip=%-$(VERBOSE_ZIP_SUFFIX).zip)
|
||||||
|
|
||||||
|
NEWVERBOSEZIPFILES += $(JTREG_ZIPFILES:%.zip=%-$(NEW_VERBOSE_ZIP_SUFFIX).zip)
|
||||||
|
|
||||||
|
#JTREG_JAVA_OPTS = -Ddebug.com.sun.javatest.TestResultCache=98
|
||||||
|
#JTREG_OPTS = $(JTREG_JAVA_OPTS:%=-J%)
|
||||||
|
|
||||||
|
TESTS += $(TESTS.jtreg)
|
||||||
|
|
|
@ -0,0 +1,140 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
|
||||||
|
- Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
- Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
- Neither the name of Oracle nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived
|
||||||
|
from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
-->
|
||||||
|
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||||
|
<type>org.netbeans.modules.ant.freeform</type>
|
||||||
|
<configuration>
|
||||||
|
<general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
|
||||||
|
<name>jtreg</name>
|
||||||
|
</general-data>
|
||||||
|
<general-data xmlns="http://www.netbeans.org/ns/freeform-project/2">
|
||||||
|
<!-- Do not use Project Properties customizer when editing this file manually. -->
|
||||||
|
<name>jtreg</name>
|
||||||
|
<properties>
|
||||||
|
<property name="root">../../..</property>
|
||||||
|
<property-file>${root}/build.properties</property-file>
|
||||||
|
<property-file>${root}/make/build.properties</property-file>
|
||||||
|
<property name="ant.script">${root}/make/build.xml</property>
|
||||||
|
</properties>
|
||||||
|
<folders>
|
||||||
|
<source-folder>
|
||||||
|
<label>jtreg</label>
|
||||||
|
<location>${root}</location>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
</source-folder>
|
||||||
|
<source-folder>
|
||||||
|
<label>Build files</label>
|
||||||
|
<type>build</type>
|
||||||
|
<location>${root}/make</location>
|
||||||
|
</source-folder>
|
||||||
|
<source-folder>
|
||||||
|
<label>jtreg</label>
|
||||||
|
<location>.</location>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
</source-folder>
|
||||||
|
<source-folder>
|
||||||
|
<label>Source files</label>
|
||||||
|
<type>java</type>
|
||||||
|
<location>${root}/src/share/classes</location>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
</source-folder>
|
||||||
|
</folders>
|
||||||
|
<ide-actions>
|
||||||
|
<action name="build">
|
||||||
|
<script>nbproject/nbjdk.xml</script>
|
||||||
|
<target>build</target>
|
||||||
|
</action>
|
||||||
|
<action name="clean">
|
||||||
|
<script>nbproject/nbjdk.xml</script>
|
||||||
|
<target>clean</target>
|
||||||
|
</action>
|
||||||
|
<action name="test">
|
||||||
|
<script>nbproject/nbjdk.xml</script>
|
||||||
|
<target>xtest-jtreg</target>
|
||||||
|
</action>
|
||||||
|
<action name="rebuild">
|
||||||
|
<script>nbproject/nbjdk.xml</script>
|
||||||
|
<target>clean</target>
|
||||||
|
<target>build</target>
|
||||||
|
</action>
|
||||||
|
</ide-actions>
|
||||||
|
<view>
|
||||||
|
<items>
|
||||||
|
<source-folder style="tree">
|
||||||
|
<label>Build files</label>
|
||||||
|
<location>${root}/make</location>
|
||||||
|
</source-folder>
|
||||||
|
<source-folder style="packages">
|
||||||
|
<label>Source files</label>
|
||||||
|
<location>${root}/src/share/classes</location>
|
||||||
|
</source-folder>
|
||||||
|
<source-file>
|
||||||
|
<label>README</label>
|
||||||
|
<location>${root}/README</location>
|
||||||
|
</source-file>
|
||||||
|
</items>
|
||||||
|
<context-menu>
|
||||||
|
<ide-action name="build"/>
|
||||||
|
<ide-action name="rebuild"/>
|
||||||
|
<ide-action name="clean"/>
|
||||||
|
<ide-action name="test"/>
|
||||||
|
</context-menu>
|
||||||
|
</view>
|
||||||
|
<subprojects/>
|
||||||
|
</general-data>
|
||||||
|
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/4">
|
||||||
|
<compilation-unit>
|
||||||
|
<package-root>${root}/src/share/classes</package-root>
|
||||||
|
<classpath mode="compile">${javatest.jar}:${jh.jar}:${ant.jar}:${junit.jar}:${testng.jar}</classpath>
|
||||||
|
<source-level>1.7</source-level>
|
||||||
|
</compilation-unit>
|
||||||
|
</java-data>
|
||||||
|
<spellchecker-wordlist xmlns="http://www.netbeans.org/ns/spellchecker-wordlist/1">
|
||||||
|
<word>applet</word>
|
||||||
|
<word>appletviewer</word>
|
||||||
|
<word>arg</word>
|
||||||
|
<word>checkBugId</word>
|
||||||
|
<word>classname</word>
|
||||||
|
<word>classpath</word>
|
||||||
|
<word>defaultExecMode</word>
|
||||||
|
<word>HTML</word>
|
||||||
|
<word>javac</word>
|
||||||
|
<word>javatest</word>
|
||||||
|
<word>jtreg</word>
|
||||||
|
<word>junit</word>
|
||||||
|
<word>JUnitCore</word>
|
||||||
|
<word>org</word>
|
||||||
|
<word>othervm</word>
|
||||||
|
<word>sourcepath</word>
|
||||||
|
<word>yesno</word>
|
||||||
|
</spellchecker-wordlist>
|
||||||
|
</configuration>
|
||||||
|
</project>
|
|
@ -0,0 +1,35 @@
|
||||||
|
#! /bin/sh
|
||||||
|
#
|
||||||
|
# Copyright (c) 2001, 2013, 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
classdir=$1; shift
|
||||||
|
cd $classdir
|
||||||
|
|
||||||
|
if [ "$#" -gt 0 ]; then
|
||||||
|
for i in $* ; do
|
||||||
|
dir=`echo $i | sed -e 's|\.|/|g'`
|
||||||
|
ls -F $dir | grep -v '/$' | sed -e 's|\*$||' -e "s|\(.*\)|-C $classdir $dir/\1|"
|
||||||
|
done
|
||||||
|
fi
|
|
@ -0,0 +1 @@
|
||||||
|
.idea
|
|
@ -0,0 +1,120 @@
|
||||||
|
# jtreg plugin for IntelliJ IDE
|
||||||
|
##### *Maurizio Cimadamore and Chris Hegarty*
|
||||||
|
|
||||||
|
This is a convenience plugin which adds jtreg capabilities to the IntelliJ IDE. With this plugin, OpenJDK developers
|
||||||
|
can write, run, debug jtreg tests without the need of leaving their IDE environment.
|
||||||
|
|
||||||
|
## Plugin setup
|
||||||
|
|
||||||
|
This section covers the initial steps that are required in order to correctly setup the plugin project inside the IntelliJ IDE.
|
||||||
|
|
||||||
|
### Folder layout
|
||||||
|
|
||||||
|
The output of this folder is as follows:
|
||||||
|
|
||||||
|
```
|
||||||
|
idea
|
||||||
|
|-src
|
||||||
|
|-main
|
||||||
|
|-java (plugin sources)
|
||||||
|
|-resources (plugin resources - the plugin.xml file lives here)
|
||||||
|
|-build (where build files are stored)
|
||||||
|
|-distributions (where the plugin zip file is generated)
|
||||||
|
|-build.gradle (the gradle build file)
|
||||||
|
|-gradle.properties (contains properties required to build this project)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Building the plugin
|
||||||
|
|
||||||
|
|
||||||
|
This plugin can be built with `gradle`. To build the plugin, simply run the following command from the `idea` folder:
|
||||||
|
|
||||||
|
`sh gradlew clean build`
|
||||||
|
|
||||||
|
> Note: when working behind a proxy, additional options might be required, such as: \
|
||||||
|
> `-Dhttps.proxyhost=<proxyServer> -Dhttps.proxyPort=<proxyPort>`
|
||||||
|
|
||||||
|
This will download gradle and the required IntelliJ dependencies, will build the plugin and will place the results in the `build/distributions` folder.
|
||||||
|
|
||||||
|
> Note: to build the plugin, the build script must point to a valid jtreg installation; see the property `jtregHome` in the `gradle.properties` file, and tweak accordingly.
|
||||||
|
|
||||||
|
> Note: the property `intellijVersion` can be used to specify which IDE version should the plugin depend on (defaults to `2021.1`).
|
||||||
|
|
||||||
|
Once the build is configured correctly, the plugin can even be tested in a sandbox environment, as follows:
|
||||||
|
|
||||||
|
`sh gradlew runIde`
|
||||||
|
|
||||||
|
### Installing the plugin
|
||||||
|
|
||||||
|
To install the plugin in your IDE, first you need to build a plugin module file (a `.zip` file), as described in the previous section.
|
||||||
|
|
||||||
|
Once the plugin zip has been obtained, it can be installed in the IDE; go in `Help -> Find Action...`, and type `Install plugin from disk`, and then select the corresponding action from the drop down list. A new file dialog will pop up: point the IDE to the zip file you have created in the step above. The IDE will require a restart - once restart is completed the installation process is completed, and the plugin is ready to be used to run and debug jtreg tests.
|
||||||
|
|
||||||
|
## Using the plugin
|
||||||
|
|
||||||
|
This section covers the the functionalities supported by the jtreg plugin.
|
||||||
|
|
||||||
|
### Configuring jtreg
|
||||||
|
|
||||||
|
The plugin allows user to configure how jtreg should be invoked by the plugin. Possible options include:
|
||||||
|
|
||||||
|
* which jtreg should be used to run the tests
|
||||||
|
* which JDK should be used to run the tests
|
||||||
|
* which jtreg options should be used to run tests
|
||||||
|
* where jtreg should put its output files
|
||||||
|
|
||||||
|
Configuring such parameters is possible through the dialog located under `File -> Settings`, under the `jtreg` panel. By default, such settings are saved on a per-project basis. If, however, you would like to specify IDE-wide default, you can do so by accessing a similar dialog under `File -> Other Settings -> Default Settings`.
|
||||||
|
|
||||||
|
Note: the settings specified here will be used as defaults for creating new jtreg run/debug configurations. As a result, if any error is made when configuring global jtreg settings, such errors will be propagated in all newly created jtreg test configurations.
|
||||||
|
|
||||||
|
### Running/debugging jtreg tests
|
||||||
|
|
||||||
|
In order to run a test, you need to create a run configuration. To create a configuration, simply open a jtreg test file, right-click on it and select `Run` (or `Debug`). This should create a configuration for the selected test, and run that configuration. The configuration will then become available for inspection under the `Run -> Edit Configurations` menu. If you wish to run all tests in a given folder, the process is the same: simply right click on the test folder (in the left panel) of choice and select `Run`.
|
||||||
|
|
||||||
|
A jtreg run configuration contains the following information:
|
||||||
|
|
||||||
|
* which test (or folder of tests) should be given as input to jtreg
|
||||||
|
* which JDK should be used to run the tests
|
||||||
|
* which jtreg options should be used to run tests
|
||||||
|
* where jtreg should put its output files
|
||||||
|
|
||||||
|
The last three options can be used to override global settings (e.g. in case a test needs more memory to run).
|
||||||
|
|
||||||
|
Once a configuration has been created, the new configuration will appear in the top right panel. If you notice a red mark beside the configuration name, it means that the configuration contains errors that will likely result in test failures. If that happens, please open the `Run -> Edit Configurations` dialog, and select the problematic configuration; this dialog should contain additional information as to why the configuration is problematic (e.g. missing JDK path).
|
||||||
|
|
||||||
|
To run an existing configuration, simply select it from the drop down list in the top right panel, and click on the `Run` (an icon similar to a *play* button) icon. If you wish to debug instead, simply press the icon beside `Run` (the one with the little bug in it).
|
||||||
|
|
||||||
|
Debugging works as for any other Java application. Simply set breakpoints (this can be done by left-clicking the area to the left of the code in the source editor, which will cause a red circle to appear). During a test debug, execution will stop at any given breakpoints, allowing you to see values of variables, set watch expressions, etc.
|
||||||
|
|
||||||
|
> Note: debugging only works with a _single_ test action such as `@run` or `@compile`. If multiple test actions are present, debugging will not work correctly. This is a known issue. To workaround, please manually remove the test actions that do not need to be debugged. Conversely, `@build` actions can be safely ignored, as they do not have any adverse effect on the debugging process.
|
||||||
|
|
||||||
|
### Inspecting jtreg test results
|
||||||
|
|
||||||
|
Once a test (or a group of tests) have finished running, you can inspect test results in the corresponding bottom panel. This panel is organized in two sub-panels: the one on the left allows you to chose the test whose results you'd like to inspect; the panel on the right contains the actual test output (e.g. the `jtr` file).
|
||||||
|
|
||||||
|
During test execution you will see green and red bars appearing, notifying test passes/failures. It is possible to filter out the tests that show up in the left panel so that e.g. only failed test are displayed (that is done by clicking on the little circle with the `OK` label in the bottom panel); ignored tests can be filtered in a similar fashion.
|
||||||
|
|
||||||
|
If you click on the very first entry of the left panel (the one named 'Test Results'), some general information will be presented in the right panel - such as how many tests were run, how many pass/fail there were, etc. You will also see the URL to the location where test results have been written (this can be opened using your browser of choice).
|
||||||
|
|
||||||
|
### Creating new tests
|
||||||
|
|
||||||
|
To create a new jtreg test, simply create a new file under a jtreg test root. Then add a javadoc comment like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
```
|
||||||
|
|
||||||
|
And press `CTRL + <Space>` - the IDE will show you possible completion suggestions for creating a positive/negative jtreg test. Once the right completion path is selected, a full jtreg header will be populated by the IDE. The IDE will then highlight the sections in the header that require user intervention (e.g. add summary in the `@summary` tag, etc.). Once you have finished typing in the input for a given section, just press enter and the IDE will move to the next section which requires manual intervention. Repeat the process until all required fields have been entered. At the end of this process, a new jtreg test will have been created.
|
||||||
|
|
||||||
|
## Miscellaneous
|
||||||
|
|
||||||
|
### What needs to be rebuilt before a test run?
|
||||||
|
|
||||||
|
The jtreg plugin is very flexible when it comes to defining the actions that should be taken by IntelliJ to rebuild the project before running/debugging a test. If your project does not use Ant, the default action associated with a jtreg test configuration is to simply run `Make` - which is the standard way in which IntelliJ builds a project. However, if your project uses Ant (this is the case with the JDK and the langtools IntelliJ projects), the plugin can launch any desired ant target before running a given test.
|
||||||
|
|
||||||
|
To select which Ant target to run before a jtreg test, simply go in the `File -> Settings -> jtreg` menu, and add ant targets to the drop down list. You can add, remove targets as well as changing order of existing targets.
|
||||||
|
|
||||||
|
### Dealing with bugs
|
||||||
|
|
||||||
|
In the unfortunate case you run into a plugin bug, you will notice a red mark in the bottom right part of the IDE. If you click on that icon, you will have the ability to show the stack trace associated with the error (and you will also be offered the option of disabling the plugin). If you want to report a bug against the jtreg plugin, we recommend that you copy the stack trace along with the IDE log file (this can be found under `Help -> Show Log in Files`) and submit them along with a description of the experienced buggy behavior. Please forward such bug reports to `jtreg-dev@openjdk.java.net`, or `ide-support-dev@openjdk.java.net`
|
|
@ -0,0 +1,36 @@
|
||||||
|
plugins {
|
||||||
|
id 'java'
|
||||||
|
id 'org.jetbrains.intellij' version '1.0'
|
||||||
|
}
|
||||||
|
|
||||||
|
def jtregLib = jtregHome + File.separator + "lib" + File.separator + "jtreg.jar"
|
||||||
|
|
||||||
|
assert file(jtregLib).exists() : """Could not find jtreg in ${jtregHome}.
|
||||||
|
Please make sure that 'jtregHome' in 'gradle.properties' points to a valid jtreg root.
|
||||||
|
"""
|
||||||
|
|
||||||
|
version pluginVersion
|
||||||
|
|
||||||
|
compileJava {
|
||||||
|
sourceCompatibility = javaLevel
|
||||||
|
targetCompatibility = javaLevel
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation files(jtregLib)
|
||||||
|
}
|
||||||
|
|
||||||
|
// See https://github.com/JetBrains/gradle-intellij-plugin/
|
||||||
|
intellij {
|
||||||
|
plugins = ['java', 'AntSupport', 'TestNG-J']
|
||||||
|
}
|
||||||
|
|
||||||
|
patchPluginXml {
|
||||||
|
changeNotes = notes
|
||||||
|
sinceBuild = minBuild
|
||||||
|
untilBuild = ''
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
jtregHome = /path/to/jtreg
|
||||||
|
minBuild = 211
|
||||||
|
pluginVersion = 1.13
|
||||||
|
javaLevel = 11
|
||||||
|
notes = <ul>\
|
||||||
|
<li>Fix compatibility with 2021.2</li>\
|
||||||
|
</ul>
|
Binary file not shown.
|
@ -0,0 +1,5 @@
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
|
@ -0,0 +1,185 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright 2015 the original author or authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=`expr $i + 1`
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
0) set -- ;;
|
||||||
|
1) set -- "$args0" ;;
|
||||||
|
2) set -- "$args0" "$args1" ;;
|
||||||
|
3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=`save "$@"`
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
|
@ -0,0 +1,89 @@
|
||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
|
@ -0,0 +1,2 @@
|
||||||
|
rootProject.name = 'jtreg-plugin'
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.oracle.plugin.jtreg.components;
|
||||||
|
|
||||||
|
import com.intellij.openapi.components.ProjectComponent;
|
||||||
|
import com.intellij.openapi.fileEditor.FileEditorManagerListener;
|
||||||
|
import com.intellij.openapi.project.Project;
|
||||||
|
import com.intellij.util.messages.MessageBusConnection;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The jtreg project component. This class is attached to every project that is opened inside the IDE and listens
|
||||||
|
* for specific events (see {@see JTRegFileManagerListener}.
|
||||||
|
*/
|
||||||
|
public class JTRegApplicationComponent implements ProjectComponent {
|
||||||
|
|
||||||
|
JTRegFileManagerListener listener;
|
||||||
|
MessageBusConnection busConnection;
|
||||||
|
|
||||||
|
public JTRegApplicationComponent(Project project) {
|
||||||
|
busConnection = project.getMessageBus().connect();
|
||||||
|
listener = new JTRegFileManagerListener(project);
|
||||||
|
busConnection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initComponent() {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disposeComponent() {
|
||||||
|
busConnection.disconnect();
|
||||||
|
listener.dispose();
|
||||||
|
listener = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void projectOpened() {
|
||||||
|
//nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void projectClosed() {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public String getComponentName() {
|
||||||
|
return "JTRegApplicationComponent";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,257 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2017, 2019 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.oracle.plugin.jtreg.components;
|
||||||
|
|
||||||
|
import com.intellij.openapi.application.ApplicationManager;
|
||||||
|
import com.intellij.openapi.application.ModalityState;
|
||||||
|
import com.intellij.openapi.diagnostic.Logger;
|
||||||
|
import com.intellij.openapi.editor.Document;
|
||||||
|
import com.intellij.openapi.editor.event.DocumentEvent;
|
||||||
|
import com.intellij.openapi.editor.event.DocumentListener;
|
||||||
|
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||||
|
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||||
|
import com.intellij.openapi.fileEditor.FileEditorManagerListener;
|
||||||
|
import com.intellij.openapi.module.Module;
|
||||||
|
import com.intellij.openapi.module.ModuleUtilCore;
|
||||||
|
import com.intellij.openapi.project.DumbService;
|
||||||
|
import com.intellij.openapi.project.Project;
|
||||||
|
import com.intellij.openapi.roots.*;
|
||||||
|
import com.intellij.openapi.vfs.VirtualFile;
|
||||||
|
import com.intellij.util.Alarm;
|
||||||
|
import com.oracle.plugin.jtreg.util.JTRegUtils;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This listener intercepts editor events for file opened/closed. Each time a new jtreg test is opened, the project root
|
||||||
|
* model is updated, so that the test source is displayed without errors. Changes in the headers will be picked up
|
||||||
|
* and reflected in the root model.
|
||||||
|
*/
|
||||||
|
public class JTRegFileManagerListener implements FileEditorManagerListener {
|
||||||
|
|
||||||
|
public static final Logger LOG = Logger.getInstance(JTRegFileManagerListener.class);
|
||||||
|
|
||||||
|
Project project;
|
||||||
|
|
||||||
|
class TestInfo {
|
||||||
|
VirtualFile file;
|
||||||
|
Module module;
|
||||||
|
Alarm alarm = new Alarm();
|
||||||
|
VirtualFile contentRoot;
|
||||||
|
List<VirtualFile> roots = new ArrayList<>();
|
||||||
|
Document document;
|
||||||
|
DocumentListener listener = new DocumentListener() {
|
||||||
|
@Override
|
||||||
|
public void documentChanged(DocumentEvent e) {
|
||||||
|
alarm.cancelAllRequests();
|
||||||
|
alarm.addRequest(() -> processFileOpened(TestInfo.this), 1000);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TestInfo(VirtualFile file) {
|
||||||
|
this.file = file;
|
||||||
|
this.module = ModuleUtilCore.findModuleForFile(file, project);
|
||||||
|
this.contentRoot = ProjectRootManager.getInstance(project).getFileIndex().getContentRootForFile(file);
|
||||||
|
this.document = FileDocumentManager.getInstance().getDocument(file);
|
||||||
|
document.addDocumentListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dispose() {
|
||||||
|
alarm.cancelAllRequests();
|
||||||
|
document.removeDocumentListener(listener);
|
||||||
|
//clear out test info
|
||||||
|
file = null;
|
||||||
|
roots = null;
|
||||||
|
contentRoot = null;
|
||||||
|
module = null;
|
||||||
|
alarm = null;
|
||||||
|
document = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<VirtualFile, TestInfo> testInfos = new HashMap<>();
|
||||||
|
TestRootManager rootManager = new TestRootManager();
|
||||||
|
|
||||||
|
|
||||||
|
public JTRegFileManagerListener(Project project) {
|
||||||
|
this.project = project;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
|
||||||
|
if (JTRegUtils.isInJTRegRoot(file)) {
|
||||||
|
LOG.info("test file opened: " + file + " @ " + project.getName());
|
||||||
|
DumbService.getInstance(project).smartInvokeLater(() -> {
|
||||||
|
LOG.info("test file opened [smart]: " + file + " @ " + project.getName());
|
||||||
|
TestInfo testInfo = new TestInfo(file);
|
||||||
|
testInfos.put(file, testInfo);
|
||||||
|
processFileOpened(testInfo);
|
||||||
|
}, ModalityState.NON_MODAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void processFileOpened(TestInfo testInfo) {
|
||||||
|
VirtualFile file = testInfo.file;
|
||||||
|
LOG.info("processing file opened: " + testInfo.file + " @ " + project.getName());
|
||||||
|
boolean isJtreg = JTRegUtils.isJTRegTestData(project, file);
|
||||||
|
boolean isTestNg = JTRegUtils.isTestNGTestData(project, file);
|
||||||
|
if (isJtreg || isTestNg) {
|
||||||
|
//add jtreg roots
|
||||||
|
try (TestRootManager.TestRootModel rootModel = rootManager.rootModel(testInfo)) {
|
||||||
|
List<VirtualFile> oldRoots = testInfo.roots;
|
||||||
|
List<VirtualFile> testRoots = JTRegUtils.getTestRoots(project, file);
|
||||||
|
if (oldRoots == null || !oldRoots.equals(testRoots)) {
|
||||||
|
if (oldRoots != null) {
|
||||||
|
rootModel.removeSourceFolders(oldRoots);
|
||||||
|
}
|
||||||
|
testInfo.roots = testRoots;
|
||||||
|
if (!testRoots.isEmpty()) {
|
||||||
|
rootModel.addSourceFolders(testRoots);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try (TestRootManager.TestRootModel rootModel = rootManager.rootModel(testInfo)) {
|
||||||
|
List<VirtualFile> oldRoots = testInfo.roots;
|
||||||
|
if (oldRoots != null) {
|
||||||
|
rootModel.removeSourceFolders(oldRoots);
|
||||||
|
}
|
||||||
|
testInfo.roots = Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fileClosed(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
|
||||||
|
TestInfo testInfo = testInfos.get(file); //did we open the file?
|
||||||
|
if (testInfo != null) {
|
||||||
|
LOG.info("test file closed: " + file + " @ " + project.getName());
|
||||||
|
DumbService.getInstance(project).smartInvokeLater(() -> {
|
||||||
|
LOG.info("test file closed [smart]: " + file + " @ " + project.getName());
|
||||||
|
processFileClosed(testInfo);
|
||||||
|
}, ModalityState.NON_MODAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void processFileClosed(TestInfo testInfo) {
|
||||||
|
VirtualFile file = testInfo.file;
|
||||||
|
LOG.info("processing file closed: " + testInfo.file + " @ " + project.getName());
|
||||||
|
if (!file.exists() || JTRegUtils.isJTRegTestData(project, file) || JTRegUtils.isTestNGTestData(project, file)) {
|
||||||
|
if (project.isOpen()) {
|
||||||
|
try (TestRootManager.TestRootModel rootModel = rootManager.rootModel(testInfo)) {
|
||||||
|
List<VirtualFile> rootsToRemove = file.exists() ?
|
||||||
|
JTRegUtils.getTestRoots(project, file) : testInfo.roots;
|
||||||
|
rootModel.removeSourceFolders(rootsToRemove);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
testInfo.dispose();
|
||||||
|
testInfos.remove(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestRootManager {
|
||||||
|
|
||||||
|
Map<VirtualFile, Integer> refCount = new HashMap<>();
|
||||||
|
|
||||||
|
TestRootModel rootModel(TestInfo testInfo) {
|
||||||
|
ModifiableRootModel modifiableRootModel = ModuleRootManager.getInstance(testInfo.module).getModifiableModel();
|
||||||
|
ContentEntry contentEntry = Stream.of(modifiableRootModel.getContentEntries())
|
||||||
|
.filter(e -> e.getFile().equals(testInfo.contentRoot))
|
||||||
|
.findFirst().orElse(null);
|
||||||
|
return new TestRootModel(contentEntry, modifiableRootModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dispose() {
|
||||||
|
refCount.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestRootModel implements AutoCloseable {
|
||||||
|
ContentEntry contentEntry;
|
||||||
|
ModifiableRootModel modifiableRootModel;
|
||||||
|
|
||||||
|
TestRootModel(ContentEntry contentEntry, ModifiableRootModel modifiableRootModel) {
|
||||||
|
this.contentEntry = contentEntry;
|
||||||
|
this.modifiableRootModel = modifiableRootModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addSourceFolders(List<VirtualFile> sourceRoots) {
|
||||||
|
for (VirtualFile f : sourceRoots) {
|
||||||
|
Integer i = refCount.get(f);
|
||||||
|
if (i == null) {
|
||||||
|
LOG.debug("Adding source folder: " + f);
|
||||||
|
contentEntry.addSourceFolder(f, true);
|
||||||
|
}
|
||||||
|
refCount.put(f, i == null ? 1 : i + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeSourceFolders(List<VirtualFile> sourceRoots) {
|
||||||
|
for (SourceFolder s : contentEntry.getSourceFolders()) {
|
||||||
|
if (!s.isTestSource()) continue;
|
||||||
|
for (VirtualFile f : sourceRoots) {
|
||||||
|
if (f.getUrl().equals(s.getUrl())) {
|
||||||
|
removeSourceFolder(f, s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeSourceFolder(VirtualFile f, SourceFolder s) {
|
||||||
|
Integer i = refCount.get(f);
|
||||||
|
if (i == null) {
|
||||||
|
//not found - skip
|
||||||
|
} else if (i == 1) {
|
||||||
|
LOG.debug("Removing source folder: " + s);
|
||||||
|
contentEntry.removeSourceFolder(s);
|
||||||
|
refCount.remove(f);
|
||||||
|
} else {
|
||||||
|
refCount.put(f, i - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
if (modifiableRootModel.isChanged()) {
|
||||||
|
ApplicationManager.getApplication().runWriteAction(() -> modifiableRootModel.commit());
|
||||||
|
} else {
|
||||||
|
modifiableRootModel.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dispose() {
|
||||||
|
Iterator<Map.Entry<VirtualFile, TestInfo>> entriesIt = testInfos.entrySet().iterator();
|
||||||
|
while (entriesIt.hasNext()) {
|
||||||
|
entriesIt.next().getValue().dispose();
|
||||||
|
entriesIt.remove();
|
||||||
|
}
|
||||||
|
rootManager.dispose();
|
||||||
|
project = null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,311 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2017, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.oracle.plugin.jtreg.configuration;
|
||||||
|
|
||||||
|
import com.intellij.diagnostic.logging.LogConfigurationPanel;
|
||||||
|
import com.intellij.execution.*;
|
||||||
|
import com.intellij.execution.configurations.*;
|
||||||
|
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||||
|
import com.intellij.execution.testframework.TestSearchScope;
|
||||||
|
import com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties;
|
||||||
|
import com.intellij.execution.ui.DefaultJreSelector;
|
||||||
|
import com.intellij.openapi.module.Module;
|
||||||
|
import com.intellij.openapi.module.ModuleManager;
|
||||||
|
import com.intellij.openapi.module.ModuleUtilCore;
|
||||||
|
import com.intellij.openapi.options.SettingsEditor;
|
||||||
|
import com.intellij.openapi.options.SettingsEditorGroup;
|
||||||
|
import com.intellij.openapi.project.Project;
|
||||||
|
import com.intellij.openapi.projectRoots.JdkUtil;
|
||||||
|
import com.intellij.openapi.projectRoots.ProjectJdkTable;
|
||||||
|
import com.intellij.openapi.projectRoots.Sdk;
|
||||||
|
import com.intellij.openapi.util.InvalidDataException;
|
||||||
|
import com.intellij.openapi.util.WriteExternalException;
|
||||||
|
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||||
|
import com.intellij.openapi.vfs.VirtualFile;
|
||||||
|
import com.intellij.psi.PsiClass;
|
||||||
|
import com.intellij.psi.PsiElement;
|
||||||
|
import com.intellij.psi.PsiMethod;
|
||||||
|
import com.intellij.refactoring.listeners.RefactoringElementListener;
|
||||||
|
import com.intellij.util.xmlb.XmlSerializer;
|
||||||
|
import org.jdom.Element;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import com.oracle.plugin.jtreg.configuration.ui.JTRegConfigurable;
|
||||||
|
import com.oracle.plugin.jtreg.service.JTRegService;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The jtreg configuration.
|
||||||
|
*/
|
||||||
|
public class JTRegConfiguration extends JavaTestConfigurationBase {
|
||||||
|
private String jtregOptions;
|
||||||
|
private boolean alternativeJrePathEnabled;
|
||||||
|
private String alternativeJrePath;
|
||||||
|
private String file;
|
||||||
|
private String directory;
|
||||||
|
private String workDirectory;
|
||||||
|
|
||||||
|
public JTRegConfiguration(Project project, ConfigurationFactory configurationFactory) {
|
||||||
|
super("jtreg", new JavaRunConfigurationModule(project, false), configurationFactory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getFrameworkPrefix() {
|
||||||
|
return "jtreg";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setEnvs(Map<String, String> map) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getEnvs() {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPassParentEnvs(boolean b) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPassParentEnvs() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<Module> getValidModules() {
|
||||||
|
if (file != null) {
|
||||||
|
VirtualFile vf = LocalFileSystem.getInstance().findFileByPath(file);
|
||||||
|
if (vf != null) {
|
||||||
|
return Collections.singletonList(ModuleUtilCore.findModuleForFile(vf, getProject()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Arrays.asList(ModuleManager.getInstance(getProject()).getModules());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public RefactoringElementListener getRefactoringElementListener(PsiElement psiElement) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readExternal(Element element) throws InvalidDataException {
|
||||||
|
super.readExternal(element);
|
||||||
|
XmlSerializer.deserializeInto(this, element);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeExternal(Element element) throws WriteExternalException {
|
||||||
|
super.writeExternal(element);
|
||||||
|
|
||||||
|
XmlSerializer.serializeInto(this, element);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public SettingsEditor<? extends RunConfiguration> getConfigurationEditor() {
|
||||||
|
SettingsEditorGroup<JTRegConfiguration> group = new SettingsEditorGroup<>();
|
||||||
|
group.addEditor(ExecutionBundle.message("run.configuration.configuration.tab.title"), new JTRegConfigurable<>(getProject()));
|
||||||
|
//provides e.g. coverage tab
|
||||||
|
JavaRunConfigurationExtensionManager.getInstance().appendEditors(this, group);
|
||||||
|
//if some logging would be interesting to have aside with console
|
||||||
|
group.addEditor(ExecutionBundle.message("logs.tab.title"), new LogConfigurationPanel<>());
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public JTRegConfigurationRunnableState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment executionEnvironment) throws ExecutionException {
|
||||||
|
return new JTRegConfigurationRunnableState(this, executionEnvironment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SMTRunnerConsoleProperties createTestConsoleProperties(Executor executor) {
|
||||||
|
//produces some additional benefits for rerun failed tests, etc
|
||||||
|
return new JTRegConfigurationConsoleProperties(executor, JTRegConfiguration.this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void checkConfiguration() throws RuntimeConfigurationException {
|
||||||
|
super.checkConfiguration();
|
||||||
|
String fileOrDirectory = file != null ? file : directory;
|
||||||
|
if (fileOrDirectory != null) {
|
||||||
|
final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(fileOrDirectory);
|
||||||
|
if (file == null || !file.isValid()) {
|
||||||
|
throw new RuntimeConfigurationWarning("Test " + (this.file != null ? "file " : "directory ") + fileOrDirectory + " doesn't exist");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new RuntimeConfigurationWarning("Nothing found to run");
|
||||||
|
}
|
||||||
|
String jtregDir = JTRegService.getInstance(getProject()).getJTRegDir();
|
||||||
|
if (jtregDir != null && !jtregDir.isEmpty()) {
|
||||||
|
final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(jtregDir);
|
||||||
|
if (file == null || !file.isValid()) {
|
||||||
|
throw new RuntimeConfigurationWarning("Configured jtreg path " + jtregDir + " doesn't exist");
|
||||||
|
}
|
||||||
|
VirtualFile lib = file.findChild("lib");
|
||||||
|
boolean error = lib == null || !lib.isValid();
|
||||||
|
if (!error) {
|
||||||
|
VirtualFile jar = lib.findChild("jtreg.jar");
|
||||||
|
error = jar == null || !jar.isValid();
|
||||||
|
}
|
||||||
|
if (error) {
|
||||||
|
throw new RuntimeConfigurationWarning("Configured jtreg path " + jtregDir + " doesn't point to a valid jtreg installation");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new RuntimeConfigurationWarning("No jtreg path configured");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getJDKString() == null) {
|
||||||
|
throw new RuntimeConfigurationWarning("No valid JDK configured for running jtreg tests");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String getJDKString() {
|
||||||
|
String jdkString = null;
|
||||||
|
if (isAlternativeJrePathEnabled()) {
|
||||||
|
String jdkPathString = getAlternativeJrePath();
|
||||||
|
Sdk sdk = ProjectJdkTable.getInstance().findJdk(jdkPathString);
|
||||||
|
if (sdk != null) {
|
||||||
|
jdkString = sdk.getHomePath();
|
||||||
|
} else if (JdkUtil.checkForJdk(jdkPathString)) {
|
||||||
|
jdkString = jdkPathString;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String defaultJdk = DefaultJreSelector.projectSdk(getProject()).getNameAndDescription().first;
|
||||||
|
jdkString = ProjectJdkTable.getInstance().findJdk(defaultJdk).getHomePath();
|
||||||
|
}
|
||||||
|
return jdkString;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRunClass() {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRunClass(String file) {
|
||||||
|
this.file = file;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public String getPackage() {
|
||||||
|
return directory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPackage(String directory) {
|
||||||
|
this.directory = directory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAlternativeJrePathEnabled() {
|
||||||
|
return alternativeJrePathEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAlternativeJrePathEnabled(boolean alternativeJREPathEnabled) {
|
||||||
|
this.alternativeJrePathEnabled = alternativeJREPathEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAlternativeJrePath() {
|
||||||
|
return alternativeJrePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAlternativeJrePath(String alternativeJrePath) {
|
||||||
|
this.alternativeJrePath = alternativeJrePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getProgramParameters() {
|
||||||
|
return jtregOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setProgramParameters(String jtregOptions) {
|
||||||
|
this.jtregOptions = jtregOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public String getWorkingDirectory() {
|
||||||
|
return workDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setWorkingDirectory(@Nullable String s) {
|
||||||
|
workDirectory = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getVMParameters() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setVMParameters(String s) { }
|
||||||
|
|
||||||
|
public void bePatternConfiguration(List<PsiClass> list, PsiMethod psiMethod) {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public void beMethodConfiguration(Location<PsiMethod> location) {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public void beClassConfiguration(PsiClass psiClass) {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isConfiguredByElement(PsiElement psiElement) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TestSearchScope getTestSearchScope() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSearchScope(TestSearchScope testSearchScope) {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTestType() {
|
||||||
|
return "jtreg";
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getTestFrameworkId() {
|
||||||
|
return 2; //for now
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.oracle.plugin.jtreg.configuration;
|
||||||
|
|
||||||
|
import com.intellij.execution.Executor;
|
||||||
|
import com.intellij.execution.actions.JavaRerunFailedTestsAction;
|
||||||
|
import com.intellij.execution.testframework.JavaAwareTestConsoleProperties;
|
||||||
|
import com.intellij.execution.testframework.actions.AbstractRerunFailedTestsAction;
|
||||||
|
import com.intellij.execution.ui.ConsoleView;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class defines policies to filter out failed tests etc. Currently unused.
|
||||||
|
*/
|
||||||
|
public class JTRegConfigurationConsoleProperties extends JavaAwareTestConsoleProperties<JTRegConfiguration> {
|
||||||
|
public JTRegConfigurationConsoleProperties(Executor executor, JTRegConfiguration runConfiguration) {
|
||||||
|
super("jtreg", runConfiguration, executor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public AbstractRerunFailedTestsAction createRerunFailedTestsAction(ConsoleView consoleView) {
|
||||||
|
return new JavaRerunFailedTestsAction(consoleView, this);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,226 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.oracle.plugin.jtreg.configuration;
|
||||||
|
|
||||||
|
import com.intellij.execution.*;
|
||||||
|
import com.intellij.execution.configurations.JavaParameters;
|
||||||
|
import com.intellij.execution.configurations.ParametersList;
|
||||||
|
import com.intellij.execution.configurations.RuntimeConfigurationError;
|
||||||
|
import com.intellij.execution.configurations.RuntimeConfigurationException;
|
||||||
|
import com.intellij.execution.process.KillableColoredProcessHandler;
|
||||||
|
import com.intellij.execution.process.OSProcessHandler;
|
||||||
|
import com.intellij.execution.process.ProcessTerminatedListener;
|
||||||
|
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||||
|
import com.intellij.execution.runners.ProgramRunner;
|
||||||
|
import com.intellij.execution.testframework.SearchForTestsTask;
|
||||||
|
import com.intellij.execution.testframework.TestSearchScope;
|
||||||
|
import com.intellij.execution.ui.DefaultJreSelector;
|
||||||
|
import com.intellij.openapi.module.Module;
|
||||||
|
import com.intellij.openapi.projectRoots.JdkUtil;
|
||||||
|
import com.intellij.openapi.projectRoots.ProjectJdkTable;
|
||||||
|
import com.intellij.openapi.projectRoots.Sdk;
|
||||||
|
import com.intellij.util.PathUtil;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import com.oracle.plugin.jtreg.executors.JTRegDebuggerRunner;
|
||||||
|
import com.oracle.plugin.jtreg.runtime.JTRegTestListener;
|
||||||
|
import com.oracle.plugin.jtreg.service.JTRegService;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.nio.file.DirectoryStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class tells the IDE how a given configuration should be translated into an actual command line invocation.
|
||||||
|
*/
|
||||||
|
class JTRegConfigurationRunnableState extends JavaTestFrameworkRunnableState<JTRegConfiguration> {
|
||||||
|
|
||||||
|
private final JTRegConfiguration myConfiguration;
|
||||||
|
|
||||||
|
public JTRegConfigurationRunnableState(JTRegConfiguration configuration, ExecutionEnvironment executionEnvironment) {
|
||||||
|
super(executionEnvironment);
|
||||||
|
myConfiguration = configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
protected String getFrameworkName() {
|
||||||
|
return "jtreg";
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
protected String getFrameworkId() {
|
||||||
|
return "jtreg";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void passTempFile(ParametersList parametersList, String s) {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
protected JTRegConfiguration getConfiguration() {
|
||||||
|
return myConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
protected TestSearchScope getScope() {
|
||||||
|
return TestSearchScope.SINGLE_MODULE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JavaParameters createJavaParameters() throws ExecutionException {
|
||||||
|
|
||||||
|
try {
|
||||||
|
getConfiguration().checkConfiguration();
|
||||||
|
} catch (RuntimeConfigurationException err) {
|
||||||
|
throw new CantRunException(err.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
JavaParameters javaParameters = super.createJavaParameters();
|
||||||
|
javaParameters.getProgramParametersList().clearAll();
|
||||||
|
javaParameters.setMainClass("com.sun.javatest.regtest.Main");
|
||||||
|
|
||||||
|
String jdkString = getConfiguration().getJDKString();
|
||||||
|
|
||||||
|
javaParameters.getProgramParametersList().add("-jdk:" + jdkString);
|
||||||
|
|
||||||
|
String customJTRegOptions = getConfiguration().getProgramParameters();
|
||||||
|
if (customJTRegOptions != null) {
|
||||||
|
javaParameters.getProgramParametersList().addParametersString(customJTRegOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getEnvironment().getRunner() instanceof JTRegDebuggerRunner) {
|
||||||
|
JTRegDebuggerRunner runner = (JTRegDebuggerRunner) getEnvironment().getRunner();
|
||||||
|
javaParameters.getProgramParametersList().add("-debug:-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=127.0.0.1:" + runner.address);
|
||||||
|
boolean hasMode = false;
|
||||||
|
for (String s : new String[] { "-ovm", "-othervm", "-avm", "-agentvm" }) {
|
||||||
|
if (javaParameters.getProgramParametersList().hasParameter(s)) {
|
||||||
|
javaParameters.getProgramParametersList().replaceOrAppend(s, "-avm");
|
||||||
|
hasMode = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasMode) {
|
||||||
|
javaParameters.getProgramParametersList().add("-avm");
|
||||||
|
}
|
||||||
|
javaParameters.getProgramParametersList().replaceOrAppend("-conc:", "-conc:1");
|
||||||
|
}
|
||||||
|
|
||||||
|
//convert any vm passed by intellij options into jtreg -vmoptions
|
||||||
|
for (String vmOption : javaParameters.getVMParametersList().getParameters()) {
|
||||||
|
javaParameters.getProgramParametersList().add("-vmoption:" + vmOption);
|
||||||
|
}
|
||||||
|
javaParameters.getVMParametersList().clearAll();
|
||||||
|
|
||||||
|
javaParameters.getProgramParametersList().add("-o:com.oracle.plugin.jtreg.runtime.JTRegTestListener");
|
||||||
|
javaParameters.getProgramParametersList().add("-od:" + PathUtil.getJarPathForClass(JTRegConfiguration.class));
|
||||||
|
if (getConfiguration().getRunClass() != null) {
|
||||||
|
javaParameters.getProgramParametersList().add(getConfiguration().getRunClass());
|
||||||
|
} else {
|
||||||
|
javaParameters.getProgramParametersList().add(getConfiguration().getPackage());
|
||||||
|
}
|
||||||
|
return javaParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void configureRTClasspath(JavaParameters javaParameters) {
|
||||||
|
JTRegService jtregSettings = JTRegService.getInstance(getConfiguration().getProject());
|
||||||
|
Path jtregLibDir = Path.of(jtregSettings.getJTRegDir(), "lib");
|
||||||
|
try (DirectoryStream<Path> libs = Files.newDirectoryStream(jtregLibDir, "*.jar")) {
|
||||||
|
libs.forEach(lib -> javaParameters.getClassPath().add(lib.toString()));
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new IllegalStateException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void configureRTClasspath(JavaParameters javaParameters, Module module) throws CantRunException {
|
||||||
|
configureRTClasspath(javaParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<String> getNamedParams(String parameters) {
|
||||||
|
return Stream.of(parameters.split(" ")).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
protected OSProcessHandler createHandler(Executor executor) throws ExecutionException {
|
||||||
|
final OSProcessHandler processHandler = new KillableColoredProcessHandler(createCommandLine());
|
||||||
|
ProcessTerminatedListener.attach(processHandler);
|
||||||
|
final SearchForTestsTask searchingForTestsTask = createSearchingForTestsTask();
|
||||||
|
if (searchingForTestsTask != null) {
|
||||||
|
searchingForTestsTask.attachTaskToProcess(processHandler);
|
||||||
|
}
|
||||||
|
return processHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public ExecutionResult execute(@NotNull final Executor executor, @NotNull final ProgramRunner runner) throws ExecutionException {
|
||||||
|
try {
|
||||||
|
Method smRunner = JavaTestFrameworkRunnableState.class.getDeclaredMethod("startSMRunner", Executor.class);
|
||||||
|
//compatibility (2016.3 or earlier)
|
||||||
|
return (ExecutionResult)smRunner.invoke(this, executor);
|
||||||
|
} catch (NoSuchMethodException ex) {
|
||||||
|
//newer IDEA (2017.1 or later)
|
||||||
|
return super.execute(executor, runner);
|
||||||
|
} catch (ReflectiveOperationException ex) {
|
||||||
|
throw new IllegalStateException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We need this for compatibility with 2016.2
|
||||||
|
*/
|
||||||
|
protected boolean isSmRunnerUsed() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SearchForTestsTask createSearchingForTestsTask() {
|
||||||
|
//todo add here test detection based on myConfiguration.getPackage(), for class configuration - do nothing
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
protected String getForkMode() {
|
||||||
|
return "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void passForkMode(String s, File file, JavaParameters javaParameters) throws ExecutionException {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.oracle.plugin.jtreg.configuration;
|
||||||
|
|
||||||
|
import com.intellij.execution.configurations.ConfigurationFactory;
|
||||||
|
import com.intellij.execution.configurations.ConfigurationType;
|
||||||
|
import com.intellij.execution.configurations.ConfigurationTypeUtil;
|
||||||
|
import com.intellij.execution.configurations.RunConfiguration;
|
||||||
|
import com.intellij.openapi.project.Project;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import icons.JTRegPluginIcons;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The jtreg configuration type.
|
||||||
|
*/
|
||||||
|
public class JTRegConfigurationType implements ConfigurationType {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDisplayName() {
|
||||||
|
return "jtreg";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getConfigurationTypeDescription() {
|
||||||
|
return "jtreg";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Icon getIcon() {
|
||||||
|
return JTRegPluginIcons.JTREG_ICON_16;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public String getId() {
|
||||||
|
return "jtreg";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ConfigurationFactory[] getConfigurationFactories() {
|
||||||
|
return new ConfigurationFactory[]{new ConfigurationFactory(this) {
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public RunConfiguration createTemplateConfiguration(@NotNull Project project) {
|
||||||
|
return new JTRegConfiguration(project, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getId() {
|
||||||
|
return "jtreg";
|
||||||
|
}
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static JTRegConfigurationType getInstance() {
|
||||||
|
return ConfigurationTypeUtil.findConfigurationType(JTRegConfigurationType.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.oracle.plugin.jtreg.configuration.producers;
|
||||||
|
|
||||||
|
import com.intellij.execution.Location;
|
||||||
|
import com.intellij.execution.actions.ConfigurationContext;
|
||||||
|
import com.intellij.lang.ant.config.AntConfiguration;
|
||||||
|
import com.intellij.openapi.module.Module;
|
||||||
|
import com.intellij.openapi.util.Ref;
|
||||||
|
import com.intellij.psi.*;
|
||||||
|
import com.oracle.plugin.jtreg.configuration.JTRegConfiguration;
|
||||||
|
import com.oracle.plugin.jtreg.service.JTRegService;
|
||||||
|
import com.oracle.plugin.jtreg.util.JTRegUtils;
|
||||||
|
import com.oracle.plugin.jtreg.configuration.JTRegConfiguration;
|
||||||
|
import com.oracle.plugin.jtreg.service.JTRegService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class generates a jtreg configuration from a given file selected in the IDE.
|
||||||
|
*/
|
||||||
|
public class JTRegClassConfigurationProducer extends JTRegConfigurationProducer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean setupConfigurationFromContext(JTRegConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
|
||||||
|
final Location contextLocation = context.getLocation();
|
||||||
|
assert contextLocation != null;
|
||||||
|
PsiFile psiFile = contextLocation.getPsiElement().getContainingFile();
|
||||||
|
if (psiFile == null ||
|
||||||
|
!JTRegUtils.isInJTRegRoot(psiFile.getContainingDirectory()) ||
|
||||||
|
(!JTRegUtils.isJTRegTestData(psiFile) &&
|
||||||
|
!JTRegUtils.isTestNGTestData(psiFile))) return false;
|
||||||
|
setupConfigurationModule(context, configuration);
|
||||||
|
final Module originalModule = configuration.getConfigurationModule().getModule();
|
||||||
|
configuration.setAlternativeJrePathEnabled(JTRegService.getInstance(configuration.getProject()).isAlternativeJrePathEnabled());
|
||||||
|
configuration.setAlternativeJrePath(JTRegService.getInstance(configuration.getProject()).getAlternativeJrePath());
|
||||||
|
configuration.setProgramParameters(JTRegService.getInstance(configuration.getProject()).getJTregOptions());
|
||||||
|
configuration.setWorkingDirectory(JTRegService.getInstance(configuration.getProject()).getWorkDir());
|
||||||
|
configuration.setRunClass(psiFile.getVirtualFile().getPath());
|
||||||
|
configuration.restoreOriginalModule(originalModule);
|
||||||
|
configuration.setName(psiFile.getName());
|
||||||
|
initBeforeTaskActions(configuration);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,103 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.oracle.plugin.jtreg.configuration.producers;
|
||||||
|
|
||||||
|
import com.intellij.execution.BeforeRunTask;
|
||||||
|
import com.intellij.execution.JavaExecutionUtil;
|
||||||
|
import com.intellij.execution.Location;
|
||||||
|
import com.intellij.execution.RunManagerEx;
|
||||||
|
import com.intellij.execution.actions.ConfigurationContext;
|
||||||
|
import com.intellij.execution.actions.ConfigurationFromContext;
|
||||||
|
import com.intellij.execution.application.ApplicationConfiguration;
|
||||||
|
import com.intellij.execution.junit.JavaRunConfigurationProducerBase;
|
||||||
|
import com.intellij.lang.ant.config.*;
|
||||||
|
import com.intellij.lang.ant.config.impl.AntBeforeRunTask;
|
||||||
|
import com.intellij.lang.ant.config.impl.AntBeforeRunTaskProvider;
|
||||||
|
import com.intellij.psi.PsiFile;
|
||||||
|
import com.oracle.plugin.jtreg.configuration.JTRegConfiguration;
|
||||||
|
import com.oracle.plugin.jtreg.service.JTRegService;
|
||||||
|
import com.oracle.plugin.jtreg.configuration.JTRegConfigurationType;
|
||||||
|
import com.theoryinpractice.testng.configuration.TestNGConfiguration;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class serves as a common superclass for both file and folder-based configuration producers.
|
||||||
|
*/
|
||||||
|
public abstract class JTRegConfigurationProducer extends JavaRunConfigurationProducerBase<JTRegConfiguration> implements Cloneable {
|
||||||
|
|
||||||
|
public JTRegConfigurationProducer() {
|
||||||
|
super(JTRegConfigurationType.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isConfigurationFromContext(JTRegConfiguration unitConfiguration, ConfigurationContext context) {
|
||||||
|
final Location contextLocation = context.getLocation();
|
||||||
|
if (contextLocation == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Location location = JavaExecutionUtil.stepIntoSingleClass(contextLocation);
|
||||||
|
if (location == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
PsiFile testClass = location.getPsiElement().getContainingFile();
|
||||||
|
final String runClass = unitConfiguration.getRunClass();
|
||||||
|
return runClass != null && testClass != null && testClass.getVirtualFile() != null &&
|
||||||
|
runClass.equals(testClass.getVirtualFile().getPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldReplace(ConfigurationFromContext self, ConfigurationFromContext other) {
|
||||||
|
if (other.getConfiguration() instanceof TestNGConfiguration) {
|
||||||
|
return true;
|
||||||
|
} else if (other.getConfiguration() instanceof ApplicationConfiguration) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.shouldReplace(self, other);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initBeforeTaskActions(JTRegConfiguration configuration) {
|
||||||
|
AntConfigurationBase antConfiguration = (AntConfigurationBase)AntConfiguration.getInstance(configuration.getProject());
|
||||||
|
antConfiguration.ensureInitialized();
|
||||||
|
List<AntBuildTarget> targets = JTRegService.getInstance(configuration.getProject()).getOptTargets(antConfiguration);
|
||||||
|
if (!targets.isEmpty()) {
|
||||||
|
List<BeforeRunTask> beforeTasks = targets.stream().map(target -> {
|
||||||
|
AntBeforeRunTask beforeTask =
|
||||||
|
AntBeforeRunTaskProvider.getProvider(antConfiguration.getProject(), AntBeforeRunTaskProvider.ID)
|
||||||
|
.createTask(configuration);
|
||||||
|
beforeTask.setTargetName(target.getName());
|
||||||
|
beforeTask.setAntFileUrl(target.getModel().getBuildFile().getVirtualFile().getUrl());
|
||||||
|
beforeTask.setEnabled(true);
|
||||||
|
return beforeTask;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
RunManagerEx.getInstanceEx(configuration.getProject())
|
||||||
|
.setBeforeRunTasks(configuration, beforeTasks, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.oracle.plugin.jtreg.configuration.producers;
|
||||||
|
|
||||||
|
import com.intellij.execution.Location;
|
||||||
|
import com.intellij.execution.actions.ConfigurationContext;
|
||||||
|
import com.intellij.lang.ant.config.AntConfiguration;
|
||||||
|
import com.intellij.openapi.module.Module;
|
||||||
|
import com.intellij.openapi.util.Ref;
|
||||||
|
import com.intellij.openapi.vfs.VirtualFile;
|
||||||
|
import com.intellij.psi.PsiDirectory;
|
||||||
|
import com.intellij.psi.PsiElement;
|
||||||
|
import com.oracle.plugin.jtreg.configuration.JTRegConfiguration;
|
||||||
|
import com.oracle.plugin.jtreg.service.JTRegService;
|
||||||
|
import com.oracle.plugin.jtreg.util.JTRegUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class generates a jtreg configuration from a given folder selected in the IDE.
|
||||||
|
*/
|
||||||
|
public class JTRegDirectoryConfigurationProducer extends JTRegConfigurationProducer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean setupConfigurationFromContext(JTRegConfiguration configuration,
|
||||||
|
ConfigurationContext context,
|
||||||
|
Ref<PsiElement> ref) {
|
||||||
|
final Location contextLocation = context.getLocation();
|
||||||
|
assert contextLocation != null;
|
||||||
|
final PsiElement element = contextLocation.getPsiElement();
|
||||||
|
|
||||||
|
if (!(element instanceof PsiDirectory)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final PsiDirectory dir = (PsiDirectory) element;
|
||||||
|
final VirtualFile virtualFile = dir.getVirtualFile();
|
||||||
|
if (!JTRegUtils.isInJTRegRoot(dir)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
setupConfigurationModule(context, configuration);
|
||||||
|
final Module originalModule = configuration.getConfigurationModule().getModule();
|
||||||
|
configuration.setAlternativeJrePathEnabled(JTRegService.getInstance(configuration.getProject()).isAlternativeJrePathEnabled());
|
||||||
|
configuration.setAlternativeJrePath(JTRegService.getInstance(configuration.getProject()).getAlternativeJrePath());
|
||||||
|
configuration.setProgramParameters(JTRegService.getInstance(configuration.getProject()).getJTregOptions());
|
||||||
|
configuration.setWorkingDirectory(JTRegService.getInstance(configuration.getProject()).getWorkDir());
|
||||||
|
configuration.setPackage(virtualFile.getPath());
|
||||||
|
configuration.restoreOriginalModule(originalModule);
|
||||||
|
configuration.setName(dir.getName());
|
||||||
|
initBeforeTaskActions(configuration);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,96 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.oracle.plugin.jtreg.configuration.ui.JTRegConfigurable">
|
||||||
|
<grid id="27dc6" binding="mainPane" layout-manager="GridLayoutManager" row-count="6" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
|
<constraints>
|
||||||
|
<xy x="20" y="20" width="418" height="227"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
|
<component id="62dc1" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="workDirectory" custom-create="true">
|
||||||
|
<constraints>
|
||||||
|
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
</component>
|
||||||
|
<component id="f22" class="javax.swing.JTextField" binding="jtregOptions">
|
||||||
|
<constraints>
|
||||||
|
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="150" height="-1"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
</component>
|
||||||
|
<component id="26f59" class="com.intellij.execution.ui.JrePathEditor" binding="jrePathEditor" custom-create="true">
|
||||||
|
<constraints>
|
||||||
|
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
</component>
|
||||||
|
<vspacer id="cfbe2">
|
||||||
|
<constraints>
|
||||||
|
<grid row="5" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
</vspacer>
|
||||||
|
<component id="d8563" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="file" custom-create="true">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
</component>
|
||||||
|
<component id="d511b" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="directory" custom-create="true">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
</component>
|
||||||
|
<component id="690e3" class="javax.swing.JLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="128" height="18"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Working directory"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="30df8" class="javax.swing.JLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="128" height="18"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Options"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="4cf02" class="javax.swing.JRadioButton" binding="fileRadioButton" default-binding="true">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="128" height="28"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="File"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="6ec22" class="javax.swing.JRadioButton" binding="directoryRadioButton" default-binding="true">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="128" height="28"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Directory"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
</children>
|
||||||
|
</grid>
|
||||||
|
<buttonGroups>
|
||||||
|
<group name="testSwitcher">
|
||||||
|
<member id="4cf02"/>
|
||||||
|
<member id="6ec22"/>
|
||||||
|
</group>
|
||||||
|
</buttonGroups>
|
||||||
|
</form>
|
|
@ -0,0 +1,120 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.oracle.plugin.jtreg.configuration.ui;
|
||||||
|
|
||||||
|
import com.intellij.execution.ui.DefaultJreSelector;
|
||||||
|
import com.intellij.execution.ui.JrePathEditor;
|
||||||
|
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||||
|
import com.intellij.openapi.options.SettingsEditor;
|
||||||
|
import com.intellij.openapi.project.Project;
|
||||||
|
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||||
|
import com.intellij.openapi.util.io.FileUtil;
|
||||||
|
import com.oracle.plugin.jtreg.configuration.JTRegConfiguration;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class models the dialog associated with the (project-wide) jtreg tool settings.
|
||||||
|
*/
|
||||||
|
public class JTRegConfigurable<T extends JTRegConfiguration> extends SettingsEditor<T> {
|
||||||
|
private JTextField jtregOptions;
|
||||||
|
private TextFieldWithBrowseButton jtregDir;
|
||||||
|
private TextFieldWithBrowseButton workDirectory;
|
||||||
|
private JrePathEditor jrePathEditor;
|
||||||
|
private JPanel mainPane;
|
||||||
|
private JRadioButton fileRadioButton;
|
||||||
|
private JRadioButton directoryRadioButton;
|
||||||
|
private TextFieldWithBrowseButton file;
|
||||||
|
private TextFieldWithBrowseButton directory;
|
||||||
|
|
||||||
|
Project project;
|
||||||
|
|
||||||
|
public JTRegConfigurable(final Project project) {
|
||||||
|
this.project = project;
|
||||||
|
ActionListener listener = this::updateComponents;
|
||||||
|
fileRadioButton.addActionListener(listener);
|
||||||
|
directoryRadioButton.addActionListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createUIComponents() {
|
||||||
|
jrePathEditor = new JrePathEditor(DefaultJreSelector.projectSdk(project));
|
||||||
|
jtregDir = new TextFieldWithBrowseButton();
|
||||||
|
jtregDir.addBrowseFolderListener("Directory with Strategies", null, project, FileChooserDescriptorFactory.createSingleFolderDescriptor());
|
||||||
|
workDirectory = new TextFieldWithBrowseButton();
|
||||||
|
workDirectory.addBrowseFolderListener("Directory with Strategies", null, project, FileChooserDescriptorFactory.createSingleFolderDescriptor());
|
||||||
|
file = new TextFieldWithBrowseButton();
|
||||||
|
file.addBrowseFolderListener("File with Strategies", null, project,
|
||||||
|
FileChooserDescriptorFactory.createSingleFileDescriptor());
|
||||||
|
directory = new TextFieldWithBrowseButton();
|
||||||
|
directory.addBrowseFolderListener("Directory with Strategies", null, project,
|
||||||
|
FileChooserDescriptorFactory.createSingleFolderDescriptor());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateComponents(ActionEvent _unused) {
|
||||||
|
file.setEnabled(fileRadioButton.isSelected());
|
||||||
|
directory.setEnabled(directoryRadioButton.isSelected());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyEditorTo(final JTRegConfiguration configuration) {
|
||||||
|
configuration.setAlternativeJrePath(jrePathEditor.getJrePathOrName());
|
||||||
|
configuration.setAlternativeJrePathEnabled(jrePathEditor.isAlternativeJreSelected());
|
||||||
|
configuration.setRunClass(fileRadioButton.isSelected() ?
|
||||||
|
FileUtil.toSystemIndependentName(file.getText().trim()) : null);
|
||||||
|
configuration.setPackage(directoryRadioButton.isSelected() ?
|
||||||
|
FileUtil.toSystemIndependentName(directory.getText().trim()) : null);
|
||||||
|
configuration.setProgramParameters(jtregOptions.getText().trim());
|
||||||
|
configuration.setWorkingDirectory(workDirectory.getText().isEmpty() ?
|
||||||
|
null : FileUtil.toSystemIndependentName(workDirectory.getText().trim()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resetEditorFrom(final JTRegConfiguration configuration) {
|
||||||
|
jrePathEditor.setPathOrName(configuration.getAlternativeJrePath(), configuration.isAlternativeJrePathEnabled());
|
||||||
|
final String runClass = configuration.getRunClass();
|
||||||
|
if (runClass != null) {
|
||||||
|
fileRadioButton.setSelected(true);
|
||||||
|
file.setText(FileUtil.toSystemDependentName(runClass));
|
||||||
|
} else {
|
||||||
|
directoryRadioButton.setSelected(true);
|
||||||
|
final String aPackage = configuration.getPackage();
|
||||||
|
directory.setText(aPackage != null ? FileUtil.toSystemDependentName(aPackage) : null);
|
||||||
|
}
|
||||||
|
jtregOptions.setText(configuration.getProgramParameters());
|
||||||
|
String workDir = configuration.getWorkingDirectory();
|
||||||
|
workDirectory.setText(workDir == null ? "" : FileUtil.toSystemDependentName(workDir));
|
||||||
|
updateComponents(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public JComponent createEditor() {
|
||||||
|
return mainPane;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.oracle.plugin.jtreg.executors;
|
||||||
|
|
||||||
|
import com.intellij.debugger.engine.DebuggerUtils;
|
||||||
|
import com.intellij.debugger.impl.GenericDebuggerRunner;
|
||||||
|
import com.intellij.execution.ExecutionException;
|
||||||
|
import com.intellij.execution.configurations.RemoteConnection;
|
||||||
|
import com.intellij.execution.configurations.RunProfile;
|
||||||
|
import com.intellij.execution.configurations.RunProfileState;
|
||||||
|
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||||
|
import com.intellij.execution.ui.RunContentDescriptor;
|
||||||
|
import com.oracle.plugin.jtreg.configuration.JTRegConfiguration;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import com.oracle.plugin.jtreg.configuration.JTRegConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A custom debugger executor that publicize port choices to external clients.
|
||||||
|
*/
|
||||||
|
public class JTRegDebuggerRunner extends GenericDebuggerRunner {
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getRunnerId() {
|
||||||
|
return "JTRegDebuggerRunner";
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canRun(@NotNull String executorId, @NotNull RunProfile profile) {
|
||||||
|
return profile instanceof JTRegConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String address;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
protected RunContentDescriptor createContentDescriptor(@NotNull final RunProfileState state,
|
||||||
|
@NotNull final ExecutionEnvironment environment) throws ExecutionException {
|
||||||
|
address = DebuggerUtils.getInstance().findAvailableDebugAddress(true);
|
||||||
|
RemoteConnection connection = new RemoteConnection(true, "127.0.0.1", address, true);
|
||||||
|
return attachVirtualMachine(state, environment, connection, true);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,126 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.oracle.plugin.jtreg.runtime;
|
||||||
|
|
||||||
|
|
||||||
|
import com.oracle.plugin.jtreg.util.MapSerializerUtil;
|
||||||
|
import com.sun.javatest.Harness;
|
||||||
|
import com.sun.javatest.Parameters;
|
||||||
|
import com.sun.javatest.Status;
|
||||||
|
import com.sun.javatest.TestResult;
|
||||||
|
import com.oracle.plugin.jtreg.util.MapSerializerUtil;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The jtreg test listener; this class listens for jtreg test events and maps them into events that the IDE
|
||||||
|
* can understand and present back to the user.
|
||||||
|
*/
|
||||||
|
public class JTRegTestListener implements Harness.Observer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startingTestRun(Parameters parameters) {
|
||||||
|
System.out.println("##teamcity[testSuiteStarted name=\'jtreg\']");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startingTest(TestResult testResult) {
|
||||||
|
String location = "";
|
||||||
|
try {
|
||||||
|
location = "locationHint=\'file://" + testResult.getDescription().getFile().getCanonicalPath() + "\'";
|
||||||
|
} catch (TestResult.Fault | IOException e) {
|
||||||
|
//do nothing (leave location empty)
|
||||||
|
}
|
||||||
|
System.out.println("##teamcity[testStarted name=\'" + escapeName(testResult.getTestName()) + "\' " +
|
||||||
|
location + "]");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void finishedTest(TestResult testResult) {
|
||||||
|
final Status status = testResult.getStatus();
|
||||||
|
final File file = testResult.getFile();
|
||||||
|
if (status.isFailed() || status.isError()) {
|
||||||
|
if (file.isFile()) {
|
||||||
|
final String output = loadText(file);
|
||||||
|
if (output != null && output.length() > 0) {
|
||||||
|
System.out.println("##teamcity[testStdOut name=\'" + escapeName(testResult.getTestName()) + "\' " +
|
||||||
|
"out=\'" + escapeName(output) + "\']");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("##teamcity[testFailed name=\'" + escapeName(testResult.getTestName()) + "\' " +
|
||||||
|
"message=\'" + escapeName(status.getReason()) + "\']");
|
||||||
|
} else if (status.isNotRun()) {
|
||||||
|
System.out.println("##teamcity[testIgnored name=\'" + escapeName(testResult.getTestName()) + "\']");
|
||||||
|
}
|
||||||
|
|
||||||
|
String duration = "0";
|
||||||
|
try {
|
||||||
|
duration = testResult.getProperty("elapsed").split(" ")[0];
|
||||||
|
} catch (Throwable t) {
|
||||||
|
//do nothing (leave duration unspecified)
|
||||||
|
}
|
||||||
|
System.out.println("##teamcity[testFinished name=\'" + escapeName(testResult.getTestName()) + "\' " +
|
||||||
|
(!duration.equals("0") ? "duration=\'" + duration : "") + "\'" +
|
||||||
|
(!status.isFailed() ? "outputFile=\'" + escapeName(file.getAbsolutePath()) + "\'" : "") +
|
||||||
|
" ]");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stoppingTestRun() {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void finishedTesting() {
|
||||||
|
//do nothing
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void finishedTestRun(boolean b) {
|
||||||
|
System.out.println("##teamcity[testSuiteFinished name=\'jtreg\']");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(String s) {
|
||||||
|
System.out.println(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String escapeName(String str) {
|
||||||
|
return MapSerializerUtil.escapeStr(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String loadText(File file) {
|
||||||
|
try {
|
||||||
|
return Files.readAllLines(file.toPath()).stream().collect(Collectors.joining("\n"));
|
||||||
|
} catch (IOException e) {
|
||||||
|
return "Failed to load test results.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,199 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.oracle.plugin.jtreg.service;
|
||||||
|
|
||||||
|
import com.intellij.lang.ant.config.AntBuildFile;
|
||||||
|
import com.intellij.lang.ant.config.AntBuildTarget;
|
||||||
|
import com.intellij.lang.ant.config.AntConfiguration;
|
||||||
|
import com.intellij.lang.ant.config.AntConfigurationBase;
|
||||||
|
import com.intellij.openapi.components.*;
|
||||||
|
import com.intellij.openapi.project.Project;
|
||||||
|
import com.intellij.openapi.util.Pair;
|
||||||
|
import com.intellij.openapi.vfs.VirtualFile;
|
||||||
|
import com.oracle.plugin.jtreg.util.JTRegUtils;
|
||||||
|
import org.jdom.Element;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.java.generate.element.ElementUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class acts as a model for the jtreg tool settings ui. Its state can be persisted to the project configuration
|
||||||
|
* file, so that jtreg settings can effectively be shared on a per-project basis.
|
||||||
|
*/
|
||||||
|
@State(name = "JTRegService")
|
||||||
|
public class JTRegService implements PersistentStateComponent<Element> {
|
||||||
|
|
||||||
|
Project project;
|
||||||
|
|
||||||
|
//state
|
||||||
|
private String jtregOptions = "";
|
||||||
|
private boolean alternativeJrePathEnabled = false;
|
||||||
|
private String alternativeJrePath = "";
|
||||||
|
private String jtregDir = "";
|
||||||
|
private String workDir = "";
|
||||||
|
private List<Pair<String, String>> optTargets = new ArrayList<>();
|
||||||
|
|
||||||
|
public JTRegService(Project project) {
|
||||||
|
this.project = project;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JTRegService getInstance(Project project) {
|
||||||
|
return ServiceManager.getService(project, JTRegService.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Element getState() {
|
||||||
|
Element jtreg = new Element("jtreg");
|
||||||
|
Element jtregPath = new Element("path");
|
||||||
|
jtregPath.addContent(jtregDir);
|
||||||
|
jtreg.addContent(jtregPath);
|
||||||
|
Element jtregWork = new Element("workDir");
|
||||||
|
jtregWork.addContent(workDir);
|
||||||
|
jtreg.addContent(jtregWork);
|
||||||
|
Element jrePath = new Element("jre");
|
||||||
|
jrePath.setAttribute("alt", String.valueOf(alternativeJrePathEnabled));
|
||||||
|
if (alternativeJrePathEnabled) {
|
||||||
|
jrePath.setAttribute("value", alternativeJrePath);
|
||||||
|
}
|
||||||
|
jtreg.addContent(jrePath);
|
||||||
|
Element opts = new Element("options");
|
||||||
|
opts.addContent(jtregOptions);
|
||||||
|
jtreg.addContent(opts);
|
||||||
|
if (!optTargets.isEmpty()) {
|
||||||
|
Element ant = new Element("ant");
|
||||||
|
for (Pair<String, String> antBuildTarget : optTargets) {
|
||||||
|
Element target = new Element("target");
|
||||||
|
target.setAttribute("file", antBuildTarget.first);
|
||||||
|
target.setAttribute("name", antBuildTarget.second);
|
||||||
|
ant.addContent(target);
|
||||||
|
}
|
||||||
|
jtreg.addContent(ant);
|
||||||
|
}
|
||||||
|
return jtreg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadState(Element jtreg) {
|
||||||
|
try {
|
||||||
|
jtregDir = Optional.of(jtreg.getChildText("path")).orElse("");
|
||||||
|
workDir = Optional.of(jtreg.getChildText("workDir")).orElse("");
|
||||||
|
jtregOptions = Optional.of(jtreg.getChildText("options")).orElse("");
|
||||||
|
Element jre = jtreg.getChild("jre");
|
||||||
|
if (jre != null) {
|
||||||
|
alternativeJrePathEnabled = jre.getAttribute("alt").getBooleanValue();
|
||||||
|
if (alternativeJrePathEnabled) {
|
||||||
|
alternativeJrePath = jre.getAttribute("value").getValue();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alternativeJrePathEnabled = false;
|
||||||
|
}
|
||||||
|
Element ant = jtreg.getChild("ant");
|
||||||
|
if (ant != null) {
|
||||||
|
List<Pair<String, String>> targets = new ArrayList<>();
|
||||||
|
for (Element target : ant.getChildren("target")) {
|
||||||
|
String url = target.getAttribute("file").getValue();
|
||||||
|
String targetName = target.getAttribute("name").getValue();
|
||||||
|
targets.add(Pair.create(url, targetName));
|
||||||
|
}
|
||||||
|
optTargets = targets;
|
||||||
|
}
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJTregOptions() {
|
||||||
|
return jtregOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJTRegOptions(String jtregOptions) {
|
||||||
|
this.jtregOptions = jtregOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAlternativeJrePathEnabled() {
|
||||||
|
return alternativeJrePathEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlternativePathEnabled(boolean enabled) {
|
||||||
|
alternativeJrePathEnabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAlternativeJrePath() {
|
||||||
|
return alternativeJrePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlternativeJrePath(String alternativeJrePath) {
|
||||||
|
this.alternativeJrePath = alternativeJrePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJTRegDir() {
|
||||||
|
return jtregDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJTRegDir(String jtregDir) {
|
||||||
|
this.jtregDir = jtregDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWorkDir() {
|
||||||
|
return workDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWorkDir(String workDir) {
|
||||||
|
this.workDir = workDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOptTargets(List<AntBuildTarget> targets) {
|
||||||
|
optTargets = targets.stream()
|
||||||
|
.filter(target -> target != null)
|
||||||
|
.map(t -> Pair.create(t.getModel().getBuildFile().getVirtualFile().getUrl(), t.getName()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AntBuildTarget> getOptTargets(AntConfiguration antConfiguration) {
|
||||||
|
return optTargets.stream()
|
||||||
|
.map(p -> findTargetByFileAndName(antConfiguration, p.first, p.second))
|
||||||
|
.filter(target -> target != null)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
//where
|
||||||
|
private AntBuildTarget findTargetByFileAndName(AntConfiguration antConfiguration, String url, String name) {
|
||||||
|
for (AntBuildFile file : JTRegUtils.getAntBuildFiles(antConfiguration)) {
|
||||||
|
if (file.getVirtualFile().getUrl().equals(url)) {
|
||||||
|
AntBuildTarget foundTarget = file.getModel().findTarget(name);
|
||||||
|
if (foundTarget != null) {
|
||||||
|
return foundTarget;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,83 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.oracle.plugin.jtreg.service.ui.JTRegServiceConfigurable">
|
||||||
|
<grid id="27dc6" binding="mainPane" layout-manager="GridLayoutManager" row-count="6" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
|
<constraints>
|
||||||
|
<xy x="20" y="20" width="418" height="227"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
|
<component id="1c202" class="javax.swing.JLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="1" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="212" height="18"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Options"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="1a5cc" class="javax.swing.JLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="1" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="212" height="18"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Working directory"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="9c47c" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="jtregDir" custom-create="true">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
</component>
|
||||||
|
<component id="62dc1" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="workDir" custom-create="true">
|
||||||
|
<constraints>
|
||||||
|
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
</component>
|
||||||
|
<component id="f22" class="javax.swing.JTextField" binding="jtregOptions">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="150" height="-1"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
</component>
|
||||||
|
<component id="26f59" class="com.intellij.execution.ui.JrePathEditor" binding="jrePathEditor" custom-create="true">
|
||||||
|
<constraints>
|
||||||
|
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
</component>
|
||||||
|
<vspacer id="cfbe2">
|
||||||
|
<constraints>
|
||||||
|
<grid row="5" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
</vspacer>
|
||||||
|
<component id="712ca" class="javax.swing.JLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="212" height="18"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="JTReg Home"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<grid id="8bdf0" binding="myListPane" custom-create="true" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
|
<margin top="2" left="2" bottom="2" right="2"/>
|
||||||
|
<constraints>
|
||||||
|
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="etched" title="Ant configuration"/>
|
||||||
|
<children/>
|
||||||
|
</grid>
|
||||||
|
</children>
|
||||||
|
</grid>
|
||||||
|
</form>
|
|
@ -0,0 +1,273 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2017, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.oracle.plugin.jtreg.service.ui;
|
||||||
|
|
||||||
|
import com.intellij.execution.ExecutionBundle;
|
||||||
|
import com.intellij.execution.ui.DefaultJreSelector;
|
||||||
|
import com.intellij.execution.ui.JrePathEditor;
|
||||||
|
import com.intellij.icons.AllIcons;
|
||||||
|
import com.intellij.lang.ant.AntBundle;
|
||||||
|
import com.intellij.lang.ant.config.AntBuildTarget;
|
||||||
|
import com.intellij.lang.ant.config.AntConfiguration;
|
||||||
|
import com.intellij.lang.ant.config.AntConfigurationBase;
|
||||||
|
import com.intellij.lang.ant.config.impl.MetaTarget;
|
||||||
|
import com.intellij.lang.ant.config.impl.TargetChooserDialog;
|
||||||
|
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||||
|
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||||
|
import com.intellij.openapi.options.ConfigurationException;
|
||||||
|
import com.intellij.openapi.options.SearchableConfigurable;
|
||||||
|
import com.intellij.openapi.project.Project;
|
||||||
|
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||||
|
import com.intellij.openapi.util.Comparing;
|
||||||
|
import com.intellij.openapi.util.SystemInfo;
|
||||||
|
import com.intellij.openapi.util.io.FileUtil;
|
||||||
|
import com.intellij.ui.AnActionButton;
|
||||||
|
import com.intellij.ui.AnActionButtonRunnable;
|
||||||
|
import com.intellij.ui.AnActionButtonUpdater;
|
||||||
|
import com.intellij.ui.CollectionListModel;
|
||||||
|
import com.intellij.ui.ToolbarDecorator;
|
||||||
|
import com.intellij.ui.components.JBList;
|
||||||
|
import com.oracle.plugin.jtreg.service.JTRegService;
|
||||||
|
import com.oracle.plugin.jtreg.util.JTRegUtils;
|
||||||
|
import icons.AntIcons;
|
||||||
|
import org.jetbrains.annotations.Nls;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class models the dialog associated with the (project-wide) jtreg tool settings.
|
||||||
|
*/
|
||||||
|
public class JTRegServiceConfigurable implements SearchableConfigurable {
|
||||||
|
private JTextField jtregOptions;
|
||||||
|
private TextFieldWithBrowseButton jtregDir;
|
||||||
|
private TextFieldWithBrowseButton workDir;
|
||||||
|
private JrePathEditor jrePathEditor;
|
||||||
|
private JPanel mainPane;
|
||||||
|
private JPanel myListPane;
|
||||||
|
private CollectionListModel<AntBuildTarget> myModel;
|
||||||
|
|
||||||
|
Project project;
|
||||||
|
|
||||||
|
public JTRegServiceConfigurable(Project project) {
|
||||||
|
this.project = project;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JTRegService getJTRegService() {
|
||||||
|
return JTRegService.getInstance(project);
|
||||||
|
}
|
||||||
|
|
||||||
|
private AntConfigurationBase getAntConfigurationBase() {
|
||||||
|
return AntConfigurationBase.getInstance(project);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public JComponent createComponent() {
|
||||||
|
return mainPane;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public String getId() {
|
||||||
|
return "jtreg";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Runnable enableSearch(String s) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nls
|
||||||
|
@Override
|
||||||
|
public String getDisplayName() {
|
||||||
|
return "jtreg Settings";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public String getHelpTopic() {
|
||||||
|
return getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isModified() {
|
||||||
|
JTRegService service = getJTRegService();
|
||||||
|
AntConfigurationBase antConfiguration = getAntConfigurationBase();
|
||||||
|
return !jtregOptions.getText().trim().equals(service.getJTregOptions()) ||
|
||||||
|
jrePathEditor.isAlternativeJreSelected() != service.isAlternativeJrePathEnabled() ||
|
||||||
|
!jtregDir.getText().trim().equals(service.getJTRegDir()) ||
|
||||||
|
!workDir.getText().trim().equals(FileUtil.toSystemDependentName(service.getWorkDir())) ||
|
||||||
|
(jrePathEditor.isAlternativeJreSelected() && !Comparing.equal(jrePathEditor.getJrePathOrName(), service.getAlternativeJrePath())) ||
|
||||||
|
!myModel.getItems().equals(service.getOptTargets(antConfiguration));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply() throws ConfigurationException {
|
||||||
|
JTRegService service = getJTRegService();
|
||||||
|
service.setJTRegOptions(jtregOptions.getText().trim());
|
||||||
|
service.setAlternativePathEnabled(jrePathEditor.isAlternativeJreSelected());
|
||||||
|
service.setAlternativeJrePath(jrePathEditor.getJrePathOrName());
|
||||||
|
service.setJTRegDir(FileUtil.toSystemIndependentName(jtregDir.getText().trim()));
|
||||||
|
service.setWorkDir(workDir.getText().trim());
|
||||||
|
service.setOptTargets(myModel.getItems());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
|
JTRegService service = getJTRegService();
|
||||||
|
AntConfigurationBase antConfiguration = getAntConfigurationBase();
|
||||||
|
jtregOptions.setText(service.getJTregOptions());
|
||||||
|
jrePathEditor.setPathOrName(service.getAlternativeJrePath(), service.isAlternativeJrePathEnabled());
|
||||||
|
jtregDir.setText(FileUtil.toSystemDependentName(service.getJTRegDir()));
|
||||||
|
workDir.setText(FileUtil.toSystemDependentName(service.getWorkDir()));
|
||||||
|
myModel.removeAll();
|
||||||
|
for (AntBuildTarget target : service.getOptTargets(antConfiguration)) {
|
||||||
|
myModel.add(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disposeUIResources() {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createUIComponents() {
|
||||||
|
jrePathEditor = new JrePathEditor(DefaultJreSelector.projectSdk(project));
|
||||||
|
jtregDir = new TextFieldWithBrowseButton();
|
||||||
|
jtregDir.addBrowseFolderListener("Directory with Strategies", null, project, FileChooserDescriptorFactory.createSingleFolderDescriptor());
|
||||||
|
workDir = new TextFieldWithBrowseButton();
|
||||||
|
workDir.addBrowseFolderListener("Directory with Strategies", null, project, FileChooserDescriptorFactory.createSingleFolderDescriptor());
|
||||||
|
myModel = new CollectionListModel<>();
|
||||||
|
JBList<AntBuildTarget> myList = new JBList<>(myModel);
|
||||||
|
myList.getEmptyText().setText(ExecutionBundle.message("before.launch.panel.empty"));
|
||||||
|
myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
|
myList.setCellRenderer(new MyListCellRenderer());
|
||||||
|
|
||||||
|
ToolbarDecorator myDecorator = ToolbarDecorator.createDecorator(myList);
|
||||||
|
if (!SystemInfo.isMac) {
|
||||||
|
myDecorator.setAsUsualTopToolbar();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AntConfigurationBase antConfiguration = getAntConfigurationBase();
|
||||||
|
antConfiguration.ensureInitialized();
|
||||||
|
boolean antConfigEnabled = JTRegUtils.getAntBuildFiles(antConfiguration).length != 0;
|
||||||
|
|
||||||
|
myDecorator.setEditAction(new AnActionButtonRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run(AnActionButton button) {
|
||||||
|
int index = myList.getSelectedIndex();
|
||||||
|
if (index == -1)
|
||||||
|
return;
|
||||||
|
AntBuildTarget prevTarget = myModel.getElementAt(index);
|
||||||
|
AntBuildTarget newTarget = pickTarget(prevTarget);
|
||||||
|
if (newTarget != null) {
|
||||||
|
myModel.setElementAt(newTarget, index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
myDecorator.setEditActionUpdater(new AnActionButtonUpdater() {
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled(AnActionEvent e) {
|
||||||
|
int index = myList.getSelectedIndex();
|
||||||
|
return index != -1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
myDecorator.setAddAction(new AnActionButtonRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run(AnActionButton button) {
|
||||||
|
AntBuildTarget target = pickTarget(null);
|
||||||
|
myModel.add(target);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
myDecorator.setAddActionUpdater(new AnActionButtonUpdater() {
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled(AnActionEvent e) {
|
||||||
|
return antConfigEnabled;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
myListPane = myDecorator.createPanel();
|
||||||
|
}
|
||||||
|
|
||||||
|
AntBuildTarget pickTarget(AntBuildTarget prev) {
|
||||||
|
TargetChooserDialog dlg = new TargetChooserDialog(project, prev);
|
||||||
|
if (dlg.showAndGet()) {
|
||||||
|
return dlg.getSelectedTarget();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Icon TARGET;
|
||||||
|
|
||||||
|
static {
|
||||||
|
//some reflective goop to retain compatibility with earlier versions
|
||||||
|
Class<?>[] iconClasses = { AntIcons.class, AllIcons.Nodes.class };
|
||||||
|
Field targetIcon;
|
||||||
|
for (Class<?> iconClass : iconClasses) {
|
||||||
|
try {
|
||||||
|
targetIcon = iconClass.getDeclaredField("Target");
|
||||||
|
TARGET = (Icon) targetIcon.get(null);
|
||||||
|
break;
|
||||||
|
} catch (ReflectiveOperationException ex) {
|
||||||
|
// try again
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (TARGET == null) {
|
||||||
|
throw new ExceptionInInitializerError("Cannot find Target icon!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class MyListCellRenderer extends JBList.StripedListCellRenderer {
|
||||||
|
@Override
|
||||||
|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
if (value instanceof AntBuildTarget) {
|
||||||
|
AntBuildTarget target = (AntBuildTarget) value;
|
||||||
|
setIcon(getTaskIcon(target));
|
||||||
|
setText(getDescription(target));
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Icon getTaskIcon(AntBuildTarget antTarget) {
|
||||||
|
return antTarget instanceof MetaTarget ? AntIcons.MetaTarget : TARGET;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription(AntBuildTarget antTarget) {
|
||||||
|
String targetName = antTarget.getName();
|
||||||
|
return targetName == null ?
|
||||||
|
AntBundle.message("ant.target.before.run.description.empty", new Object[0]) :
|
||||||
|
AntBundle.message("ant.target.before.run.description", new Object[]{targetName != null ? targetName : "<not selected>"});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.oracle.plugin.jtreg.templates;
|
||||||
|
|
||||||
|
import com.intellij.codeInsight.template.impl.DefaultLiveTemplatesProvider;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provider class for jtreg active templates
|
||||||
|
*/
|
||||||
|
public class JTRegTemplateProvider implements DefaultLiveTemplatesProvider {
|
||||||
|
@Override
|
||||||
|
public String[] getDefaultLiveTemplateFiles() {
|
||||||
|
return new String[]{"liveTemplates/jtreg"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public String[] getHiddenLiveTemplateFiles() {
|
||||||
|
return new String[0];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,123 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.oracle.plugin.jtreg.util;
|
||||||
|
|
||||||
|
import com.intellij.psi.PsiComment;
|
||||||
|
import com.intellij.psi.tree.java.IJavaElementType;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple parser for jtreg tags.
|
||||||
|
*/
|
||||||
|
public class JTRegTagParser {
|
||||||
|
|
||||||
|
private static final Pattern TAG_PATTERN = Pattern.compile("@([a-zA-Z]+)(\\s+|$)");
|
||||||
|
|
||||||
|
public static Result parseTags(PsiComment header) {
|
||||||
|
String text = header.getText();
|
||||||
|
List<Tag> tags = new ArrayList<>();
|
||||||
|
int start = -1;
|
||||||
|
int end = -1;
|
||||||
|
int tagStart = -1;
|
||||||
|
int tagEnd = -1;
|
||||||
|
|
||||||
|
text = text.substring(0, text.length() - 2);
|
||||||
|
|
||||||
|
String tagName = null;
|
||||||
|
StringBuilder tagText = new StringBuilder();
|
||||||
|
int prefix = header.getTokenType() instanceof IJavaElementType ? 2 : 3;
|
||||||
|
String[] lines = text.substring(prefix).split("\n");
|
||||||
|
int pos = header.getTextOffset() + prefix;
|
||||||
|
|
||||||
|
for (String line : lines) {
|
||||||
|
if (line.replaceAll("[*\\s]+", "").isEmpty()) {
|
||||||
|
pos += line.length() + 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Matcher m = TAG_PATTERN.matcher(line);
|
||||||
|
if (m.find()) {
|
||||||
|
if (tagName != null) {
|
||||||
|
tags.add(new Tag(start, pos, tagStart, tagEnd, tagName, tagText.toString()));
|
||||||
|
tagText.delete(0, tagText.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
tagName = m.group(1);
|
||||||
|
|
||||||
|
start = pos;
|
||||||
|
tagStart = pos + m.start();
|
||||||
|
tagEnd = pos + m.end(1);
|
||||||
|
tagText.append(line.substring(m.end()));
|
||||||
|
} else if (tagName != null) {
|
||||||
|
int asterisk = line.indexOf('*');
|
||||||
|
tagText.append(line.substring(asterisk + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
pos += line.length() + 1;
|
||||||
|
|
||||||
|
if (tagName != null) {
|
||||||
|
end = pos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tagName != null) {
|
||||||
|
tags.add(new Tag(start, end, tagStart, tagEnd, tagName, tagText.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, List<Tag>> result = new HashMap<>();
|
||||||
|
|
||||||
|
for (Tag tag : tags) {
|
||||||
|
List<Tag> innerTags = result.get(tag.getName());
|
||||||
|
|
||||||
|
if (innerTags == null) {
|
||||||
|
result.put(tag.getName(), innerTags = new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
innerTags.add(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Result(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class holding parser results.
|
||||||
|
*/
|
||||||
|
public static final class Result {
|
||||||
|
private final Map<String, List<Tag>> name2Tag;
|
||||||
|
|
||||||
|
public Result(Map<String, List<Tag>> name2Tag) {
|
||||||
|
this.name2Tag = name2Tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<Tag>> getName2Tag() {
|
||||||
|
return name2Tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,349 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 2019 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.oracle.plugin.jtreg.util;
|
||||||
|
|
||||||
|
import com.intellij.lang.ant.config.AntBuildFile;
|
||||||
|
import com.intellij.lang.ant.config.AntConfiguration;
|
||||||
|
import com.intellij.openapi.project.Project;
|
||||||
|
import com.intellij.openapi.vfs.VirtualFile;
|
||||||
|
import com.intellij.psi.*;
|
||||||
|
import com.intellij.psi.util.PsiTreeUtil;
|
||||||
|
import com.intellij.psi.util.PsiUtil;
|
||||||
|
import com.intellij.openapi.diagnostic.Logger;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class contains several helper routines that are used by the jtreg plugin.
|
||||||
|
*/
|
||||||
|
public class JTRegUtils {
|
||||||
|
|
||||||
|
private static final Logger LOG = Logger.getInstance(JTRegUtils.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Are we inside a jtreg test root?
|
||||||
|
*/
|
||||||
|
public static boolean isInJTRegRoot(PsiDirectory dir) {
|
||||||
|
return dir != null ?
|
||||||
|
isInJTRegRoot(dir.getVirtualFile()) :
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Are we inside a jtreg test root?
|
||||||
|
*/
|
||||||
|
public static boolean isInJTRegRoot(VirtualFile file) {
|
||||||
|
return findJTRegRoot(file) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a file, searches up the vfs hierarchy for the closest parent directory containing the
|
||||||
|
* associated test suite config (TEST.ROOT).
|
||||||
|
* @param file the file
|
||||||
|
* @return file referring to the test root directory or null if not found
|
||||||
|
*/
|
||||||
|
public static VirtualFile findJTRegRoot(VirtualFile file) {
|
||||||
|
VirtualFile test_root_file = findRootFile(file);
|
||||||
|
if (test_root_file != null) {
|
||||||
|
return file.getParent();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a file, searches up the vfs hierarchy for the associated test suite
|
||||||
|
* configuration (a TEST.ROOT file in a parent directory).
|
||||||
|
* @param file the virtual file
|
||||||
|
* @return virtual file referring to TEST.ROOT or null if not found.
|
||||||
|
*/
|
||||||
|
private static VirtualFile findRootFile(VirtualFile file) {
|
||||||
|
while (file != null) {
|
||||||
|
VirtualFile rootFile = file.findChild("TEST.ROOT");
|
||||||
|
if (rootFile != null) {
|
||||||
|
return rootFile;
|
||||||
|
}
|
||||||
|
file = file.getParent();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a test suite configuration.
|
||||||
|
* @param rootFile a file representing a test suite configuration (TEST.ROOT)
|
||||||
|
* @return a Properties object containing the parsed TEST.ROOT
|
||||||
|
*/
|
||||||
|
private static Properties parseTestSuiteConfig(VirtualFile rootFile) {
|
||||||
|
Properties prop = null;
|
||||||
|
try {
|
||||||
|
prop = new Properties();
|
||||||
|
InputStream input = rootFile.getInputStream();
|
||||||
|
prop.load(input);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return prop;
|
||||||
|
}
|
||||||
|
|
||||||
|
// cache parsed test configurations.
|
||||||
|
private static HashMap<VirtualFile, Properties> _cachedTestConfigs = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a test suite configuration.
|
||||||
|
* @param rootFile a file representing a test suite configuration (TEST.ROOT)
|
||||||
|
* @return a Properties object containing the parsed TEST.ROOT
|
||||||
|
*/
|
||||||
|
private static Properties testSuiteConfigForRootFile(VirtualFile rootFile) {
|
||||||
|
Properties p = _cachedTestConfigs.get(rootFile);
|
||||||
|
if (p == null) {
|
||||||
|
p = parseTestSuiteConfig(rootFile);
|
||||||
|
if (p != null) {
|
||||||
|
LOG.debug("Parsing test suite config " + rootFile + "...");
|
||||||
|
_cachedTestConfigs.put(rootFile, p);
|
||||||
|
LOG.debug("Content: " + p);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOG.debug("Returning cached test suite config for " + rootFile);
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the given file a jtreg test?
|
||||||
|
*/
|
||||||
|
public static boolean isJTRegTestData(Project project, VirtualFile file) {
|
||||||
|
return isJTRegTestData(PsiUtil.getPsiFile(project, file));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the given file a jtreg test?
|
||||||
|
*/
|
||||||
|
public static boolean isJTRegTestData(PsiFile file) {
|
||||||
|
if (file instanceof PsiJavaFile) {
|
||||||
|
return PsiTreeUtil.findChildrenOfType(file, PsiComment.class).stream()
|
||||||
|
.anyMatch(JTRegUtils::hasTestTag);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the source roots associated with a jtreg test.
|
||||||
|
*/
|
||||||
|
public static List<VirtualFile> getTestRoots(Project project, VirtualFile file) {
|
||||||
|
return isJTRegTestData(project, file) ?
|
||||||
|
getJTRegRoots(PsiUtil.getPsiFile(project, file)) :
|
||||||
|
getTestNgRoots(PsiUtil.getPsiFile(project, file));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the source roots associated with a testng test.
|
||||||
|
*/
|
||||||
|
public static List<VirtualFile> getTestNgRoots(PsiFile file) {
|
||||||
|
VirtualFile pkgRoot = getPackageRoot(file);
|
||||||
|
return pkgRoot == null ?
|
||||||
|
Collections.singletonList(file.getVirtualFile().getParent()) :
|
||||||
|
Collections.singletonList(pkgRoot);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Infer the source root given a package name.
|
||||||
|
*/
|
||||||
|
public static VirtualFile getPackageRoot(PsiFile file) {
|
||||||
|
if (file instanceof PsiJavaFile) {
|
||||||
|
Optional<PsiPackageStatement> optPackageDecl = PsiTreeUtil.findChildrenOfType(file, PsiPackageStatement.class).stream().findFirst();
|
||||||
|
if (optPackageDecl.isPresent()) {
|
||||||
|
String[] pkgs = optPackageDecl.get().getPackageName().split("\\.");
|
||||||
|
VirtualFile root = file.getVirtualFile();
|
||||||
|
for (int i = pkgs.length - 1 ; i >= 0 ; i--) {
|
||||||
|
root = root.getParent();
|
||||||
|
if (!root.getName().equals(pkgs[i])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return root.getParent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the source roots associated with jtreg test with header.
|
||||||
|
*/
|
||||||
|
public static List<VirtualFile> getJTRegRoots(PsiFile file) {
|
||||||
|
LOG.debug("JTregRoots for " + file + "...");
|
||||||
|
if (file instanceof PsiJavaFile) {
|
||||||
|
Optional<PsiComment> optHeader = PsiTreeUtil.findChildrenOfType(file, PsiComment.class).stream()
|
||||||
|
.filter(JTRegUtils::hasTestTag).findFirst();
|
||||||
|
if (optHeader.isPresent()) {
|
||||||
|
PsiComment header = getTestHeader(optHeader.get());
|
||||||
|
List<VirtualFile> roots = new ArrayList<>();
|
||||||
|
VirtualFile pkgRoot = getPackageRoot(file);
|
||||||
|
if (pkgRoot != null) {
|
||||||
|
LOG.debug("Package root: " + pkgRoot.getParent());
|
||||||
|
roots.add(pkgRoot);
|
||||||
|
} else {
|
||||||
|
LOG.debug("Package root not found, adding immediate parent.");
|
||||||
|
roots.add(file.getVirtualFile().getParent());
|
||||||
|
}
|
||||||
|
JTRegTagParser.Result result = JTRegTagParser.parseTags(header);
|
||||||
|
//watch out for library tags
|
||||||
|
List<Tag> libTags = result.getName2Tag().get("library");
|
||||||
|
if (libTags != null) {
|
||||||
|
for (Tag libTag : libTags) {
|
||||||
|
String libVal = libTag.getValue();
|
||||||
|
for (String lib : libVal.split(" ")) {
|
||||||
|
VirtualFile libFile = null;
|
||||||
|
LOG.debug("Processing @library \"" + lib + "\"...");
|
||||||
|
if (lib.startsWith("/")) {
|
||||||
|
//absolute
|
||||||
|
// Excerpt from jtreg tags specification:
|
||||||
|
// "If an argument begins with '/', it will first be evaluated relative to the root
|
||||||
|
// directory of the test suite. It is an error if the resulting path is outside the
|
||||||
|
// test suite."
|
||||||
|
VirtualFile testRootFile = findRootFile(file.getVirtualFile());
|
||||||
|
if (testRootFile != null) {
|
||||||
|
VirtualFile jtRegRoot = testRootFile.getParent();
|
||||||
|
libFile = jtRegRoot.findFileByRelativePath(lib.substring(1));
|
||||||
|
if (libFile != null) {
|
||||||
|
LOG.debug("Found : " + libFile + " relative to test suite root.");
|
||||||
|
} else {
|
||||||
|
// "If the result does not identify an existing directory, it will be further
|
||||||
|
// evaluated against each entry of a search path in turn, until an existing
|
||||||
|
// directory is found. The search path is specified by the external.lib.roots
|
||||||
|
// entry in the test suite configuration files."
|
||||||
|
LOG.debug("Nothing found relative to test suite root.");
|
||||||
|
Properties testSuiteConfig = testSuiteConfigForRootFile(testRootFile);
|
||||||
|
if (testSuiteConfig != null) {
|
||||||
|
String s = testSuiteConfig.getProperty("external.lib.roots").trim();
|
||||||
|
if (s != null) {
|
||||||
|
LOG.debug("external.lib.roots = \"" + s + "\"");
|
||||||
|
// Note: jtreg tag specification for "external.lib.roots" talks about a
|
||||||
|
// search path with separate segments; however, all usages I see in our
|
||||||
|
// configurations are single paths, so to keep matters simple I treat it
|
||||||
|
// as a single path.
|
||||||
|
// The "external.lib.roots" is relative to the jtreg root
|
||||||
|
VirtualFile searchPath = jtRegRoot.findFileByRelativePath(s);
|
||||||
|
if (searchPath != null) {
|
||||||
|
libFile = searchPath.findFileByRelativePath(lib);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//relative
|
||||||
|
libFile = file.getParent().getVirtualFile().findFileByRelativePath(lib);
|
||||||
|
}
|
||||||
|
if (libFile != null) {
|
||||||
|
LOG.debug("@library \"" + lib + "\" resolves to " + libFile + ".");
|
||||||
|
if (libFile.exists()) {
|
||||||
|
LOG.debug("which exists.");
|
||||||
|
roots.add(libFile);
|
||||||
|
} else {
|
||||||
|
LOG.debug("which does not exists.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return roots;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the given file a testng test?
|
||||||
|
*/
|
||||||
|
public static boolean isTestNGTestData(Project project, VirtualFile file) {
|
||||||
|
return isTestNGTestData(PsiUtil.getPsiFile(project, file));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the given file a testng test?
|
||||||
|
*/
|
||||||
|
public static boolean isTestNGTestData(PsiFile file) {
|
||||||
|
// if (file instanceof PsiJavaFile) {
|
||||||
|
// for (PsiClass psiClass : ((PsiJavaFile) file).getClasses()) {
|
||||||
|
// if (TestNGUtil.isTestNGClass(psiClass)) return true;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//would be nice to rely on TestNG to do this (see above) but doesn't work as the file is not
|
||||||
|
//under test root (yet!) so we use an heuristics instead (look for 'import org.testng')
|
||||||
|
if (file instanceof PsiJavaFile) {
|
||||||
|
return Stream.of(((PsiJavaFile) file).getImportList().getImportStatements())
|
||||||
|
.anyMatch(JTRegUtils::isTestNGImport);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the given file a testng test?
|
||||||
|
*/
|
||||||
|
public static boolean isTestNGImport(PsiImportStatement importStatement) {
|
||||||
|
String qualifiedName = importStatement.getQualifiedName();
|
||||||
|
//qualifiedName can be null if the import statement hasn't been fully written yet
|
||||||
|
return qualifiedName != null && qualifiedName.startsWith("org.testng");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does the given file contain a jtreg header?
|
||||||
|
*/
|
||||||
|
private static boolean hasTestTag(PsiElement e) {
|
||||||
|
return getTestHeader(e) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does the given file contain a jtreg header?
|
||||||
|
*/
|
||||||
|
private static PsiComment getTestHeader(PsiElement e) {
|
||||||
|
while (e instanceof PsiComment) {
|
||||||
|
PsiComment comment = (PsiComment) e;
|
||||||
|
if (comment.getText().contains("@test")) {
|
||||||
|
return comment;
|
||||||
|
}
|
||||||
|
e = PsiTreeUtil.skipSiblingsForward(e, PsiWhiteSpace.class);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Workaround incompatible signature change from 2016.2 to 2016.3
|
||||||
|
*/
|
||||||
|
public static AntBuildFile[] getAntBuildFiles(AntConfiguration antConfiguration) {
|
||||||
|
try {
|
||||||
|
Method m = antConfiguration.getClass().getDeclaredMethod("getBuildFiles");
|
||||||
|
return (AntBuildFile[])m.invoke(antConfiguration);
|
||||||
|
} catch (ReflectiveOperationException ex) {
|
||||||
|
throw new IllegalStateException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,104 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.oracle.plugin.jtreg.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Misc utility methods for formatting test results messages back onto the IDE console.
|
||||||
|
*/
|
||||||
|
public class MapSerializerUtil {
|
||||||
|
|
||||||
|
static final char ESC_CHAR = '|';
|
||||||
|
|
||||||
|
static char escape(final char c) {
|
||||||
|
switch (c) {
|
||||||
|
case '\n':
|
||||||
|
return 'n';
|
||||||
|
case '\r':
|
||||||
|
return 'r';
|
||||||
|
case '\u0085':
|
||||||
|
return 'x'; // next-line character
|
||||||
|
case '\u2028':
|
||||||
|
return 'l'; // line-separator character
|
||||||
|
case '\u2029':
|
||||||
|
return 'p'; // paragraph-separator character
|
||||||
|
case '|':
|
||||||
|
return '|';
|
||||||
|
case '\'':
|
||||||
|
return '\'';
|
||||||
|
case '[':
|
||||||
|
return '[';
|
||||||
|
case ']':
|
||||||
|
return ']';
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Escapes characters specified by provider with '\' and specified character.
|
||||||
|
*
|
||||||
|
* @param str initial string
|
||||||
|
* @return escaped string.
|
||||||
|
*/
|
||||||
|
public static String escapeStr(final String str) {
|
||||||
|
if (str == null) return null;
|
||||||
|
int finalCount = calcFinalEscapedStringCount(str);
|
||||||
|
|
||||||
|
if (str.length() == finalCount) return str;
|
||||||
|
|
||||||
|
char[] resultChars = new char[finalCount];
|
||||||
|
int resultPos = 0;
|
||||||
|
for (int i = 0; i < str.length(); i++) {
|
||||||
|
char c = str.charAt(i);
|
||||||
|
final char escaped = escape(c);
|
||||||
|
if (escaped != 0) {
|
||||||
|
resultChars[resultPos++] = ESC_CHAR;
|
||||||
|
resultChars[resultPos++] = escaped;
|
||||||
|
} else {
|
||||||
|
resultChars[resultPos++] = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resultPos != finalCount) {
|
||||||
|
throw new RuntimeException("Incorrect escaping for '" + str + "'");
|
||||||
|
}
|
||||||
|
return new String(resultChars);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int calcFinalEscapedStringCount(final String name) {
|
||||||
|
int result = 0;
|
||||||
|
for (int i = 0; i < name.length(); i++) {
|
||||||
|
char c = name.charAt(i);
|
||||||
|
if (escape(c) != 0) {
|
||||||
|
result += 2;
|
||||||
|
} else {
|
||||||
|
result += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.oracle.plugin.jtreg.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class models a jtreg test tag. For a full specification of jtreg tags please refer to the following
|
||||||
|
* document: {@link "http://openjdk.java.net/jtreg/tag-spec.html"}.
|
||||||
|
*/
|
||||||
|
public class Tag {
|
||||||
|
private final int start;
|
||||||
|
private final int end;
|
||||||
|
private final int tagStart;
|
||||||
|
private final int tagEnd;
|
||||||
|
private final String name;
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
public Tag(int start, int end, int tagStart, int tagEnd, String name, String value) {
|
||||||
|
this.start = start;
|
||||||
|
this.end = end;
|
||||||
|
this.tagStart = tagStart;
|
||||||
|
this.tagEnd = tagEnd;
|
||||||
|
this.name = name;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStart() {
|
||||||
|
return start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEnd() {
|
||||||
|
return end;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTagStart() {
|
||||||
|
return tagStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTagEnd() {
|
||||||
|
return tagEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package icons;
|
||||||
|
|
||||||
|
import com.intellij.openapi.util.IconLoader;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public interface JTRegPluginIcons {
|
||||||
|
Icon JTREG_ICON_32 = IconLoader.findIcon("/com/oracle/plugin/jtreg/icons/JavaCup32.png");
|
||||||
|
|
||||||
|
Icon JTREG_ICON_16 = IconLoader.findIcon("/com/oracle/plugin/jtreg/icons/JavaCup16.png");
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2016, 2019 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<idea-plugin>
|
||||||
|
<id>jtreg</id>
|
||||||
|
<name>jtreg Test Support</name>
|
||||||
|
<description><![CDATA[
|
||||||
|
Allows execution of tests developed using the <a href="http://openjdk.java.net/jtreg/">jtreg</a> framework.
|
||||||
|
]]></description>
|
||||||
|
|
||||||
|
<depends>AntSupport</depends>
|
||||||
|
<depends>TestNG-J</depends>
|
||||||
|
|
||||||
|
<extensions defaultExtensionNs="com.intellij">
|
||||||
|
<programRunner implementation="com.oracle.plugin.jtreg.executors.JTRegDebuggerRunner"/>
|
||||||
|
<configurationType implementation="com.oracle.plugin.jtreg.configuration.JTRegConfigurationType"/>
|
||||||
|
<runConfigurationProducer implementation="com.oracle.plugin.jtreg.configuration.producers.JTRegClassConfigurationProducer"/>
|
||||||
|
<runConfigurationProducer
|
||||||
|
implementation="com.oracle.plugin.jtreg.configuration.producers.JTRegDirectoryConfigurationProducer"/>
|
||||||
|
<projectConfigurable displayName="jtreg" id="jtreg" instance="com.oracle.plugin.jtreg.service.ui.JTRegServiceConfigurable"/>
|
||||||
|
<projectService serviceImplementation="com.oracle.plugin.jtreg.service.JTRegService"/>
|
||||||
|
<defaultLiveTemplatesProvider implementation="com.oracle.plugin.jtreg.templates.JTRegTemplateProvider"/>
|
||||||
|
</extensions>
|
||||||
|
|
||||||
|
<project-components>
|
||||||
|
<component>
|
||||||
|
<implementation-class>com.oracle.plugin.jtreg.components.JTRegApplicationComponent</implementation-class>
|
||||||
|
</component>
|
||||||
|
</project-components>
|
||||||
|
</idea-plugin>
|
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.8 KiB |
|
@ -0,0 +1,21 @@
|
||||||
|
<templateSet group="jtreg">
|
||||||
|
<template name="@test" value="@test * @bug $BUG_ID$ * @summary $BUG_SUMMARY$ * $JTREG_ACTION$ $FILE_NAME$" description="jtreg header (positive test)" toReformat="false" toShortenFQNames="true">
|
||||||
|
<variable name="BUG_ID" expression="groovyScript("_1 ==~ /T\\d{7}/ ? _1.substring(1).take(7) : 'NNNNNNN'", fileNameWithoutExtension())" defaultValue="" alwaysStopAt="true" />
|
||||||
|
<variable name="BUG_SUMMARY" expression=""Bug summary"" defaultValue="" alwaysStopAt="true" />
|
||||||
|
<variable name="JTREG_ACTION" expression=""@compile"" defaultValue="" alwaysStopAt="true" />
|
||||||
|
<variable name="FILE_NAME" expression="fileName()" defaultValue="" alwaysStopAt="true" />
|
||||||
|
<context>
|
||||||
|
<option name="JAVA_COMMENT" value="true" />
|
||||||
|
</context>
|
||||||
|
</template>
|
||||||
|
<template name="@test /nodynamiccopyright/" value="@test /nodynamiccopyright/ * @bug $BUG_ID$ * @summary $BUG_SUMMARY$ * $JTREG_ACTION$/fail/ref=$GOLDEN_NAME$ -XDrawDiagnostics $FILE_NAME$" description="jtreg header (negative test)" toReformat="false" toShortenFQNames="true">
|
||||||
|
<variable name="BUG_ID" expression="groovyScript("_1 ==~ /T\\d{7}/ ? _1.substring(1).take(7) : 'NNNNNNN'", fileNameWithoutExtension())" defaultValue="NNNNNNN" alwaysStopAt="true" />
|
||||||
|
<variable name="BUG_SUMMARY" expression=""Bug summary"" defaultValue="" alwaysStopAt="true" />
|
||||||
|
<variable name="JTREG_ACTION" expression=""@compile"" defaultValue="" alwaysStopAt="true" />
|
||||||
|
<variable name="GOLDEN_NAME" expression="groovyScript("_1 + '.out'", fileNameWithoutExtension())" defaultValue="out.txt" alwaysStopAt="true" />
|
||||||
|
<variable name="FILE_NAME" expression="fileName()" defaultValue="" alwaysStopAt="true" />
|
||||||
|
<context>
|
||||||
|
<option name="JAVA_COMMENT" value="true" />
|
||||||
|
</context>
|
||||||
|
</template>
|
||||||
|
</templateSet>
|
|
@ -0,0 +1,127 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Copyright (c) 1998, 2015, 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Usage:
|
||||||
|
# jtdiff ...args....
|
||||||
|
#
|
||||||
|
# jtdiff requires a version of Java equivalent to JDK 1.5.0 or higher.
|
||||||
|
|
||||||
|
# $JT_HOME can be used to specify the jtdiff installation directory
|
||||||
|
# (e.g. /usr/local/java/jct-tools/3.2.2)
|
||||||
|
#
|
||||||
|
# $JT_JAVA is used to specify the version of java to use when running JavaTest
|
||||||
|
# (e.g. /usr/local/java/jdk1.5.0/solaris-sparc/bin/java)
|
||||||
|
#
|
||||||
|
# jtdiff also provides an Ant task for direct invocation from Ant.
|
||||||
|
|
||||||
|
if [ -z "${JT_HOME}" ]; then
|
||||||
|
JT_HOME="/usr/share/jtreg"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Determine jtdiff/JavaTest installation directory
|
||||||
|
if [ -n "$JT_HOME" ]; then
|
||||||
|
if [ ! -r $JT_HOME/lib/jtreg.jar ];then
|
||||||
|
echo "Invalid JT_HOME=$JT_HOME. Cannot find or read $JT_HOME/lib/jtreg.jar"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Deduce where script is installed
|
||||||
|
# - should work on most derivatives of Bourne shell, like ash, bash, ksh,
|
||||||
|
# sh, zsh, etc, including on Windows, MKS (ksh) and Cygwin (ash or bash)
|
||||||
|
if type -p type 1>/dev/null 2>&1 && test -z "`type -p type`" ; then
|
||||||
|
myname=`type -p "$0"`
|
||||||
|
elif type type 1>/dev/null 2>&1 ; then
|
||||||
|
myname=`type "$0" | sed -e 's/^.* is a tracked alias for //' -e 's/^.* is //'`
|
||||||
|
elif whence whence 1>/dev/null 2>&1 ; then
|
||||||
|
myname=`whence "$0"`
|
||||||
|
fi
|
||||||
|
mydir=`dirname "$myname"`
|
||||||
|
p=`cd "$mydir" ; pwd`
|
||||||
|
while [ -n "$p" -a "$p" != "/" ]; do
|
||||||
|
if [ -r "$p"/lib/jtreg.jar ]; then JT_HOME="$p" ; break; fi
|
||||||
|
p=`dirname "$p"`
|
||||||
|
done
|
||||||
|
if [ -z "$JT_HOME" ]; then
|
||||||
|
echo "Cannot determine JT_HOME; please set it explicitly"; exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Normalize JT_HOME if using Cygwin
|
||||||
|
case "`uname -s`" in
|
||||||
|
CYGWIN* ) cygwin=1 ; JT_HOME=`cygpath -a -m "$JT_HOME"` ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
# Separate out -J* options for the JVM
|
||||||
|
# Unset IFS and use newline as arg separator to preserve spaces in args
|
||||||
|
DUALCASE=1 # for MKS: make case statement case-sensitive (6709498)
|
||||||
|
saveIFS="$IFS"
|
||||||
|
nl='
|
||||||
|
'
|
||||||
|
for i in "$@" ; do
|
||||||
|
IFS=
|
||||||
|
if [ -n "$cygwin" ]; then i=`echo $i | sed -e 's|/cygdrive/\([A-Za-z]\)/|\1:/|'` ; fi
|
||||||
|
case $i in
|
||||||
|
-J* ) javaOpts=$javaOpts$nl`echo $i | sed -e 's/^-J//'` ;;
|
||||||
|
* ) jtdiffOpts=$jtdiffOpts$nl$i ;;
|
||||||
|
esac
|
||||||
|
IFS="$saveIFS"
|
||||||
|
done
|
||||||
|
unset DUALCASE
|
||||||
|
|
||||||
|
# Determine java for jtdiff, from JT_JAVA, JAVA_HOME, java
|
||||||
|
if [ -n "$JT_JAVA" ]; then
|
||||||
|
if [ -d "$JT_JAVA" ]; then
|
||||||
|
JT_JAVA="$JT_JAVA/bin/java"
|
||||||
|
fi
|
||||||
|
elif [ -n "$JAVA_HOME" ]; then
|
||||||
|
JT_JAVA="$JAVA_HOME/bin/java"
|
||||||
|
else
|
||||||
|
JT_JAVA=/usr/lib/jvm/default-java/bin/java
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Verify java version (1.)5 or newer used to run jtdiff
|
||||||
|
version=`"$JT_JAVA" -classpath "${JT_HOME}/lib/jtreg.jar" com.sun.javatest.regtest.agent.GetSystemProperty java.version 2>&1 |
|
||||||
|
grep 'java.version=' | sed -e 's/^.*=//' -e 's/^1\.//' -e 's/\([1-9][0-9]*\).*/\1/'`
|
||||||
|
|
||||||
|
if [ -z "$version" ]; then
|
||||||
|
echo "Cannot determine version of java to run jtdiff"
|
||||||
|
exit 1;
|
||||||
|
elif [ "$version" -lt 5 ]; then
|
||||||
|
echo "java version 5 or later is required to run jtdiff"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
# And finally ...
|
||||||
|
|
||||||
|
IFS=$nl
|
||||||
|
|
||||||
|
"${JT_JAVA:-${JAVA_HOME:+$JAVA_HOME/bin/}java}" \
|
||||||
|
$javaOpts \
|
||||||
|
-Dprogram=`basename "$0"` \
|
||||||
|
-cp "${JT_HOME}/lib/jtreg.jar" \
|
||||||
|
com.sun.javatest.diff.Main \
|
||||||
|
$jtdiffOpts
|
|
@ -0,0 +1,182 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Copyright (c) 1998, 2020, 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Usage:
|
||||||
|
# jtreg ...args....
|
||||||
|
# Run the application via the regression test-suite front end
|
||||||
|
# with the given arguments.
|
||||||
|
# The Java runtime used to run jtreg is found as follows:
|
||||||
|
# - $JTREG_JAVA is used, if it is set
|
||||||
|
# - Otherwise, $JAVA_HOME/bin/java is used if $JAVA_HOME is set
|
||||||
|
# (that is, similar to JDK.)
|
||||||
|
# - Otherwise, the value of the -jdk option is used if found
|
||||||
|
# - Otherwise, "java" is used
|
||||||
|
#
|
||||||
|
# jtreg requires a version of Java equivalent to JDK 1.8.0 or higher.
|
||||||
|
|
||||||
|
# $JTREG_HOME can be used to specify the jtreg installation directory
|
||||||
|
# (e.g. /usr/local/jtreg/5.0)
|
||||||
|
#
|
||||||
|
# $JTREG_JAVA is used to specify the version of java to use when running jtreg
|
||||||
|
# (e.g. /usr/local/java/jdk1.8.0/bin/java)
|
||||||
|
#
|
||||||
|
# You can also run the jar file directly, as in
|
||||||
|
# java -jar <path>/lib/jtreg.jar ...args...
|
||||||
|
#
|
||||||
|
# jtreg also provides Ant tasks; see the documentation for details.
|
||||||
|
|
||||||
|
# Implementation notes for Windows:
|
||||||
|
# Cygwin:
|
||||||
|
# Detected with `uname -s` (CYGWIN*)
|
||||||
|
# Windows drives are mounted with /cygdrive/LETTER
|
||||||
|
# Windows Subsystem for Linux (WSL):
|
||||||
|
# Detected with `uname -s` (Linux) and /proc/version contains "Microsoft"
|
||||||
|
# Windows drives are mounted with /mnt/LETTER
|
||||||
|
# Windows binaries need an explicit .exe suffix.
|
||||||
|
#
|
||||||
|
# Values are evaluated according to whether they are used in the context of the
|
||||||
|
# shell, or in the context of the JDK under test.
|
||||||
|
# JTREG_JAVA is evaluated for use in the shell, to run java
|
||||||
|
# JTREG_HOME is evaluated as a JDK arg, for use in -classpath or -jar args
|
||||||
|
# Other command line are updated to be JDK args for jtreg.
|
||||||
|
|
||||||
|
case "`uname -s`" in
|
||||||
|
CYGWIN* ) cygwin=1 ;;
|
||||||
|
Linux ) if grep -qi Microsoft /proc/version ; then wsl=1 ; fi ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Determine jtreg installation directory
|
||||||
|
JTREG_HOME=${JTREG_HOME:-$JT_HOME} # allow for old version of name
|
||||||
|
if [ -z "${JTREG_HOME}" ]; then
|
||||||
|
JTREG_HOME="/usr/share/jtreg"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$JTREG_HOME" ]; then
|
||||||
|
if [ ! -r $JTREG_HOME/lib/jtreg.jar ];then
|
||||||
|
echo "Invalid JTREG_HOME=$JTREG_HOME. Cannot find or read $JTREG_HOME/lib/jtreg.jar"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Deduce where script is installed
|
||||||
|
# - should work on most derivatives of Bourne shell, like ash, bash, ksh,
|
||||||
|
# sh, zsh, etc, including on Windows, MKS (ksh), Cygwin (ash or bash)
|
||||||
|
# and Windows Subsystem for Linux (WSL)
|
||||||
|
if type -p type 1>/dev/null 2>&1 && test -z "`type -p type`" ; then
|
||||||
|
myname=`type -p "$0"`
|
||||||
|
elif type type 1>/dev/null 2>&1 ; then
|
||||||
|
myname=`type "$0" | sed -e 's/^.* is a tracked alias for //' -e 's/^.* is //'`
|
||||||
|
elif whence whence 1>/dev/null 2>&1 ; then
|
||||||
|
myname=`whence "$0"`
|
||||||
|
fi
|
||||||
|
mydir=`dirname "$myname"`
|
||||||
|
p=`cd "$mydir" ; pwd`
|
||||||
|
while [ -n "$p" -a "$p" != "/" ]; do
|
||||||
|
if [ -r "$p"/lib/jtreg.jar ]; then JTREG_HOME="$p" ; break; fi
|
||||||
|
p=`dirname "$p"`
|
||||||
|
done
|
||||||
|
if [ -z "$JTREG_HOME" ]; then
|
||||||
|
echo "Cannot determine JTREG_HOME; please set it explicitly"; exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Look for -jdk option as possible default to run jtreg
|
||||||
|
# Unset IFS and use newline as arg separator to preserve spaces in args
|
||||||
|
DUALCASE=1 # for MKS: make case statement case-sensitive (6709498)
|
||||||
|
saveIFS="$IFS"
|
||||||
|
nl='
|
||||||
|
'
|
||||||
|
for i in "$@" ; do
|
||||||
|
IFS=
|
||||||
|
case $i in
|
||||||
|
-jdk:* ) jdk="`echo $i | sed -e 's/^-jdk://'`" ;;
|
||||||
|
esac
|
||||||
|
IFS="$saveIFS"
|
||||||
|
done
|
||||||
|
unset DUALCASE
|
||||||
|
|
||||||
|
# Determine java for jtreg, from JTREG_JAVA, JAVA_HOME, -jdk, java
|
||||||
|
JTREG_JAVA=${JTREG_JAVA:-$JT_JAVA} # allow for old version of name
|
||||||
|
if [ -n "$JTREG_JAVA" ]; then
|
||||||
|
if [ -d "$JTREG_JAVA" ]; then
|
||||||
|
JTREG_JAVA="$JTREG_JAVA/bin/java"
|
||||||
|
fi
|
||||||
|
elif [ -n "$JAVA_HOME" ]; then
|
||||||
|
JTREG_JAVA="$JAVA_HOME/bin/java"
|
||||||
|
elif [ -n "$jdk" ]; then
|
||||||
|
JTREG_JAVA="$jdk/bin/java"
|
||||||
|
else
|
||||||
|
JTREG_JAVA=/usr/lib/jvm/default-java/bin/java
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fixup JTREG_JAVA, JTREG_HOME as needed, if using Cygwin or WSL
|
||||||
|
if [ -n "$cygwin" ]; then
|
||||||
|
JTREG_HOME=`cygpath -a -m "$JTREG_HOME"`
|
||||||
|
driveDir=cygdrive
|
||||||
|
elif [ -n "$wsl" -a -x "$JTREG_JAVA".exe ]; then
|
||||||
|
JTREG_JAVA="$JTREG_JAVA".exe
|
||||||
|
JTREG_HOME=`wslpath -a -m "$JTREG_HOME"`
|
||||||
|
driveDir=mnt
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Verify java version (1.)8 or newer used to run jtreg
|
||||||
|
version=`"$JTREG_JAVA" -classpath "${JTREG_HOME}/lib/jtreg.jar" com.sun.javatest.regtest.agent.GetSystemProperty java.version 2>&1 |
|
||||||
|
grep 'java.version=' | sed -e 's/^.*=//' -e 's/^1\.//' -e 's/\([1-9][0-9]*\).*/\1/'`
|
||||||
|
|
||||||
|
if [ -z "$version" ]; then
|
||||||
|
echo "Cannot determine version of java to run jtreg"
|
||||||
|
exit 1;
|
||||||
|
elif [ "$version" -lt 8 ]; then
|
||||||
|
echo "java version 8 or later is required to run jtreg"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Separate out -J* options for the JVM
|
||||||
|
# Unset IFS and use newline as arg separator to preserve spaces in arg
|
||||||
|
DUALCASE=1 # for MKS: make case statement case-sensitive (6709498)
|
||||||
|
saveIFS="$IFS"
|
||||||
|
nl='
|
||||||
|
'
|
||||||
|
for i in "$@" ; do
|
||||||
|
IFS=
|
||||||
|
if [ -n "$driveDir" ]; then i=`echo $i | sed -e 's|/'$driveDir'/\([A-Za-z]\)/|\1:/|'` ; fi
|
||||||
|
case $i in
|
||||||
|
-J* ) javaOpts=$javaOpts$nl`echo $i | sed -e 's/^-J//'` ;;
|
||||||
|
* ) jtregOpts=$jtregOpts$nl$i ;;
|
||||||
|
esac
|
||||||
|
IFS="$saveIFS"
|
||||||
|
done
|
||||||
|
unset DUALCASE
|
||||||
|
|
||||||
|
# And finally ...
|
||||||
|
|
||||||
|
IFS=$nl
|
||||||
|
|
||||||
|
"${JTREG_JAVA}" \
|
||||||
|
$javaOpts \
|
||||||
|
-Dprogram=`basename "$0"` \
|
||||||
|
-jar "${JTREG_HOME}/lib/jtreg.jar" \
|
||||||
|
$jtregOpts
|
|
@ -0,0 +1,162 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2007, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.diff;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.sun.javatest.Status;
|
||||||
|
import com.sun.javatest.TestResult;
|
||||||
|
import com.sun.javatest.TestSuite;
|
||||||
|
import com.sun.javatest.WorkDirectory;
|
||||||
|
import com.sun.javatest.util.I18NResourceBundle;
|
||||||
|
|
||||||
|
public abstract class Diff {
|
||||||
|
|
||||||
|
public abstract boolean report(File outFile) throws Fault, InterruptedException;
|
||||||
|
|
||||||
|
protected boolean diff(List<File> files, File outFile)
|
||||||
|
throws Fault, InterruptedException {
|
||||||
|
this.outFile = outFile;
|
||||||
|
List<DiffReader> list = new ArrayList<DiffReader>();
|
||||||
|
for (File f: files)
|
||||||
|
list.add(open(f));
|
||||||
|
|
||||||
|
PrintWriter prevOut = out;
|
||||||
|
if (outFile != null) {
|
||||||
|
try {
|
||||||
|
out = new PrintWriter(new BufferedWriter(new FileWriter(outFile))); // FIXME don't want to use PrintWriter
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new Fault(i18n, "diff.cantOpenFile", outFile, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
initComparator();
|
||||||
|
|
||||||
|
initReporter();
|
||||||
|
reporter.setTitle(title);
|
||||||
|
reporter.setComparator(comparator);
|
||||||
|
reporter.setReaders(list);
|
||||||
|
|
||||||
|
List<int[]> testCounts = new ArrayList<int[]>();
|
||||||
|
MultiMap<String, TestResult> table = new MultiMap<String, TestResult>();
|
||||||
|
for (DiffReader r: list) {
|
||||||
|
int index = table.addColumn(r.getFile().getPath());
|
||||||
|
int[] counts = new int[Status.NUM_STATES];
|
||||||
|
for (TestResult tr: r) {
|
||||||
|
table.addRow(index, tr.getTestName(), tr);
|
||||||
|
counts[tr.getStatus().getType()]++;
|
||||||
|
}
|
||||||
|
testCounts.add(counts);
|
||||||
|
}
|
||||||
|
reporter.setTestCounts(testCounts);
|
||||||
|
|
||||||
|
try {
|
||||||
|
reporter.write(table);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new Fault(i18n, "diff.ioError", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (reporter.diffs == 0);
|
||||||
|
} finally {
|
||||||
|
if (out != prevOut) {
|
||||||
|
// try {
|
||||||
|
out.close();
|
||||||
|
// } catch (IOException e) {
|
||||||
|
// throw new Fault(i18n, "main.ioError", e);
|
||||||
|
// }
|
||||||
|
out = prevOut;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initFormat() {
|
||||||
|
if (format == null && outFile != null) {
|
||||||
|
String name = outFile.getName();
|
||||||
|
int dot = name.lastIndexOf(".");
|
||||||
|
if (dot != -1)
|
||||||
|
format = name.substring(dot + 1).toLowerCase();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initReporter() throws Fault {
|
||||||
|
if (reporter == null) {
|
||||||
|
try {
|
||||||
|
initFormat();
|
||||||
|
if (format != null && format.equals("html"))
|
||||||
|
reporter = new HTMLReporter(out);
|
||||||
|
else
|
||||||
|
reporter = new SimpleReporter(out);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new Fault(i18n, "diff.cantOpenReport", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initComparator() {
|
||||||
|
if (comparator == null)
|
||||||
|
comparator = new StatusComparator(includeReason);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DiffReader open(File f) throws Fault {
|
||||||
|
if (!f.exists())
|
||||||
|
throw new Fault(i18n, "main.cantFindFile", f);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (WorkDirectoryReader.accepts(f))
|
||||||
|
return new WorkDirectoryReader(f);
|
||||||
|
|
||||||
|
if (ReportReader.accepts(f))
|
||||||
|
return new ReportReader(f);
|
||||||
|
|
||||||
|
throw new Fault(i18n, "main.unrecognizedFile", f);
|
||||||
|
|
||||||
|
} catch (TestSuite.Fault e) {
|
||||||
|
throw new Fault(i18n, "main.cantOpenFile", f, e);
|
||||||
|
} catch (WorkDirectory.Fault e) {
|
||||||
|
throw new Fault(i18n, "main.cantOpenFile", f, e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new Fault(i18n, "main.cantOpenFile", f, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected File outFile;
|
||||||
|
protected PrintWriter out;
|
||||||
|
protected Comparator<TestResult> comparator;
|
||||||
|
protected Reporter reporter;
|
||||||
|
protected boolean includeReason;
|
||||||
|
protected String format;
|
||||||
|
protected String title;
|
||||||
|
private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(Diff.class);
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2007, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.diff;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import com.sun.javatest.TestResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for reading a series of test-status results.
|
||||||
|
*/
|
||||||
|
public interface DiffReader extends Iterable<TestResult> {
|
||||||
|
File getWorkDirectory();
|
||||||
|
String getFileType();
|
||||||
|
File getFile();
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2007, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.diff;
|
||||||
|
|
||||||
|
import com.sun.javatest.util.I18NResourceBundle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception to report a problem while executing in Main.
|
||||||
|
*/
|
||||||
|
public class Fault extends Exception {
|
||||||
|
|
||||||
|
static final long serialVersionUID = 1607979458544175906L;
|
||||||
|
|
||||||
|
Fault(I18NResourceBundle i18n, String s, Object... args) {
|
||||||
|
super(i18n.getString(s, args));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,350 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2007, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.diff;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.sun.javatest.Status;
|
||||||
|
import com.sun.javatest.TestResult;
|
||||||
|
import com.sun.javatest.util.I18NResourceBundle;
|
||||||
|
|
||||||
|
import static com.sun.javatest.util.HTMLWriter.*;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO: import CSS
|
||||||
|
* TODO: links to .jtr files
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report differences to an HTML file.
|
||||||
|
*/
|
||||||
|
public class HTMLReporter extends Reporter {
|
||||||
|
|
||||||
|
/** Creates a new instance of HTMLReporter */
|
||||||
|
public HTMLReporter(Writer out) throws IOException {
|
||||||
|
this.out = new HTMLWriter(out, DOCTYPE);
|
||||||
|
this.out.setI18NResourceBundle(i18n);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(MultiMap<String, TestResult> table) throws IOException {
|
||||||
|
this.table = table;
|
||||||
|
size = table.getColumns();
|
||||||
|
|
||||||
|
startReport(title);
|
||||||
|
|
||||||
|
out.startTag(H1);
|
||||||
|
if (title == null)
|
||||||
|
out.writeI18N("html.head.notitle");
|
||||||
|
else
|
||||||
|
out.writeI18N("html.head.title", title);
|
||||||
|
out.endTag(H1);
|
||||||
|
|
||||||
|
writeIndexTable();
|
||||||
|
writeMainTable();
|
||||||
|
writeSummary();
|
||||||
|
|
||||||
|
endReport();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void startReport(String title) throws IOException {
|
||||||
|
out.startTag(HTML);
|
||||||
|
writeHead(title);
|
||||||
|
out.startTag(BODY);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void endReport() throws IOException {
|
||||||
|
out.startTag(HR);
|
||||||
|
out.writeI18N("html.generatedAt", new Date());
|
||||||
|
out.endTag(BODY);
|
||||||
|
|
||||||
|
out.endTag(HTML);
|
||||||
|
out.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void writeHead(String title) throws IOException {
|
||||||
|
out.startTag(HEAD);
|
||||||
|
out.startTag(TITLE);
|
||||||
|
if (title == null)
|
||||||
|
out.writeI18N("html.head.notitle");
|
||||||
|
else
|
||||||
|
out.writeI18N("html.head.title", title);
|
||||||
|
out.endTag(TITLE);
|
||||||
|
out.startTag(STYLE);
|
||||||
|
out.writeAttr(TYPE, "text/css");
|
||||||
|
out.write("\n");
|
||||||
|
out.write("table { background-color:white }");
|
||||||
|
out.write("tr.head { background-color:#dddddd }");
|
||||||
|
out.write("tr.odd { background-color:#eeeeee }");
|
||||||
|
out.write("tr.even { background-color:white } ");
|
||||||
|
out.write("td { padding: 0 .5em }");
|
||||||
|
out.write("td.pass { background-color:#ddffdd } ");
|
||||||
|
out.write("td.fail { background-color:#ffdddd } ");
|
||||||
|
out.write("td.error { background-color:#ddddff } ");
|
||||||
|
out.write("td.notRun { background-color:#dddddd } ");
|
||||||
|
out.write("th { padding: 0 .5em }");
|
||||||
|
out.write("hr { margin-top:30px; }");
|
||||||
|
out.write("\n");
|
||||||
|
out.endTag(STYLE);
|
||||||
|
out.endTag(HEAD);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeIndexTable() throws IOException {
|
||||||
|
out.startTag(H2);
|
||||||
|
out.writeI18N("html.head.sets");
|
||||||
|
out.endTag(H2);
|
||||||
|
|
||||||
|
out.startTag(TABLE);
|
||||||
|
out.writeAttr(FRAME, BOX);
|
||||||
|
out.writeAttr(RULES, GROUPS);
|
||||||
|
out.startTag(THEAD);
|
||||||
|
out.startTag(TR);
|
||||||
|
out.writeAttr(CLASS, HEAD);
|
||||||
|
out.startTag(TH);
|
||||||
|
out.writeI18N("html.th.set");
|
||||||
|
out.endTag(TH);
|
||||||
|
out.startTag(TH);
|
||||||
|
out.writeI18N("html.th.location");
|
||||||
|
out.endTag(TH);
|
||||||
|
writeIndexTableInfoHeadings();
|
||||||
|
// out.startTag(TH);
|
||||||
|
// out.writeI18N("html.th.type");
|
||||||
|
// out.endTag(TH);
|
||||||
|
for (int c = 0; c < Status.NUM_STATES; c++) {
|
||||||
|
out.startTag(TH);
|
||||||
|
switch (c) {
|
||||||
|
case Status.PASSED:
|
||||||
|
out.writeI18N("html.th.pass");
|
||||||
|
break;
|
||||||
|
case Status.FAILED:
|
||||||
|
out.writeI18N("html.th.fail");
|
||||||
|
break;
|
||||||
|
case Status.ERROR:
|
||||||
|
out.writeI18N("html.th.error");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
out.writeI18N("html.th.notRun");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
out.endTag(TH);
|
||||||
|
}
|
||||||
|
out.startTag(TH);
|
||||||
|
out.writeI18N("html.th.total");
|
||||||
|
out.endTag(TH);
|
||||||
|
out.endTag(TR);
|
||||||
|
out.endTag(THEAD);
|
||||||
|
|
||||||
|
out.startTag(TBODY);
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
out.startTag(TR);
|
||||||
|
out.writeAttr(CLASS, (i % 2 == 0 ? EVEN : ODD));
|
||||||
|
out.startTag(TD);
|
||||||
|
out.write(String.valueOf(i + 1));
|
||||||
|
out.endTag(TD);
|
||||||
|
out.startTag(TD);
|
||||||
|
out.write(table.getColumnName(i));
|
||||||
|
out.endTag(TD);
|
||||||
|
writeIndexTableInfoValues(table.getColumnName(i));
|
||||||
|
// out.startTag(TD);
|
||||||
|
// out.write("??");
|
||||||
|
// out.endTag(TD);
|
||||||
|
int total = 0;
|
||||||
|
int[] counts = testCounts.get(i);
|
||||||
|
for (int c = 0; c < Status.NUM_STATES; c++) {
|
||||||
|
out.startTag(TD);
|
||||||
|
if (counts[c] > 0)
|
||||||
|
out.write(String.valueOf(counts[c]));
|
||||||
|
else
|
||||||
|
out.writeEntity(" ");
|
||||||
|
total += counts[c];
|
||||||
|
out.endTag(TD);
|
||||||
|
}
|
||||||
|
out.startTag(TD);
|
||||||
|
out.write(String.valueOf(total));
|
||||||
|
out.endTag(TD);
|
||||||
|
out.endTag(TR);
|
||||||
|
}
|
||||||
|
out.endTag(TBODY);
|
||||||
|
out.endTag(TABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void writeIndexTableInfoHeadings() throws IOException {
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void writeIndexTableInfoValues(String name) throws IOException {
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeMainTable() throws IOException {
|
||||||
|
diffs = 0;
|
||||||
|
for (Map.Entry<String, MultiMap.Entry<TestResult>> e: table.entrySet()) {
|
||||||
|
String testName = e.getKey();
|
||||||
|
MultiMap.Entry<TestResult> result = e.getValue();
|
||||||
|
if (result.allEqual(comparator))
|
||||||
|
continue;
|
||||||
|
if (diffs == 0) {
|
||||||
|
out.startTag(H2);
|
||||||
|
out.writeI18N("html.head.differences");
|
||||||
|
out.endTag(H2);
|
||||||
|
out.startTag(TABLE);
|
||||||
|
out.writeAttr(FRAME, BOX);
|
||||||
|
out.writeAttr(RULES, GROUPS);
|
||||||
|
out.startTag(THEAD);
|
||||||
|
out.startTag(TR);
|
||||||
|
out.writeAttr(CLASS, HEAD);
|
||||||
|
out.startTag(TH);
|
||||||
|
out.writeI18N("html.th.test");
|
||||||
|
out.endTag(TH);
|
||||||
|
for (int i = 0; i < result.getSize(); i++) {
|
||||||
|
out.startTag(TH);
|
||||||
|
if (compact)
|
||||||
|
out.write(String.valueOf(i + 1));
|
||||||
|
else
|
||||||
|
out.writeI18N("html.th.setN", i + 1);
|
||||||
|
out.endTag(TH);
|
||||||
|
}
|
||||||
|
out.endTag(TR);
|
||||||
|
out.endTag(THEAD);
|
||||||
|
out.startTag(TBODY);
|
||||||
|
}
|
||||||
|
out.startTag(TR);
|
||||||
|
out.writeAttr(CLASS, (diffs % 2 == 0 ? EVEN : ODD));
|
||||||
|
out.startTag(TD);
|
||||||
|
out.write(testName);
|
||||||
|
out.endTag(TD);
|
||||||
|
for (int i = 0; i < result.getSize(); i++) {
|
||||||
|
TestResult tr = result.get(i);
|
||||||
|
File trFile = (tr == null ? null : tr.getFile());
|
||||||
|
if (trFile == null) {
|
||||||
|
File wd = readers.get(i).getWorkDirectory();
|
||||||
|
if (wd != null)
|
||||||
|
trFile = new File(wd, tr.getWorkRelativePath());
|
||||||
|
}
|
||||||
|
out.startTag(TD);
|
||||||
|
Status s = (tr == null ? null : tr.getStatus());
|
||||||
|
out.writeAttr(CLASS, getClassAttr(s));
|
||||||
|
String text = getText(s);
|
||||||
|
if (trFile != null && trFile.exists()) {
|
||||||
|
out.startTag(A);
|
||||||
|
out.writeAttr(HREF, trFile.toURI().toString());
|
||||||
|
if (text.startsWith("&"))
|
||||||
|
out.writeEntity(text);
|
||||||
|
else
|
||||||
|
out.write(text);
|
||||||
|
out.endTag(A);
|
||||||
|
} else {
|
||||||
|
if (text.startsWith("&"))
|
||||||
|
out.writeEntity(text);
|
||||||
|
else
|
||||||
|
out.write(text);
|
||||||
|
}
|
||||||
|
out.endTag(TD);
|
||||||
|
}
|
||||||
|
out.endTag(TR);
|
||||||
|
diffs++;
|
||||||
|
}
|
||||||
|
if (diffs > 0) {
|
||||||
|
out.endTag(TBODY);
|
||||||
|
out.endTag(TABLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeSummary() throws IOException {
|
||||||
|
out.startTag(P);
|
||||||
|
if (diffs == 0)
|
||||||
|
out.writeI18N("html.diffs.none");
|
||||||
|
else
|
||||||
|
out.writeI18N("html.diffs.count", diffs);
|
||||||
|
out.endTag(P);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getClassAttr(Status s) {
|
||||||
|
switch (s == null ? Status.NOT_RUN : s.getType()) {
|
||||||
|
case Status.PASSED:
|
||||||
|
return PASS;
|
||||||
|
case Status.FAILED:
|
||||||
|
return FAIL;
|
||||||
|
case Status.ERROR:
|
||||||
|
return ERROR;
|
||||||
|
default:
|
||||||
|
return NOT_RUN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getText(Status s) {
|
||||||
|
if (statusStrings == null) {
|
||||||
|
statusStrings = new String[Status.NUM_STATES];
|
||||||
|
if (compact) {
|
||||||
|
statusStrings[Status.PASSED] = i18n.getString("html.pass.compact");
|
||||||
|
statusStrings[Status.FAILED] = i18n.getString("html.fail.compact");
|
||||||
|
statusStrings[Status.ERROR] = i18n.getString("html.error.compact");
|
||||||
|
statusStrings[Status.NOT_RUN] = i18n.getString("html.notRun.compact");
|
||||||
|
} else {
|
||||||
|
statusStrings[Status.PASSED] = i18n.getString("html.pass");
|
||||||
|
statusStrings[Status.FAILED] = i18n.getString("html.fail");
|
||||||
|
statusStrings[Status.ERROR] = i18n.getString("html.error");
|
||||||
|
statusStrings[Status.NOT_RUN] = i18n.getString("html.notRun");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return statusStrings[s == null ? Status.NOT_RUN : s.getType()];
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] statusStrings;
|
||||||
|
|
||||||
|
protected final HTMLWriter out;
|
||||||
|
private MultiMap<String, TestResult> table;
|
||||||
|
private int size;
|
||||||
|
|
||||||
|
private static final String DOCTYPE = "<!DOCTYPE HTML>";
|
||||||
|
|
||||||
|
// HTML tags
|
||||||
|
private static final String THEAD = "thead";
|
||||||
|
private static final String TBODY = "tbody";
|
||||||
|
|
||||||
|
// HTML attribute names
|
||||||
|
private static final String CLASS = "class";
|
||||||
|
private static final String FRAME = "frame";
|
||||||
|
private static final String RULES = "rules";
|
||||||
|
|
||||||
|
// HTML attribute values
|
||||||
|
private static final String BOX = "box";
|
||||||
|
private static final String GROUPS = "groups";
|
||||||
|
|
||||||
|
// HTML class values
|
||||||
|
private static final String HEAD = "head";
|
||||||
|
private static final String ODD = "odd";
|
||||||
|
private static final String EVEN = "even";
|
||||||
|
private static final String PASS = "pass";
|
||||||
|
private static final String FAIL = "fail";
|
||||||
|
private static final String ERROR = "error";
|
||||||
|
private static final String NOT_RUN = "notRun";
|
||||||
|
|
||||||
|
private boolean compact = Boolean.TRUE.equals(Boolean.getBoolean("jtdiff.html.compact"));
|
||||||
|
private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(HTMLReporter.class);
|
||||||
|
}
|
|
@ -0,0 +1,559 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1996, 2008, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.diff;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import com.sun.javatest.util.I18NResourceBundle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class to facilitate writing HTML via a stream.
|
||||||
|
*/
|
||||||
|
public class HTMLWriter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create an HTMLWriter object, using a default doctype for HTML 3.2.
|
||||||
|
* @param out a Writer to which to write the generated HTML
|
||||||
|
* @throws IOException if there is a problem writing to the underlying stream
|
||||||
|
*/
|
||||||
|
public HTMLWriter(Writer out) throws IOException {
|
||||||
|
this(out, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an HTMLWriter object, using a specifed doctype header.
|
||||||
|
* @param out a Writer to which to write the generated HTML
|
||||||
|
* @param docType a string containing a doctype header for the HTML to be generetaed
|
||||||
|
* @throws IOException if there is a problem writing to the underlying stream
|
||||||
|
*/
|
||||||
|
public HTMLWriter(Writer out, String docType) throws IOException {
|
||||||
|
if (out instanceof BufferedWriter)
|
||||||
|
this.out = (BufferedWriter) out;
|
||||||
|
else
|
||||||
|
this.out = new BufferedWriter(out);
|
||||||
|
this.out.write(docType);
|
||||||
|
this.out.newLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an HTMLWriter object, using a specified bundle for l0calizing messages.
|
||||||
|
* @param out a Writer to which to write the generated HTML
|
||||||
|
* @param i18n a resource bundle to use to localize messages
|
||||||
|
* @throws IOException if there is a problem writing to the underlying stream
|
||||||
|
*/
|
||||||
|
public HTMLWriter(Writer out, I18NResourceBundle i18n) throws IOException {
|
||||||
|
this(out);
|
||||||
|
this.i18n = i18n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an HTMLWriter object, using a specifed doctype header and
|
||||||
|
* using a specified bundle for l0calizing messages.
|
||||||
|
* @param out a Writer to which to write the generated HTML
|
||||||
|
* @param docType a string containing a doctype header for the HTML to be generetaed
|
||||||
|
* @param i18n a resource bundle to use to localize messages
|
||||||
|
* @throws IOException if there is a problem writing to the underlying stream
|
||||||
|
*/
|
||||||
|
public HTMLWriter(Writer out, String docType, I18NResourceBundle i18n) throws IOException {
|
||||||
|
this(out, docType);
|
||||||
|
this.i18n = i18n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the reource bundle to be used for localizing messages.
|
||||||
|
* @param i18n the resource bundle to be used for localizing messages
|
||||||
|
*/
|
||||||
|
public void setI18NResourceBundle(I18NResourceBundle i18n) {
|
||||||
|
this.i18n = i18n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flush the stream, and the underlying output stream.
|
||||||
|
* @throws IOException if there is a problem writing to the underlying stream
|
||||||
|
*/
|
||||||
|
public void flush() throws IOException {
|
||||||
|
out.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close the stream, and the underlying output stream.
|
||||||
|
* @throws IOException if there is a problem closing the underlying stream
|
||||||
|
*/
|
||||||
|
public void close() throws IOException {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a newline to the underlying output stream.
|
||||||
|
* @throws IOException if there is a problem writing to the underlying stream
|
||||||
|
*/
|
||||||
|
public void newLine() throws IOException {
|
||||||
|
out.newLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start an HTML tag. If a prior tag has been started, it will
|
||||||
|
* be closed first. Once a tag has been opened, attributes for the
|
||||||
|
* tag may be written out, followed by body content before finally
|
||||||
|
* ending the tag.
|
||||||
|
* @param tag the tag to be started
|
||||||
|
* @throws IOException if there is a problem writing to the underlying stream
|
||||||
|
* @see #writeAttr
|
||||||
|
* @see #write
|
||||||
|
* @see #endTag
|
||||||
|
*/
|
||||||
|
public void startTag(String tag) throws IOException {
|
||||||
|
if (state == IN_TAG) {
|
||||||
|
out.write(">");
|
||||||
|
state = IN_BODY;
|
||||||
|
}
|
||||||
|
newLine();
|
||||||
|
out.write("<");
|
||||||
|
out.write(tag);
|
||||||
|
state = IN_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finish an HTML tag. It is expected that a call to endTag will match
|
||||||
|
* a corresponding earlier call to startTag, but there is no formal check
|
||||||
|
* for this.
|
||||||
|
* @param tag the tag to be closed.
|
||||||
|
* @throws IOException if there is a problem writing to the underlying stream
|
||||||
|
*/
|
||||||
|
public void endTag(String tag) throws IOException {
|
||||||
|
if (state == IN_TAG) {
|
||||||
|
out.write(">");
|
||||||
|
state = IN_BODY;
|
||||||
|
out.newLine();
|
||||||
|
}
|
||||||
|
out.write("</");
|
||||||
|
out.write(tag);
|
||||||
|
out.write(">");
|
||||||
|
//out.newLine(); // PATCHED, jjg
|
||||||
|
state = IN_BODY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finish an empty element tag, such as a META, BASE or LINK tag.
|
||||||
|
* This is expected to correspond with a startTag.
|
||||||
|
* @param tag the tag which is being closed. this is only useful for
|
||||||
|
* validation, it is not written out
|
||||||
|
* @throws IllegalStateException if this call does not follow startTag
|
||||||
|
* (stream is not currently inside a tag)
|
||||||
|
* @throws IOException if there is a problem writing to the underlying stream
|
||||||
|
*/
|
||||||
|
public void endEmptyTag(String tag) throws IOException {
|
||||||
|
if (state != IN_TAG)
|
||||||
|
throw new IllegalStateException();
|
||||||
|
|
||||||
|
out.write(">");
|
||||||
|
state = IN_BODY;
|
||||||
|
out.newLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write an attribute for a tag. A tag must previously have been started.
|
||||||
|
* All tag attributes must be written before any body text is written.
|
||||||
|
* The value will be quoted if necessary when writing it to the underlying
|
||||||
|
* stream. No check is made that the attribute is valid for the current tag.
|
||||||
|
* @param name the name of the attribute to be written
|
||||||
|
* @param value the value of the attribute to be written
|
||||||
|
* @throws IllegalStateException if the stream is not in a state to
|
||||||
|
* write attributes -- e.g. if this call does not follow startTag or other
|
||||||
|
* calls of writteAttr
|
||||||
|
* @throws IOException if there is a problem writing to the underlying stream
|
||||||
|
*/
|
||||||
|
public void writeAttr(String name, String value) throws IOException {
|
||||||
|
if (state != IN_TAG)
|
||||||
|
throw new IllegalStateException();
|
||||||
|
|
||||||
|
out.write(" ");
|
||||||
|
out.write(name);
|
||||||
|
out.write("=");
|
||||||
|
boolean alpha = true;
|
||||||
|
for (int i = 0; i < value.length() && alpha; i++)
|
||||||
|
alpha = Character.isLetter(value.charAt(i));
|
||||||
|
if (!alpha)
|
||||||
|
out.write("\"");
|
||||||
|
out.write(value);
|
||||||
|
if (!alpha)
|
||||||
|
out.write("\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write an attribute for a tag. A tag must previously have been started.
|
||||||
|
* All tag attributes must be written before any body text is written.
|
||||||
|
* The value will be quoted if necessary when writing it to the underlying
|
||||||
|
* stream. No check is made that the attribute is valid for the current tag.
|
||||||
|
* @param name the name of the attribute to be written
|
||||||
|
* @param value the value of the attribute to be written
|
||||||
|
* @throws IllegalStateException if the stream is not in a state to
|
||||||
|
* write attributes -- e.g. if this call does not follow startTag or other
|
||||||
|
* calls of writteAttr
|
||||||
|
* @throws IOException if there is a problem writing to the underlying stream
|
||||||
|
*/
|
||||||
|
public void writeAttr(String name, int value) throws IOException {
|
||||||
|
writeAttr(name, Integer.toString(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a line of text, followed by a newline.
|
||||||
|
* The text will be escaped as necessary.
|
||||||
|
* @param text the text to be written.
|
||||||
|
* @throws IOException if there is a problem closing the underlying stream
|
||||||
|
*/
|
||||||
|
public void writeLine(String text) throws IOException {
|
||||||
|
write(text);
|
||||||
|
out.newLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write body text, escaping it as necessary.
|
||||||
|
* If this call follows a call of startTag, the open tag will be
|
||||||
|
* closed -- meaning that no more attributes can be written until another
|
||||||
|
* tag is started. If the text value is null, the current tag will still
|
||||||
|
* be closed, but no other text will be written.
|
||||||
|
* @param text the text to be written, may be null or zero length.
|
||||||
|
* @throws IOException if there is a problem writing to the underlying stream
|
||||||
|
*/
|
||||||
|
public void write(String text) throws IOException {
|
||||||
|
if (state == IN_TAG) {
|
||||||
|
out.write(">");
|
||||||
|
state = IN_BODY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (text == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// check to see if there are any special characters
|
||||||
|
boolean specialChars = false;
|
||||||
|
for (int i = 0; i < text.length() && !specialChars; i++) {
|
||||||
|
switch (text.charAt(i)) {
|
||||||
|
case '<': case '>': case '&':
|
||||||
|
specialChars = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if there are special characters write the string character at a time;
|
||||||
|
// otherwise, write it out as is
|
||||||
|
if (specialChars) {
|
||||||
|
for (int i = 0; i < text.length(); i++) {
|
||||||
|
char c = text.charAt(i);
|
||||||
|
switch (c) {
|
||||||
|
case '<': out.write("<"); break;
|
||||||
|
case '>': out.write(">"); break;
|
||||||
|
case '&': out.write("&"); break;
|
||||||
|
default: out.write(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
out.write(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a basic HTML entity, such as or { .
|
||||||
|
* @param entity the entity to write
|
||||||
|
* @throws IOException if there is a problem writing to the underlying stream
|
||||||
|
*/
|
||||||
|
public void writeEntity(String entity) throws IOException {
|
||||||
|
if (state == IN_TAG) {
|
||||||
|
out.write(">");
|
||||||
|
state = IN_BODY;
|
||||||
|
}
|
||||||
|
out.write(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write an image tag, using a specified path for the image source attribute.
|
||||||
|
* @param imagePath the path for the image source
|
||||||
|
* @throws IOException if there is a problem closing the underlying stream
|
||||||
|
*/
|
||||||
|
public void writeImage(String imagePath) throws IOException {
|
||||||
|
startTag(IMAGE);
|
||||||
|
writeAttr(SRC, imagePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write an image tag, using a specified path for the image source attribute.
|
||||||
|
* @param imageURL the url for the image source
|
||||||
|
* @throws IOException if there is a problem closing the underlying stream
|
||||||
|
*/
|
||||||
|
public void writeImage(URL imageURL) throws IOException {
|
||||||
|
writeImage(imageURL.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a hypertext link.
|
||||||
|
* @param anchor the target for the link
|
||||||
|
* @param body the body text for the link
|
||||||
|
* @throws IOException if there is a problem closing the underlying stream
|
||||||
|
*/
|
||||||
|
public void writeLink(String anchor, String body) throws IOException {
|
||||||
|
startTag(A);
|
||||||
|
writeAttr(HREF, anchor);
|
||||||
|
write(body);
|
||||||
|
endTag(A);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a hypertext link.
|
||||||
|
* @param file the target for the link
|
||||||
|
* @param body the body text for the link
|
||||||
|
* @throws IOException if there is a problem closing the underlying stream
|
||||||
|
*/
|
||||||
|
public void writeLink(File file, String body) throws IOException {
|
||||||
|
startTag(A);
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
String path = file.getPath().replace(File.separatorChar, '/');
|
||||||
|
if (file.isAbsolute() && !path.startsWith("/"))
|
||||||
|
sb.append('/');
|
||||||
|
sb.append(path);
|
||||||
|
writeAttr(HREF, sb.toString());
|
||||||
|
write(body);
|
||||||
|
endTag(A);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a hypertext link.
|
||||||
|
* @param file the target and body for the link
|
||||||
|
* @throws IOException if there is a problem closing the underlying stream
|
||||||
|
*/
|
||||||
|
public void writeLink(File file) throws IOException {
|
||||||
|
writeLink(file, file.getPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a hypertext link.
|
||||||
|
* @param url the target for the link
|
||||||
|
* @param body the body text for the link
|
||||||
|
* @throws IOException if there is a problem closing the underlying stream
|
||||||
|
*/
|
||||||
|
public void writeLink(URL url, String body) throws IOException {
|
||||||
|
startTag(A);
|
||||||
|
writeAttr(HREF, url.toString());
|
||||||
|
write(body);
|
||||||
|
endTag(A);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write the destination marker for a hypertext link.
|
||||||
|
* @param anchor the destination marker for hypertext links
|
||||||
|
* @param body the body text for the marker
|
||||||
|
* @throws IOException if there is a problem closing the underlying stream
|
||||||
|
*/
|
||||||
|
public void writeLinkDestination(String anchor, String body) throws IOException {
|
||||||
|
startTag(A);
|
||||||
|
writeAttr(NAME, anchor);
|
||||||
|
write(body);
|
||||||
|
endTag(A);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a parameter tag.
|
||||||
|
* @param name the name of the parameter
|
||||||
|
* @param value the value of the parameter
|
||||||
|
* @throws IOException if there is a problem closing the underlying stream
|
||||||
|
*/
|
||||||
|
public void writeParam(String name, String value) throws IOException {
|
||||||
|
startTag(PARAM);
|
||||||
|
writeAttr(NAME, name);
|
||||||
|
writeAttr(VALUE, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a style attribute.
|
||||||
|
* @param value the value for the style atrtribute
|
||||||
|
* @throws IOException if there is a problem closing the underlying stream
|
||||||
|
*/
|
||||||
|
public void writeStyleAttr(String value) throws IOException {
|
||||||
|
writeAttr(STYLE, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a localized message, using a specified resource bundle.
|
||||||
|
* @param i18n the resource bundle used to localize the message
|
||||||
|
* @param key the key for the message to be localized
|
||||||
|
* @throws IOException if there is a problem closing the underlying stream
|
||||||
|
*/
|
||||||
|
public void write(I18NResourceBundle i18n, String key) throws IOException {
|
||||||
|
write(i18n.getString(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a localized message, using a specified resource bundle.
|
||||||
|
* @param i18n the resource bundle used to localize the message
|
||||||
|
* @param key the key for the message to be localized
|
||||||
|
* @param arg an argument to be formatted into the localized message
|
||||||
|
* @throws IOException if there is a problem closing the underlying stream
|
||||||
|
*/
|
||||||
|
public void write(I18NResourceBundle i18n, String key, Object arg) throws IOException {
|
||||||
|
write(i18n.getString(key, arg));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a localized message, using a specified resource bundle.
|
||||||
|
* @param i18n the resource bundle used to localize the message
|
||||||
|
* @param key the key for the message to be localized
|
||||||
|
* @param args arguments to be formatted into the localized message
|
||||||
|
* @throws IOException if there is a problem closing the underlying stream
|
||||||
|
*/
|
||||||
|
public void write(I18NResourceBundle i18n, String key, Object[] args) throws IOException {
|
||||||
|
write(i18n.getString(key, args));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a localized message, using the default resource bundle.
|
||||||
|
* @param key the key for the message to be localized
|
||||||
|
* @throws IOException if there is a problem closing the underlying stream
|
||||||
|
*/
|
||||||
|
public void writeI18N(String key) throws IOException {
|
||||||
|
write(i18n.getString(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a localized message, using the default resource bundle.
|
||||||
|
* @param key the key for the message to be localized
|
||||||
|
* @param arg an argument to be formatted into the localized message
|
||||||
|
* @throws IOException if there is a problem closing the underlying stream
|
||||||
|
*/
|
||||||
|
public void writeI18N(String key, Object arg) throws IOException {
|
||||||
|
write(i18n.getString(key, arg));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a localized message, using the default resource bundle.
|
||||||
|
* @param key the key for the message to be localized
|
||||||
|
* @param args arguments to be formatted into the localized message
|
||||||
|
* @throws IOException if there is a problem closing the underlying stream
|
||||||
|
*/
|
||||||
|
public void writeI18N(String key, Object[] args) throws IOException {
|
||||||
|
write(i18n.getString(key, args));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The HTML "a" tag. */
|
||||||
|
public static final String A = "a";
|
||||||
|
/** The HTML "align" attribute. */
|
||||||
|
public static final String ALIGN = "align";
|
||||||
|
/** The HTML "b" tag. */
|
||||||
|
public static final String B = "b";
|
||||||
|
/** The HTML "body" tag. */
|
||||||
|
public static final String BODY = "body";
|
||||||
|
/** The HTML "border" attribute. */
|
||||||
|
public static final String BORDER = "border";
|
||||||
|
/** The HTML "br" tag. */
|
||||||
|
public static final String BR = "br";
|
||||||
|
/** The HTML "classid" attribute. */
|
||||||
|
public static final String CLASSID = "classid";
|
||||||
|
/** The HTML "code" tag. */
|
||||||
|
public static final String CODE = "code";
|
||||||
|
/** The HTML "color" attribte. */
|
||||||
|
public static final String COLOR = "color";
|
||||||
|
/** The HTML "col" attribute value. */
|
||||||
|
public static final String COL = "col";
|
||||||
|
/** The HTML "font" tag. */
|
||||||
|
public static final String FONT = "font";
|
||||||
|
/** The HTML "h1" tag. */
|
||||||
|
public static final String H1 = "h1";
|
||||||
|
/** The HTML "h2" tag. */
|
||||||
|
public static final String H2 = "h2";
|
||||||
|
/** The HTML "h3" tag. */
|
||||||
|
public static final String H3 = "h3";
|
||||||
|
/** The HTML "h4" tag. */
|
||||||
|
public static final String H4 = "h4";
|
||||||
|
/** The HTML "head" tag. */
|
||||||
|
public static final String HEAD = "head";
|
||||||
|
/** The HTML "href" attribute. */
|
||||||
|
public static final String HREF = "href";
|
||||||
|
/** The HTML "html" tag. */
|
||||||
|
public static final String HTML = "html";
|
||||||
|
/** The HTML "hr" tag. */
|
||||||
|
public static final String HR = "hr";
|
||||||
|
/** The HTML "i" tag. */
|
||||||
|
public static final String I = "i";
|
||||||
|
/** The HTML "image" tag. */
|
||||||
|
public static final String IMAGE = "image";
|
||||||
|
/** The HTML "left" attribute value. */
|
||||||
|
public static final String LEFT = "left";
|
||||||
|
/** The HTML "li" tag. */
|
||||||
|
public static final String LI = "li";
|
||||||
|
/** The HTML "link" tag. */
|
||||||
|
public static final String LINK = "link";
|
||||||
|
/** The HTML "name" attribute. */
|
||||||
|
public static final String NAME = "name";
|
||||||
|
/** The HTML "object" tag. */
|
||||||
|
public static final String OBJECT = "object";
|
||||||
|
/** The HTML "p" tag. */
|
||||||
|
public static final String PARAM = "param";
|
||||||
|
/** The HTML "param" tag. */
|
||||||
|
public static final String P = "p";
|
||||||
|
/** The HTML "rel" attribute value. */
|
||||||
|
public static final String REL = "rel";
|
||||||
|
/** The HTML "right" attribute value. */
|
||||||
|
public static final String RIGHT = "right";
|
||||||
|
/** The HTML "row" attribute value. */
|
||||||
|
public static final String ROW = "row";
|
||||||
|
/** The HTML "small" tag. */
|
||||||
|
public static final String SMALL = "small";
|
||||||
|
/** The HTML "src" attribute. */
|
||||||
|
public static final String SRC = "src";
|
||||||
|
/** The HTML "scope" attribute. */
|
||||||
|
public static final String SCOPE = "scope";
|
||||||
|
/** The HTML "style" attribute. */
|
||||||
|
public static final String STYLE = "style";
|
||||||
|
/** The HTML "table" tag. */
|
||||||
|
public static final String TABLE = "table";
|
||||||
|
/** The HTML "td" tag. */
|
||||||
|
public static final String TD = "td";
|
||||||
|
/** The HTML "title"attribute. */
|
||||||
|
public static final String TITLE = "title";
|
||||||
|
/** The HTML "th" tag. */
|
||||||
|
public static final String TH = "th";
|
||||||
|
/** The HTML "top" attribute value. */
|
||||||
|
public static final String TOP = "top";
|
||||||
|
/** The HTML "tr" tag. */
|
||||||
|
public static final String TR = "tr";
|
||||||
|
/** The HTML "type" attribute. */
|
||||||
|
public static final String TYPE = "type";
|
||||||
|
/** The HTML "ul" tag. */
|
||||||
|
public static final String UL = "ul";
|
||||||
|
/** The HTML "valign" attribute. */
|
||||||
|
public static final String VALIGN = "valign";
|
||||||
|
/** The HTML "value" attribute. */
|
||||||
|
public static final String VALUE = "value";
|
||||||
|
|
||||||
|
|
||||||
|
private BufferedWriter out;
|
||||||
|
private int state;
|
||||||
|
private I18NResourceBundle i18n;
|
||||||
|
private static final int IN_TAG = 1;
|
||||||
|
private static final int IN_BODY = 2;
|
||||||
|
}
|
|
@ -0,0 +1,376 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2007, 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.diff;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.SortedMap;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
import com.sun.javatest.regtest.tool.Option;
|
||||||
|
import com.sun.javatest.util.HelpTree;
|
||||||
|
import com.sun.javatest.util.I18NResourceBundle;
|
||||||
|
import com.sun.javatest.util.WrapWriter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles help options for main program
|
||||||
|
*/
|
||||||
|
public class Help {
|
||||||
|
|
||||||
|
/** Creates a new instance of Help */
|
||||||
|
public Help(List<Option> options) {
|
||||||
|
this.options = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setVersionFlag(boolean yes) {
|
||||||
|
versionFlag = yes;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setCommandLineHelpQuery(String query) {
|
||||||
|
if (commandLineHelpQuery == null)
|
||||||
|
commandLineHelpQuery = new ArrayList<String>();
|
||||||
|
if (query != null)
|
||||||
|
commandLineHelpQuery.addAll(Arrays.asList(query.trim().split("\\s+")));
|
||||||
|
}
|
||||||
|
|
||||||
|
void show(PrintStream out) {
|
||||||
|
PrintWriter w = new PrintWriter(out);
|
||||||
|
show(w);
|
||||||
|
w.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
void show(PrintWriter out) {
|
||||||
|
|
||||||
|
if (versionFlag)
|
||||||
|
showVersion(out);
|
||||||
|
|
||||||
|
if (commandLineHelpQuery != null)
|
||||||
|
showCommandLineHelp(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show version information for JavaTest.
|
||||||
|
* @param out the stream to which to write the information
|
||||||
|
*/
|
||||||
|
void showVersion(PrintWriter out) {
|
||||||
|
Properties manifest = getManifestForClass(getClass());
|
||||||
|
if (manifest == null)
|
||||||
|
manifest = new Properties();
|
||||||
|
|
||||||
|
String unknown = i18n.getString("help.version.unknown");
|
||||||
|
|
||||||
|
// build properties, from manifest
|
||||||
|
String prefix = "jtreg"; // base name of containing .jar file
|
||||||
|
String product = "jtdiff"; // manifest.getProperty(productPrefix + "-Name", unknown);
|
||||||
|
String version = manifest.getProperty(prefix + "-Version", unknown);
|
||||||
|
String milestone = manifest.getProperty(prefix + "-Milestone", unknown);
|
||||||
|
String build = manifest.getProperty(prefix + "-Build", unknown);
|
||||||
|
String buildJavaVersion = manifest.getProperty(prefix + "-BuildJavaVersion", unknown);
|
||||||
|
String buildDate = manifest.getProperty(prefix + "-BuildDate", unknown);
|
||||||
|
|
||||||
|
String thisJavaHome = System.getProperty("java.home");
|
||||||
|
String thisJavaVersion = System.getProperty("java.version");
|
||||||
|
|
||||||
|
File classPathFile = getClassPathFileForClass(Main.class);
|
||||||
|
String classPath = (classPathFile == null ? unknown : classPathFile.getPath());
|
||||||
|
|
||||||
|
DateFormat df = DateFormat.getDateInstance(DateFormat.LONG);
|
||||||
|
|
||||||
|
Object[] versionArgs = {
|
||||||
|
product,
|
||||||
|
version,
|
||||||
|
milestone,
|
||||||
|
build,
|
||||||
|
classPath,
|
||||||
|
thisJavaVersion,
|
||||||
|
thisJavaHome,
|
||||||
|
buildJavaVersion,
|
||||||
|
buildDate
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Example format string:
|
||||||
|
*
|
||||||
|
* {0}, version {1} {2} {3}
|
||||||
|
* Installed in {4}
|
||||||
|
* Running on platform version {5} from {6}.
|
||||||
|
* Built with {7} on {8}.
|
||||||
|
*
|
||||||
|
* Example output:
|
||||||
|
*
|
||||||
|
* jtdiff, version 3.2.2 dev b00
|
||||||
|
* Installed in /tl/ws/jct-tools-322dev/dist/jtreg/lib/jtreg.jar
|
||||||
|
* Running on platform version 1.5.0_06 from /opt/java/5.0/jre.
|
||||||
|
* Built with 1.5.0_06 on 09/11/2006 07:52 PM.
|
||||||
|
*/
|
||||||
|
|
||||||
|
out.println(i18n.getString("help.version.txt", versionArgs));
|
||||||
|
out.println(i18n.getString("help.copyright.txt"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private File getDocDir() {
|
||||||
|
File classPathFile = getClassPathFileForClass(Main.class);
|
||||||
|
if (classPathFile == null)
|
||||||
|
return null;
|
||||||
|
File lib = classPathFile.getParentFile();
|
||||||
|
File home = lib.getParentFile();
|
||||||
|
File doc = new File(new File(home, "doc"), "jtreg");
|
||||||
|
if (doc.exists())
|
||||||
|
return doc;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private URL getClassPathEntryForClass(Class<?> c) {
|
||||||
|
try {
|
||||||
|
URL url = c.getResource("/" + c.getName().replace('.', '/') + ".class");
|
||||||
|
if (url.getProtocol().equals("jar")) {
|
||||||
|
String path = url.getPath();
|
||||||
|
int sep = path.lastIndexOf("!");
|
||||||
|
return new URL(path.substring(0, sep));
|
||||||
|
}
|
||||||
|
} catch (MalformedURLException ignore) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private File getClassPathFileForClass(Class<?> c) {
|
||||||
|
URL url = getClassPathEntryForClass(c);
|
||||||
|
if (url.getProtocol().equals("file"))
|
||||||
|
return new File(url.getPath());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Properties getManifestForClass(Class<?> c) {
|
||||||
|
URL classPathEntry = getClassPathEntryForClass(c);
|
||||||
|
if (classPathEntry == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
Enumeration<URL> e = getClass().getClassLoader().getResources("META-INF/MANIFEST.MF");
|
||||||
|
while (e.hasMoreElements()) {
|
||||||
|
URL url = e.nextElement();
|
||||||
|
if (url.getProtocol().equals("jar")) {
|
||||||
|
String path = url.getPath();
|
||||||
|
int sep = path.lastIndexOf("!");
|
||||||
|
URL u = new URL(path.substring(0, sep));
|
||||||
|
if (u.equals(classPathEntry)) {
|
||||||
|
Properties p = new Properties();
|
||||||
|
InputStream in = url.openStream();
|
||||||
|
p.load(in);
|
||||||
|
in.close();
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException ignore) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print out info about the options accepted by the command line decoder.
|
||||||
|
* @param out A stream to which to write the information.
|
||||||
|
*/
|
||||||
|
void showCommandLineHelp(PrintWriter out) {
|
||||||
|
HelpTree commandHelpTree = new HelpTree();
|
||||||
|
|
||||||
|
Integer nodeIndent = Integer.getInteger("javatest.help.nodeIndent");
|
||||||
|
if (nodeIndent != null)
|
||||||
|
commandHelpTree.setNodeIndent(nodeIndent);
|
||||||
|
|
||||||
|
Integer descIndent = Integer.getInteger("javatest.help.descIndent");
|
||||||
|
if (descIndent != null)
|
||||||
|
commandHelpTree.setDescriptionIndent(descIndent);
|
||||||
|
|
||||||
|
// first, group the options by their group, and sort within group
|
||||||
|
// by their first name
|
||||||
|
Set<String> groups = new LinkedHashSet<String>();
|
||||||
|
for (Option o: options)
|
||||||
|
groups.add(o.group);
|
||||||
|
Map<String, SortedMap<String, Option>> map =
|
||||||
|
new LinkedHashMap<String, SortedMap<String, Option>>();
|
||||||
|
for (String g: groups)
|
||||||
|
map.put(g, new TreeMap<String, Option>(new CaseInsensitiveStringComparator()));
|
||||||
|
for (Option o: options) {
|
||||||
|
if (o.names.length > 0)
|
||||||
|
map.get(o.group).put(o.names[0], o);
|
||||||
|
}
|
||||||
|
|
||||||
|
// now build the help tree nodes and add then into the primary help node
|
||||||
|
for (String g: groups) {
|
||||||
|
SortedMap<String, Option> optionsForGroup = map.get(g);
|
||||||
|
// continue;
|
||||||
|
List<HelpTree.Node> nodesForGroup = new ArrayList<HelpTree.Node>();
|
||||||
|
for (Option o: optionsForGroup.values())
|
||||||
|
nodesForGroup.add(createOptionHelpNode(o));
|
||||||
|
HelpTree.Node groupNode = new HelpTree.Node(i18n, "help." + g.toLowerCase(),
|
||||||
|
nodesForGroup.toArray(new HelpTree.Node[nodesForGroup.size()]));
|
||||||
|
commandHelpTree.addNode(groupNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
String progName = getProgramName();
|
||||||
|
|
||||||
|
try {
|
||||||
|
WrapWriter ww = new WrapWriter(out);
|
||||||
|
|
||||||
|
if (commandLineHelpQuery == null || commandLineHelpQuery.isEmpty()) {
|
||||||
|
// no keywords given
|
||||||
|
ww.write(i18n.getString("help.cmd.proto", progName));
|
||||||
|
ww.write("\n\n");
|
||||||
|
ww.write(i18n.getString("help.cmd.introHead"));
|
||||||
|
ww.write('\n');
|
||||||
|
commandHelpTree.writeSummary(ww);
|
||||||
|
} else if (commandLineHelpQuery.contains("all")) {
|
||||||
|
// -help all
|
||||||
|
ww.write(i18n.getString("help.cmd.proto", progName));
|
||||||
|
ww.write("\n\n");
|
||||||
|
ww.write(i18n.getString("help.cmd.fullHead"));
|
||||||
|
ww.write('\n');
|
||||||
|
commandHelpTree.write(ww);
|
||||||
|
} else {
|
||||||
|
String[] query = commandLineHelpQuery.toArray(new String[commandLineHelpQuery.size()]);
|
||||||
|
HelpTree.Selection s = commandHelpTree.find(query);
|
||||||
|
if (s != null)
|
||||||
|
commandHelpTree.write(ww, s);
|
||||||
|
else {
|
||||||
|
ww.write(i18n.getString("help.cmd.noEntriesFound"));
|
||||||
|
ww.write("\n\n");
|
||||||
|
ww.write(i18n.getString("help.cmd.summaryHead"));
|
||||||
|
ww.write('\n');
|
||||||
|
commandHelpTree.writeSummary(ww);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ww.write('\n');
|
||||||
|
ww.write(i18n.getString("help.cmd.tail"));
|
||||||
|
ww.write("\n\n");
|
||||||
|
ww.write(i18n.getString("help.cmd.ant"));
|
||||||
|
ww.write("\n\n");
|
||||||
|
ww.write(i18n.getString("help.copyright.txt"));
|
||||||
|
ww.write("\n\n");
|
||||||
|
|
||||||
|
ww.flush();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// should not happen, from PrintWriter
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private HelpTree.Node createOptionHelpNode(Option o) {
|
||||||
|
String prefix = "help." + o.group.toLowerCase() + "."
|
||||||
|
+ o.names[0].replaceAll("^-+", "").replaceAll("[^A-Za-z0-9.]+", "_");
|
||||||
|
String arg = (o.argType == Option.ArgType.NONE ? null : i18n.getString(prefix + ".arg"));
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (String n: o.names) {
|
||||||
|
if (sb.length() > 0)
|
||||||
|
sb.append(" | ");
|
||||||
|
sb.append(n);
|
||||||
|
switch (o.argType) {
|
||||||
|
case NONE:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OLD: // old is deprecated, so just show preferred format
|
||||||
|
case STD:
|
||||||
|
case FILE:
|
||||||
|
sb.append(":").append(arg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GNU:
|
||||||
|
case SEP:
|
||||||
|
case REST:
|
||||||
|
sb.append(" ").append(arg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WILDCARD:
|
||||||
|
sb.append(arg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OPT:
|
||||||
|
sb.append(" | -").append(n).append(":").append(arg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String name = sb.toString();
|
||||||
|
String desc = i18n.getString(prefix + ".desc");
|
||||||
|
String[] values = o.getChoices();
|
||||||
|
if (values == null || values.length == 0)
|
||||||
|
return new HelpTree.Node(name, desc);
|
||||||
|
else {
|
||||||
|
HelpTree.Node[] children = new HelpTree.Node[values.length];
|
||||||
|
for (int i = 0; i < children.length; i++)
|
||||||
|
children[i] = new HelpTree.Node(values[i], i18n.getString(prefix + "." + values[i] + ".desc"));
|
||||||
|
return new HelpTree.Node(name, desc, children);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getProgramName() {
|
||||||
|
String p = System.getProperty("program");
|
||||||
|
if (p != null)
|
||||||
|
return p;
|
||||||
|
|
||||||
|
return "java " + Main.class.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class CaseInsensitiveStringComparator implements Comparator<String> {
|
||||||
|
public int compare(String s1, String s2) {
|
||||||
|
if (s1 == null && s2 == null)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (s1 == null || s2 == null)
|
||||||
|
return (s1 == null ? -1 : +1);
|
||||||
|
|
||||||
|
return s1.compareToIgnoreCase(s2);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private final List<Option> options;
|
||||||
|
private boolean versionFlag;
|
||||||
|
private List<String> commandLineHelpQuery;
|
||||||
|
|
||||||
|
private static final I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(Main.class);
|
||||||
|
}
|
|
@ -0,0 +1,308 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2007, 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO: XMLReporter
|
||||||
|
* TODO: filter options
|
||||||
|
* TODO: comparator option
|
||||||
|
* TODO: css option
|
||||||
|
**/
|
||||||
|
|
||||||
|
package com.sun.javatest.diff;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.tools.ant.BuildException;
|
||||||
|
import org.apache.tools.ant.Project;
|
||||||
|
import org.apache.tools.ant.taskdefs.MatchingTask;
|
||||||
|
import org.apache.tools.ant.types.Commandline;
|
||||||
|
|
||||||
|
import com.sun.javatest.regtest.tool.AntOptionDecoder;
|
||||||
|
import com.sun.javatest.regtest.BadArgs;
|
||||||
|
import com.sun.javatest.regtest.tool.Option;
|
||||||
|
import com.sun.javatest.regtest.tool.OptionDecoder;
|
||||||
|
import com.sun.javatest.util.I18NResourceBundle;
|
||||||
|
|
||||||
|
import static com.sun.javatest.regtest.tool.Option.ArgType.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main entry point for jtdiff.
|
||||||
|
*/
|
||||||
|
public class Main {
|
||||||
|
//---------- command line option decoding ----------------------------------
|
||||||
|
|
||||||
|
private static final String COMPARE = "compare";
|
||||||
|
private static final String OUTPUT = "output";
|
||||||
|
private static final String DOC = "doc";
|
||||||
|
private static final String FILES = "files";
|
||||||
|
|
||||||
|
List<Option> options = Arrays.asList(
|
||||||
|
new Option(NONE, COMPARE, "r", "-r", "-reason") {
|
||||||
|
@Override
|
||||||
|
public void process(String opt, String arg) {
|
||||||
|
includeReason = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Option(NONE, COMPARE, "s", "-s", "-super") {
|
||||||
|
@Override
|
||||||
|
public void process(String opt, String arg) {
|
||||||
|
superMode = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Option(OLD, OUTPUT, "o", "-o", "-outFile") {
|
||||||
|
@Override
|
||||||
|
public void process(String opt, String arg) {
|
||||||
|
outFile = new File(arg);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Option(STD, OUTPUT, "format", "-format") {
|
||||||
|
@Override
|
||||||
|
public void process(String opt, String arg) {
|
||||||
|
format = arg;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Option(OLD, OUTPUT, "title", "-title") {
|
||||||
|
@Override
|
||||||
|
public void process(String opt, String arg) {
|
||||||
|
title = arg;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Option(REST, DOC, "help", "-h", "-help", "--help", "-usage") {
|
||||||
|
@Override
|
||||||
|
public void process(String opt, String arg) {
|
||||||
|
if (help == null)
|
||||||
|
help = new Help(options);
|
||||||
|
help.setCommandLineHelpQuery(arg);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Option(NONE, DOC, "help", "-version") {
|
||||||
|
@Override
|
||||||
|
public void process(String opt, String arg) {
|
||||||
|
if (help == null)
|
||||||
|
help = new Help(options);
|
||||||
|
help.setVersionFlag(true);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Option(FILE, FILES, null) {
|
||||||
|
@Override
|
||||||
|
public void process(String opt, String arg) {
|
||||||
|
File f = new File(arg);
|
||||||
|
fileArgs.add(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
//---------- Ant Invovation ------------------------------------------------
|
||||||
|
|
||||||
|
public static class Ant extends MatchingTask {
|
||||||
|
private final Main m = new Main();
|
||||||
|
private final List<Commandline.Argument> args = new ArrayList<>();
|
||||||
|
private String format;
|
||||||
|
private File outFile;
|
||||||
|
private String title;
|
||||||
|
private boolean failOnError = true;
|
||||||
|
private String resultProperty;
|
||||||
|
|
||||||
|
public void setFormat(String format) {
|
||||||
|
this.format = format;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOutFile(File outFile) {
|
||||||
|
this.outFile = outFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResultProperty(String name) {
|
||||||
|
this.resultProperty = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFailOnError(boolean yes) {
|
||||||
|
this.failOnError = yes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addArg(Commandline.Argument arg) {
|
||||||
|
args.add(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
AntOptionDecoder decoder = new AntOptionDecoder(m.options);
|
||||||
|
decoder.process("format", format);
|
||||||
|
decoder.process("outFile", outFile);
|
||||||
|
decoder.process("title", title);
|
||||||
|
|
||||||
|
if (args.size() > 0) {
|
||||||
|
List<String> allArgs = new ArrayList<>();
|
||||||
|
for (Commandline.Argument a: args)
|
||||||
|
allArgs.addAll(Arrays.asList(a.getParts()));
|
||||||
|
decoder.decodeArgs(allArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean ok = m.run();
|
||||||
|
|
||||||
|
if (resultProperty != null) {
|
||||||
|
Project p = getProject();
|
||||||
|
p.setProperty(resultProperty, String.valueOf(ok ? 0 : 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (failOnError && !ok)
|
||||||
|
throw new BuildException(i18n.getString("main.diffsFound"));
|
||||||
|
|
||||||
|
} catch (BadArgs | Fault e) {
|
||||||
|
throw new BuildException(e.getMessage(), e);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new BuildException(i18n.getString("main.interrupted"), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------- Command line invocation support -------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard entry point. Only returns if GUI mode is initiated; otherwise, it calls System.exit
|
||||||
|
* with an appropriate exit code.
|
||||||
|
* @param args An array of args, such as might be supplied on the command line.
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
PrintWriter out = new PrintWriter(System.out, true);
|
||||||
|
PrintWriter err = new PrintWriter(System.err, true);
|
||||||
|
Main m = new Main(out, err);
|
||||||
|
try {
|
||||||
|
boolean ok;
|
||||||
|
try {
|
||||||
|
ok = m.run(args);
|
||||||
|
if (!ok && (m.outFile != null)) {
|
||||||
|
// no need for an additional message if outFile == null
|
||||||
|
err.println(i18n.getString("main.diffsFound"));
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
out.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ok) {
|
||||||
|
// take care not to exit if GUI might be around,
|
||||||
|
// and take care to ensure JavaTestSecurityManager will
|
||||||
|
// permit the exit
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
} catch (Fault e) {
|
||||||
|
err.println(i18n.getString("main.error", e.getMessage()));
|
||||||
|
exit(2);
|
||||||
|
} catch (BadArgs e) {
|
||||||
|
err.println(i18n.getString("main.badArgs", e.getMessage()));
|
||||||
|
new Help(m.options).showCommandLineHelp(out);
|
||||||
|
exit(2);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
err.println(i18n.getString("main.interrupted"));
|
||||||
|
exit(2);
|
||||||
|
} catch (Exception e) {
|
||||||
|
err.println(i18n.getString("main.unexpectedException"));
|
||||||
|
e.printStackTrace(System.err);
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
|
} // main()
|
||||||
|
|
||||||
|
public Main() {
|
||||||
|
this(new PrintWriter(System.out, true), new PrintWriter(System.err, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Main(PrintWriter out, PrintWriter err) {
|
||||||
|
this.out = out;
|
||||||
|
this.err = err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode command line args and perform the requested operations.
|
||||||
|
* @param args An array of args, such as might be supplied on the command line.
|
||||||
|
* @throws BadArgs if problems are found with any of the supplied args
|
||||||
|
* @throws Fault if exception problems are found while trying to compare the results
|
||||||
|
* @throws InterruptedException if the tool is interrupted while comparing the results
|
||||||
|
*/
|
||||||
|
public final boolean run(String[] args) throws BadArgs, Fault, InterruptedException {
|
||||||
|
new OptionDecoder(options).decodeArgs(args);
|
||||||
|
|
||||||
|
if (superMode) {
|
||||||
|
if (fileArgs.size() != 1 || !fileArgs.get(0).isDirectory())
|
||||||
|
throw new Fault(i18n, "main.bad.super.dir");
|
||||||
|
if (format != null)
|
||||||
|
throw new Fault(i18n, "main.bad.super.format");
|
||||||
|
if (outFile == null)
|
||||||
|
throw new Fault(i18n, "main.no.output.dir");
|
||||||
|
}
|
||||||
|
|
||||||
|
return run();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean run() throws Fault, InterruptedException {
|
||||||
|
if (fileArgs.isEmpty() && !superMode && help == null) {
|
||||||
|
help = new Help(options);
|
||||||
|
help.setCommandLineHelpQuery(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (help != null) {
|
||||||
|
help.show(out);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Diff d;
|
||||||
|
if (superMode)
|
||||||
|
d = new SuperDiff(fileArgs.get(0));
|
||||||
|
else
|
||||||
|
d = new StandardDiff(fileArgs);
|
||||||
|
|
||||||
|
d.out = out;
|
||||||
|
d.includeReason = includeReason;
|
||||||
|
d.format = format;
|
||||||
|
d.title = title;
|
||||||
|
|
||||||
|
return d.report(outFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void exit(int exitCode) {
|
||||||
|
System.exit(exitCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private PrintWriter out;
|
||||||
|
private PrintWriter err;
|
||||||
|
|
||||||
|
private boolean includeReason;
|
||||||
|
private String format;
|
||||||
|
private String title;
|
||||||
|
private File outFile;
|
||||||
|
private List<File> fileArgs = new ArrayList<>();
|
||||||
|
private boolean superMode;
|
||||||
|
private Help help;
|
||||||
|
|
||||||
|
private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(Main.class);
|
||||||
|
}
|
|
@ -0,0 +1,173 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2007, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.diff;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Map from a key to a possibly sparse array of values.
|
||||||
|
*/
|
||||||
|
public class MultiMap<K, V> implements Map<K, MultiMap.Entry<V>> {
|
||||||
|
public static class Entry<V> {
|
||||||
|
|
||||||
|
private Entry(MultiMap<?, ?> t) {
|
||||||
|
table = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
V get(int index) {
|
||||||
|
return (index < list.size() ? list.get(index) : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
int getSize() {
|
||||||
|
return table.getColumns();
|
||||||
|
}
|
||||||
|
|
||||||
|
void put(int index, V value) {
|
||||||
|
if (index >= table.getColumns())
|
||||||
|
throw new IndexOutOfBoundsException();
|
||||||
|
|
||||||
|
if (list == null)
|
||||||
|
list = new ArrayList<V>(index);
|
||||||
|
|
||||||
|
if (index < list.size())
|
||||||
|
list.set(index, value);
|
||||||
|
else {
|
||||||
|
while (index > list.size())
|
||||||
|
list.add(null);
|
||||||
|
list.add(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean allEqual(Comparator<V> c) {
|
||||||
|
if (list.size() == 0)
|
||||||
|
return true;
|
||||||
|
int size = table.getColumns();
|
||||||
|
V v0 = list.get(0);
|
||||||
|
for (int i = 1; i < size; i++) {
|
||||||
|
V v = get(i);
|
||||||
|
if (c.compare(v, v0) != 0)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<V> list;
|
||||||
|
private MultiMap<?, ?> table;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Creates a new instance of MultiMap */
|
||||||
|
public MultiMap() {
|
||||||
|
names = new ArrayList<String>();
|
||||||
|
map = new TreeMap<K, Entry<V>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
int getColumns() {
|
||||||
|
return names.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
String getColumnName(int index) {
|
||||||
|
return names.get(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
int addColumn(String name) {
|
||||||
|
names.add(name);
|
||||||
|
return names.size() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addColumn(String name, Map<K, V> map) {
|
||||||
|
addColumn(name, map.entrySet());
|
||||||
|
}
|
||||||
|
|
||||||
|
void addColumn(String name, Iterable<Map.Entry<K, V>> iter) {
|
||||||
|
int index = addColumn(name);
|
||||||
|
for (Map.Entry<K, V> e: iter)
|
||||||
|
addRow(index, e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
void addRow(int index, K k, V v) {
|
||||||
|
Entry<V> de = get(k);
|
||||||
|
if (de == null)
|
||||||
|
put(k, de = new Entry<V>(this));
|
||||||
|
de.put(index, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return map.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Entry<V> get(Object path) {
|
||||||
|
return map.get(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return map.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean containsKey(Object key) {
|
||||||
|
return map.containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean containsValue(Object value) {
|
||||||
|
return map.containsValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Entry<V> put(K key, Entry<V> value) {
|
||||||
|
return map.put(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Entry<V> remove(Object key) {
|
||||||
|
return map.remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void putAll(Map<? extends K, ? extends Entry<V>> t) {
|
||||||
|
map.putAll(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
map.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Map.Entry<K, Entry<V>>> entrySet() {
|
||||||
|
return map.entrySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<K> keySet() {
|
||||||
|
return map.keySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<Entry<V>> values() {
|
||||||
|
return map.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> names;
|
||||||
|
private TreeMap<K, Entry<V>> map;
|
||||||
|
}
|
|
@ -0,0 +1,128 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2007, 2008, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.diff;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.sun.javatest.Status;
|
||||||
|
import com.sun.javatest.TestDescription;
|
||||||
|
import com.sun.javatest.TestResult;
|
||||||
|
import com.sun.javatest.util.I18NResourceBundle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read a set of test results from summary.txt, possibly located in a
|
||||||
|
* report directory.
|
||||||
|
*/
|
||||||
|
public class ReportReader implements DiffReader {
|
||||||
|
private static final String SUMMARY_TXT = "summary.txt";
|
||||||
|
|
||||||
|
public static boolean accepts(File f) {
|
||||||
|
if (!f.exists())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (f.isFile() && f.getName().equals(SUMMARY_TXT))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (f.isDirectory() && new File(f, SUMMARY_TXT).exists())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (f.isDirectory() && new File(new File(f, "text"), SUMMARY_TXT).exists())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Creates a new instance of SummaryReader */
|
||||||
|
public ReportReader(File file) {
|
||||||
|
this.file = file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getFile() {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileType() {
|
||||||
|
if (file != null && file.isDirectory())
|
||||||
|
return i18n.getString("report.reportDir");
|
||||||
|
else
|
||||||
|
return i18n.getString("report.reportFile");
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getWorkDirectory() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterator<TestResult> iterator() {
|
||||||
|
return readSummary().iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<TestResult> readSummary() {
|
||||||
|
List<TestResult> list = new ArrayList<TestResult>();
|
||||||
|
File root = getRoot();
|
||||||
|
File f;
|
||||||
|
if (file.isFile() && file.getName().equals(SUMMARY_TXT))
|
||||||
|
f = file;
|
||||||
|
else if (file.isDirectory() && new File(file, SUMMARY_TXT).exists())
|
||||||
|
f = new File(file, SUMMARY_TXT);
|
||||||
|
else if (file.isDirectory() && new File(new File(file, "text"), SUMMARY_TXT).exists())
|
||||||
|
f = new File(new File(file, "text"), SUMMARY_TXT);
|
||||||
|
else
|
||||||
|
throw new IllegalStateException();
|
||||||
|
|
||||||
|
try {
|
||||||
|
BufferedReader in = new BufferedReader(new FileReader(f));
|
||||||
|
String line;
|
||||||
|
while ((line = in.readLine()) != null) {
|
||||||
|
int sp = line.indexOf(' ');
|
||||||
|
String t = line.substring(0, sp);
|
||||||
|
Status s = Status.parse(line.substring(sp).trim());
|
||||||
|
TestDescription td = new TestDescription(root, new File(t), Collections.emptyMap());
|
||||||
|
TestResult tr = new TestResult(td, s);
|
||||||
|
list.add(tr);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private File getRoot() {
|
||||||
|
return UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static File UNKNOWN = new File("unknown");
|
||||||
|
|
||||||
|
private File file;
|
||||||
|
|
||||||
|
private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(WorkDirectoryReader.class);
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2007, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.diff;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.sun.javatest.TestResult;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for generating reports.
|
||||||
|
*/
|
||||||
|
public abstract class Reporter {
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Comparator<TestResult> getComparator() {
|
||||||
|
return comparator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComparator(Comparator<TestResult> c) {
|
||||||
|
this.comparator = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReaders(List<DiffReader> readers) {
|
||||||
|
this.readers = readers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTestCounts(List<int[]> testCounts) {
|
||||||
|
this.testCounts = testCounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDiffCount() {
|
||||||
|
return diffs;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract void write(MultiMap<String, TestResult> table) throws IOException;
|
||||||
|
|
||||||
|
protected List<DiffReader> readers;
|
||||||
|
protected List<int[]> testCounts = new ArrayList<int[]>();
|
||||||
|
protected Comparator<TestResult> comparator;
|
||||||
|
protected String title;
|
||||||
|
protected int diffs;
|
||||||
|
}
|
|
@ -0,0 +1,164 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2007, 2021, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO: colorize output?
|
||||||
|
|
||||||
|
package com.sun.javatest.diff;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.sun.javatest.Status;
|
||||||
|
import com.sun.javatest.TestResult;
|
||||||
|
import com.sun.javatest.util.I18NResourceBundle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write simple reports to a text file.
|
||||||
|
*/
|
||||||
|
public class SimpleReporter extends Reporter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance of SimpleReporter
|
||||||
|
*/
|
||||||
|
public SimpleReporter(PrintWriter out) {
|
||||||
|
if (out == null)
|
||||||
|
throw new NullPointerException();
|
||||||
|
|
||||||
|
this.out = out;
|
||||||
|
|
||||||
|
statusStrings = new String[4];
|
||||||
|
statusStrings[Status.PASSED] = i18n.getString("simple.pass");
|
||||||
|
statusStrings[Status.FAILED] = i18n.getString("simple.fail");
|
||||||
|
statusStrings[Status.ERROR] = i18n.getString("simple.error");
|
||||||
|
statusStrings[Status.NOT_RUN] = i18n.getString("simple.notRun");
|
||||||
|
for (String ss: statusStrings)
|
||||||
|
maxStatusStringLength = Math.max(maxStatusStringLength, ss.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(MultiMap<String, TestResult> table) throws IOException {
|
||||||
|
this.table = table;
|
||||||
|
size = table.getColumns();
|
||||||
|
|
||||||
|
if (title != null) {
|
||||||
|
println(title);
|
||||||
|
println();
|
||||||
|
}
|
||||||
|
|
||||||
|
writeHead();
|
||||||
|
writeBody();
|
||||||
|
writeSummary();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeHead() throws IOException {
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
int[] c = testCounts.get(i);
|
||||||
|
int passed = c[Status.PASSED];
|
||||||
|
int failed = c[Status.FAILED];
|
||||||
|
int error = c[Status.ERROR];
|
||||||
|
int notRun = c[Status.NOT_RUN];
|
||||||
|
writeI18N("simple.set", i, table.getColumnName(i));
|
||||||
|
print(" ");
|
||||||
|
writeI18N("simple.counts",
|
||||||
|
passed,
|
||||||
|
(passed > 0) && (failed + error + notRun > 0) ? 1 : 0,
|
||||||
|
failed,
|
||||||
|
(failed > 0) && (error + notRun > 0) ? 1 : 0,
|
||||||
|
error,
|
||||||
|
(error > 0) && (notRun > 0) ? 1 : 0,
|
||||||
|
notRun);
|
||||||
|
println();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeBody() throws IOException {
|
||||||
|
diffs = 0;
|
||||||
|
for (Map.Entry<String, MultiMap.Entry<TestResult>> e: table.entrySet()) {
|
||||||
|
String testName = e.getKey();
|
||||||
|
MultiMap.Entry<TestResult> result = e.getValue();
|
||||||
|
if (result.allEqual(comparator))
|
||||||
|
continue;
|
||||||
|
if (diffs == 0) {
|
||||||
|
println();
|
||||||
|
for (int i = 0; i < result.getSize(); i++) {
|
||||||
|
print(String.valueOf(i), maxStatusStringLength + 2);
|
||||||
|
}
|
||||||
|
writeI18N("simple.test");
|
||||||
|
println();
|
||||||
|
}
|
||||||
|
for (int i = 0; i < result.getSize(); i++) {
|
||||||
|
TestResult tr = result.get(i);
|
||||||
|
Status s = (tr == null ? null : tr.getStatus());
|
||||||
|
print(getStatusString(s), maxStatusStringLength + 2);
|
||||||
|
}
|
||||||
|
println(testName);
|
||||||
|
diffs++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeSummary() throws IOException {
|
||||||
|
println();
|
||||||
|
if (diffs == 0)
|
||||||
|
writeI18N("simple.diffs.none");
|
||||||
|
else
|
||||||
|
writeI18N("simple.diffs.count", diffs);
|
||||||
|
println();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeI18N(String key, Object... args) throws IOException {
|
||||||
|
print(i18n.getString(key, args));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void print(Object o) throws IOException {
|
||||||
|
out.print(o.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void print(String s, int width) throws IOException {
|
||||||
|
out.print(s);
|
||||||
|
for (int i = s.length(); i < width; i++)
|
||||||
|
out.print(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
private void println() throws IOException {
|
||||||
|
out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void println(Object o) throws IOException {
|
||||||
|
out.println(o.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getStatusString(Status s) {
|
||||||
|
return statusStrings[s == null ? Status.NOT_RUN : s.getType()];
|
||||||
|
}
|
||||||
|
|
||||||
|
private MultiMap<String, TestResult> table;
|
||||||
|
private int size;
|
||||||
|
private PrintWriter out;
|
||||||
|
|
||||||
|
private String[] statusStrings;
|
||||||
|
private int maxStatusStringLength;
|
||||||
|
|
||||||
|
private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(SimpleReporter.class);
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2008, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.diff;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class StandardDiff extends Diff {
|
||||||
|
StandardDiff(List<File> files) {
|
||||||
|
this.files = files;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean report(File outFile) throws Fault, InterruptedException {
|
||||||
|
return diff(files, outFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<File> files;
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2007, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.diff;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
import com.sun.javatest.Status;
|
||||||
|
import com.sun.javatest.TestResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A comparator for the status contained in a test result.
|
||||||
|
*/
|
||||||
|
public class StatusComparator implements Comparator<TestResult> {
|
||||||
|
|
||||||
|
/** Creates a new instance of StatusComparator */
|
||||||
|
public StatusComparator() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Creates a new instance of StatusComparator */
|
||||||
|
public StatusComparator(boolean includeReason) {
|
||||||
|
this.includeReason = includeReason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compare(TestResult o1, TestResult o2) {
|
||||||
|
int t1 = getType(o1);
|
||||||
|
int t2 = getType(o2);
|
||||||
|
|
||||||
|
if (t1 < t2)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (t1 > t2)
|
||||||
|
return +1;
|
||||||
|
|
||||||
|
if (!includeReason)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
String r1 = getReason(o1);
|
||||||
|
String r2 = getReason(o2);
|
||||||
|
return r1.compareTo(r2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getType(TestResult tr) {
|
||||||
|
if (tr == null)
|
||||||
|
return Status.NOT_RUN;
|
||||||
|
Status s = tr.getStatus();
|
||||||
|
return (s == null ? Status.NOT_RUN : s.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getReason(TestResult tr) {
|
||||||
|
if (tr == null)
|
||||||
|
return "";
|
||||||
|
Status s = tr.getStatus();
|
||||||
|
return (s == null ? "" : s.getReason());
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean includeReason;
|
||||||
|
}
|
|
@ -0,0 +1,345 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2008, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.diff;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ListIterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import com.sun.javatest.util.I18NResourceBundle;
|
||||||
|
|
||||||
|
import static com.sun.javatest.util.HTMLWriter.*;
|
||||||
|
|
||||||
|
class SuperDiff extends Diff {
|
||||||
|
SuperDiff(File dir) {
|
||||||
|
table = new SuperTable(dir, resultPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean report(File outDir) throws Fault, InterruptedException {
|
||||||
|
baseTitle = title;
|
||||||
|
boolean ok = true;
|
||||||
|
for (YearDay yearDay: table.getRecentKeys(historySize))
|
||||||
|
ok &= diffPlatforms(yearDay, outDir);
|
||||||
|
for (String platform : table.platforms) {
|
||||||
|
ok &= diffHistory(platform, outDir);
|
||||||
|
}
|
||||||
|
writeIndex(outDir, baseTitle);
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean diff(List<File> files, File outFile, String title) throws Fault, InterruptedException {
|
||||||
|
this.title = title;
|
||||||
|
reporter = null;
|
||||||
|
return diff(files, outFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initReporter() throws Fault {
|
||||||
|
try {
|
||||||
|
reporter = new SuperReporter(out);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new Fault(i18n, "main.cantOpenReport", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean diffPlatforms(YearDay yearDay, File outDir) throws Fault, InterruptedException {
|
||||||
|
Map<String, File> pMap = table.get(yearDay);
|
||||||
|
List<File> pDirs = new ArrayList<File>();
|
||||||
|
for (String platform : table.platforms) {
|
||||||
|
File dir = pMap.get(platform);
|
||||||
|
if (dir != null) {
|
||||||
|
pDirs.add(dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
File file = new File(outDir, yearDay.year + "_" + yearDay.dayOfYear + ".html");
|
||||||
|
platformIndex.put(yearDay.toDateString(monthDayFormat), file);
|
||||||
|
String prefix = baseTitle == null ? "" : baseTitle + ": ";
|
||||||
|
return diff(pDirs, file, prefix + yearDay.toDateString(mediumDateFormat)); // I18N a better title?
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean diffHistory(String platform, File outDir) throws Fault, InterruptedException {
|
||||||
|
List<File> pDirs = new ArrayList<File>();
|
||||||
|
for (YearDay yearDay: table.getRecentKeys(historySize, platform)) {
|
||||||
|
pDirs.add(table.get(yearDay).get(platform));
|
||||||
|
}
|
||||||
|
File file = new File(outDir, platform + ".html");
|
||||||
|
historyIndex.put(platform, file);
|
||||||
|
String prefix = baseTitle == null ? "" : baseTitle + ": ";
|
||||||
|
return diff(pDirs, file, prefix + platform); // I18N a better title?
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeIndex(File outDir, String title) throws Fault {
|
||||||
|
PrintWriter out;
|
||||||
|
try {
|
||||||
|
out = new PrintWriter(new BufferedWriter(new FileWriter(new File(outDir, "index.html"))));
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new Fault(i18n, "main.cantOpenReport", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
SuperReporter r = new SuperReporter(out);
|
||||||
|
r.writeMainIndex(title);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new Fault(i18n, "main.ioError", e);
|
||||||
|
} finally {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String resultPath = System.getProperty("jtdiff.super.testResults", "JTreport/text/summary.txt");
|
||||||
|
protected int historySize = Integer.getInteger("jtdiff.super.history", 21);
|
||||||
|
|
||||||
|
private SuperTable table;
|
||||||
|
private String baseTitle;
|
||||||
|
private Map<String, File> historyIndex = new LinkedHashMap<String, File>();
|
||||||
|
private Map<String, File> platformIndex = new LinkedHashMap<String, File>();
|
||||||
|
|
||||||
|
private static DateFormat monthDayFormat = new SimpleDateFormat("MMM d");
|
||||||
|
private static DateFormat mediumDateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
|
||||||
|
private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(Main.class);
|
||||||
|
|
||||||
|
static class Info {
|
||||||
|
Info(String platform, Date date) {
|
||||||
|
this.platform = platform;
|
||||||
|
this.date = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String platform;
|
||||||
|
final Date date;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SuperReporter extends HTMLReporter {
|
||||||
|
SuperReporter(Writer out) throws IOException {
|
||||||
|
super(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void writeIndexTableInfoHeadings() throws IOException {
|
||||||
|
out.startTag(TH);
|
||||||
|
out.writeI18N("super.th.platform");
|
||||||
|
out.endTag(TH);
|
||||||
|
out.startTag(TH);
|
||||||
|
out.writeI18N("super.th.date");
|
||||||
|
out.endTag(TH);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void writeIndexTableInfoValues(String path) throws IOException {
|
||||||
|
Info info = table.getInfo(path);
|
||||||
|
out.startTag(TD);
|
||||||
|
if (info != null)
|
||||||
|
out.write(info.platform);
|
||||||
|
out.endTag(TD);
|
||||||
|
out.startTag(TD);
|
||||||
|
if (info != null)
|
||||||
|
out.write(monthDayFormat.format(info.date));
|
||||||
|
out.endTag(TD);
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeMainIndex(String title) throws IOException {
|
||||||
|
startReport(title);
|
||||||
|
|
||||||
|
if (baseTitle != null) {
|
||||||
|
out.startTag(H1);
|
||||||
|
out.write(baseTitle);
|
||||||
|
out.endTag(H1);
|
||||||
|
}
|
||||||
|
|
||||||
|
writeMainIndexList(i18n.getString("super.platforms"), platformIndex);
|
||||||
|
writeMainIndexList(i18n.getString("super.history"), historyIndex);
|
||||||
|
|
||||||
|
endReport();
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeMainIndexList(String head, Map<String, File> map) throws IOException {
|
||||||
|
out.startTag(H2);
|
||||||
|
out.write(head);
|
||||||
|
out.endTag(H2);
|
||||||
|
out.startTag(P);
|
||||||
|
String comma = "";
|
||||||
|
for (Map.Entry<String, File> e: map.entrySet()) {
|
||||||
|
out.write(comma);
|
||||||
|
out.startTag(A);
|
||||||
|
out.writeAttr(HREF, e.getValue().getName());
|
||||||
|
String nbsp = "";
|
||||||
|
for (String s: e.getKey().split(" ")) {
|
||||||
|
out.writeEntity(nbsp);
|
||||||
|
out.write(s);
|
||||||
|
nbsp = " ";
|
||||||
|
}
|
||||||
|
out.endTag(A);
|
||||||
|
comma = ", ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static class SuperTable extends TreeMap<YearDay, Map<String, File>> {
|
||||||
|
|
||||||
|
static final long serialVersionUID = 5933594140534747584L;
|
||||||
|
|
||||||
|
SuperTable(File inDir, String resultPath) {
|
||||||
|
super();
|
||||||
|
for (File pDir : inDir.listFiles()) {
|
||||||
|
if (!pDir.isDirectory()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (File yDir : pDir.listFiles()) {
|
||||||
|
if (!yDir.isDirectory()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (File dDir : yDir.listFiles()) {
|
||||||
|
if (!dDir.isDirectory()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
File resultDir = new File(dDir, resultPath);
|
||||||
|
if (resultDir.exists()) {
|
||||||
|
add(pDir.getName(), yDir.getName(), dDir.getName(), resultDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void add(String platform, String year, String day, File dir) {
|
||||||
|
platforms.add(platform);
|
||||||
|
YearDay yd = new YearDay(year, day);
|
||||||
|
Map<String, File> pMap = get(yd);
|
||||||
|
if (pMap == null) {
|
||||||
|
pMap = new HashMap<String, File>();
|
||||||
|
put(yd, pMap);
|
||||||
|
}
|
||||||
|
pMap.put(platform, dir);
|
||||||
|
|
||||||
|
Date date;
|
||||||
|
try {
|
||||||
|
Calendar c = Calendar.getInstance();
|
||||||
|
c.clear();
|
||||||
|
c.set(Calendar.YEAR, Integer.parseInt(year));
|
||||||
|
c.set(Calendar.DAY_OF_YEAR, Integer.parseInt(day));
|
||||||
|
date = c.getTime();
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
date = null;
|
||||||
|
}
|
||||||
|
infoTable.put(dir.getPath(), new Info(platform, date));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<YearDay> getRecentKeys(int n) {
|
||||||
|
return getRecentKeys(n, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<YearDay> getRecentKeys(int n, String platform) {
|
||||||
|
LinkedList<YearDay> results = new LinkedList<YearDay>();
|
||||||
|
List<YearDay> keys = new ArrayList<YearDay>(keySet());
|
||||||
|
for (ListIterator<YearDay> iter = keys.listIterator(keys.size());
|
||||||
|
iter.hasPrevious() && results.size() < n; ) {
|
||||||
|
YearDay key = iter.previous();
|
||||||
|
if (platform == null || get(key).get(platform) != null)
|
||||||
|
results.addFirst(key);
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info getInfo(String path) {
|
||||||
|
return infoTable.get(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
final Set<String> platforms = new TreeSet<String>();
|
||||||
|
final Map<String, Info> infoTable = new HashMap<String, Info>();
|
||||||
|
}
|
||||||
|
|
||||||
|
static class YearDay implements Comparable<YearDay> {
|
||||||
|
YearDay(String year, String dayOfYear) {
|
||||||
|
year.getClass();
|
||||||
|
dayOfYear.getClass();
|
||||||
|
this.year = year;
|
||||||
|
this.dayOfYear = dayOfYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (!(o instanceof YearDay))
|
||||||
|
return false;
|
||||||
|
YearDay ydo = (YearDay) o;
|
||||||
|
return year.equals(ydo.year) && dayOfYear.equals(ydo.dayOfYear);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return year.hashCode() * 37 + dayOfYear.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
//@Override
|
||||||
|
public int compareTo(YearDay o) {
|
||||||
|
int c = compare(year, o.year);
|
||||||
|
return (c == 0 ? compare(dayOfYear, o.dayOfYear) : c);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return year + ":" + dayOfYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date asDate() {
|
||||||
|
try {
|
||||||
|
Calendar c = Calendar.getInstance();
|
||||||
|
c.clear();
|
||||||
|
c.set(Calendar.YEAR, Integer.parseInt(year));
|
||||||
|
c.set(Calendar.DAY_OF_YEAR, Integer.parseInt(dayOfYear));
|
||||||
|
return c.getTime();
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toDateString(DateFormat f) {
|
||||||
|
Date d = asDate();
|
||||||
|
return (d == null ? toString() : f.format(d));
|
||||||
|
}
|
||||||
|
|
||||||
|
private int compare(String left, String right) {
|
||||||
|
return left.compareTo(right);
|
||||||
|
}
|
||||||
|
|
||||||
|
final String year;
|
||||||
|
final String dayOfYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,122 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2007, 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.diff;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import com.sun.javatest.TestFinder;
|
||||||
|
import com.sun.javatest.TestResult;
|
||||||
|
import com.sun.javatest.TestResultTable;
|
||||||
|
import com.sun.javatest.TestSuite;
|
||||||
|
import com.sun.javatest.WorkDirectory;
|
||||||
|
import com.sun.javatest.regtest.config.RegressionTestSuite;
|
||||||
|
import com.sun.javatest.util.I18NResourceBundle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read test results from a work directory.
|
||||||
|
*/
|
||||||
|
public class WorkDirectoryReader implements DiffReader {
|
||||||
|
public static boolean accepts(File f) {
|
||||||
|
return WorkDirectory.isWorkDirectory(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Creates a new instance of WorkDirectoryReader */
|
||||||
|
public WorkDirectoryReader(File file)
|
||||||
|
throws FileNotFoundException, WorkDirectory.Fault, TestSuite.Fault {
|
||||||
|
this.file = file;
|
||||||
|
|
||||||
|
// Because regtest testsuites don't contain testsuite.jtt
|
||||||
|
// files, we can't use the standard WorkDirectory.open call.
|
||||||
|
File tsp = getTestSuitePath(file);
|
||||||
|
if (tsp != null && new File(tsp, "TEST.ROOT").exists()) {
|
||||||
|
TestSuite ts = new RegressionTestSuite(tsp, new TestFinder.ErrorHandler() {
|
||||||
|
public void error(String msg) {
|
||||||
|
WorkDirectoryReader.this.error(msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
wd = WorkDirectory.open(file, ts);
|
||||||
|
} else
|
||||||
|
wd = WorkDirectory.open(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getFile() {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileType() {
|
||||||
|
return i18n.getString("wd.name");
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getWorkDirectory() {
|
||||||
|
return wd.getRoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public Iterator<TestResult> iterator() {
|
||||||
|
TestResultTable trt = wd.getTestResultTable();
|
||||||
|
trt.waitUntilReady();
|
||||||
|
return trt.getIterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static File getTestSuitePath(File workDir) {
|
||||||
|
File f = new File(new File(workDir, "jtData"), "testsuite");
|
||||||
|
if (!f.exists())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
InputStream in = null;
|
||||||
|
try {
|
||||||
|
in = new BufferedInputStream(new FileInputStream(f));
|
||||||
|
Properties p = new Properties();
|
||||||
|
p.load(in);
|
||||||
|
in.close();
|
||||||
|
String ts = p.getProperty("root");
|
||||||
|
return (ts == null ? null : new File(ts));
|
||||||
|
} catch (IOException e) {
|
||||||
|
try {
|
||||||
|
if (in != null)
|
||||||
|
in.close();
|
||||||
|
} catch (IOException ignore) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void error(String msg) {
|
||||||
|
System.err.println("Error: " + msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
private File file;;
|
||||||
|
private WorkDirectory wd;
|
||||||
|
|
||||||
|
private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(WorkDirectoryReader.class);
|
||||||
|
}
|
|
@ -0,0 +1,150 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2007, 2013, 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
diff.cantOpenFile=Cannot open file {0}: {1}
|
||||||
|
diff.cantOpenReport=Cannot open report: {0}
|
||||||
|
diff.ioError=Error: {0}
|
||||||
|
|
||||||
|
help.cmd.ant=jtdiff can also be run with Ant.
|
||||||
|
help.cmd.fullHead=
|
||||||
|
help.cmd.introHead=For brief details about a topic, use "-help <term> ...". \
|
||||||
|
The argument <term> is a command option or other word related to the topic. \
|
||||||
|
Use "-help all" to show all of the help entries.\n\nInformation is \
|
||||||
|
available for the following topics.\n
|
||||||
|
help.cmd.noEntriesFound=No entries were found that matched your query.
|
||||||
|
help.cmd.proto=Usage:\n\t{0} options... [directory|file]...
|
||||||
|
help.cmd.summaryHead=Information is available for the following topics:
|
||||||
|
help.cmd.tail=
|
||||||
|
help.copyright.txt=Copyright (c) 2008, 2013 Oracle and/or its affiliates. \
|
||||||
|
All rights reserved.\nUse is subject to license terms.
|
||||||
|
|
||||||
|
help.compare.name=Compare Options
|
||||||
|
help.compare.desc=
|
||||||
|
help.compare.r.desc=Include the reason string in the comparison, as well as \
|
||||||
|
the type (i.e. Passed, Failed, etc.)
|
||||||
|
help.compare.s.desc=Perform a "super-diff" looking for result sets within \
|
||||||
|
a directory hierarchy. The hierarchy must be arranged as \
|
||||||
|
follows: PATH/PLATFORM/YEAR/DAY_OF_YEAR/TEST_RESULTS, where PATH is \
|
||||||
|
given by the single directory argument, PLATFORM is the name of the \
|
||||||
|
platform on which the tests were run, YEAR and DAY_OF_YEAR are numbers \
|
||||||
|
identifying when the tests were run, and TESTSUITE_RESULTS is a fixed string \
|
||||||
|
identifying when to find the result set in the hierarchy. The default \
|
||||||
|
is "JTreport/text/summary.txt", but it can be set to a different value by \
|
||||||
|
setting the system property "jtdiff.super.testResults". It may identify any \
|
||||||
|
source of results acceptable to a standard invocation of jtdiff. \
|
||||||
|
Set system property jtdiff.html.compact=true for a more output format, with \
|
||||||
|
symbols replacing the words "pass" (check mark), "fail" (cross), "error" \
|
||||||
|
(cross in a circle), and "not run" (horizontal bar).
|
||||||
|
|
||||||
|
help.doc.name=Help Options
|
||||||
|
help.doc.desc=Options for additional help and information
|
||||||
|
help.doc.h.arg=[words...]
|
||||||
|
help.doc.h.desc=Command line help. Give words to see help info containing those \
|
||||||
|
or use "-help all" to see all available help.
|
||||||
|
help.doc.version.desc=Give information about the version of jtdiff in use.
|
||||||
|
|
||||||
|
help.files.name=Input Files
|
||||||
|
help.files.desc=Input files can be any of work directories, report directories, \
|
||||||
|
or the summary.txt files in a report directory.
|
||||||
|
|
||||||
|
help.output.name=Output Options
|
||||||
|
help.output.desc=Options to customize the output
|
||||||
|
help.output.format.arg=html|text
|
||||||
|
help.output.format.desc=Output format. If not specified, it is inferred from the \
|
||||||
|
extension of the output file.
|
||||||
|
help.output.o.arg=<file>
|
||||||
|
help.output.o.desc=File to which to write the results
|
||||||
|
help.output.title.arg=<string>
|
||||||
|
help.output.title.desc=Title to use for the results
|
||||||
|
|
||||||
|
help.version.txt={0}, version {1} {2} {3}\nInstalled in {4}\nRunning on platform version {5} from {6}.\nBuilt with {7} on {8}.
|
||||||
|
help.version.unknown=(unknown)
|
||||||
|
|
||||||
|
html.diffs.count={0} differences
|
||||||
|
html.diffs.none=No differences
|
||||||
|
html.generatedAt=Generated at {0}
|
||||||
|
html.error=error
|
||||||
|
html.fail=fail
|
||||||
|
html.notRun=not run
|
||||||
|
html.pass=pass
|
||||||
|
html.error.compact=⊗
|
||||||
|
html.fail.compact=×
|
||||||
|
html.notRun.compact=—
|
||||||
|
html.pass.compact=√
|
||||||
|
|
||||||
|
html.head.differences=Differences
|
||||||
|
html.head.notitle=jtdiff results
|
||||||
|
html.head.sets=Test Result Sets
|
||||||
|
html.head.title=jtdiff results: {0}
|
||||||
|
|
||||||
|
html.th.location=Location
|
||||||
|
html.th.set=Set
|
||||||
|
html.th.setN=Set {0}
|
||||||
|
html.th.test=Test
|
||||||
|
html.th.error=Errors
|
||||||
|
html.th.fail=Failed
|
||||||
|
html.th.notRun=Not Run
|
||||||
|
html.th.pass=Passed
|
||||||
|
html.th.total=Total
|
||||||
|
html.th.type=Type
|
||||||
|
|
||||||
|
main.badArgs=Error: {0}
|
||||||
|
main.bad.super.dir=Bad directory argument for "super" mode
|
||||||
|
main.bad.super.format=Cannot specify format in "super" mode
|
||||||
|
main.cantFindFile=Cannot find file: {0}
|
||||||
|
main.cantOpenFile=Cannot open file {0}: {1}
|
||||||
|
main.cantOpenReport=Cannot open report: {0}
|
||||||
|
main.diffsFound=Differences found.
|
||||||
|
main.error=Error: {0}
|
||||||
|
main.interrupted=Error: Interrupted!
|
||||||
|
main.ioError=Error: {0}
|
||||||
|
main.no.output.dir=No output directory given; use -o dir
|
||||||
|
main.unexpectedException=Error: Unexpected exception occured!
|
||||||
|
main.unrecognizedFile=File not recognized: {0}
|
||||||
|
|
||||||
|
report.reportDir=Report Drectory
|
||||||
|
report.reportFile=Report File
|
||||||
|
|
||||||
|
simple.diffs.count={0} differences
|
||||||
|
simple.diffs.none=No differences
|
||||||
|
simple.set={0}: {1}
|
||||||
|
simple.test=Test
|
||||||
|
simple.error=error
|
||||||
|
simple.fail=fail
|
||||||
|
simple.notRun=---
|
||||||
|
simple.pass=pass
|
||||||
|
|
||||||
|
simple.counts=\
|
||||||
|
{0,choice,0#|0<pass: {0,number}}{1,choice,0#|1#; }\
|
||||||
|
{2,choice,0#|0<fail: {2,number}}{3,choice,0#|1#; }\
|
||||||
|
{4,choice,0#|0<error: {4,number}}{5,choice,0#|1#; }\
|
||||||
|
{6,choice,0#|0<not run: {6,number}}
|
||||||
|
|
||||||
|
wd.name=Work Directory
|
||||||
|
|
||||||
|
super.history=Comparison of recent results by platform
|
||||||
|
super.platforms=Comparison across platforms by date
|
||||||
|
super.th.date=Date
|
||||||
|
super.th.platform=Platform
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2007, 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.regtest;
|
||||||
|
|
||||||
|
import com.sun.javatest.util.I18NResourceBundle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception to report a problem interpreting command line arguments.
|
||||||
|
*/
|
||||||
|
public class BadArgs extends Exception {
|
||||||
|
static final long serialVersionUID = -5835655326361668148L;
|
||||||
|
public BadArgs(I18NResourceBundle i18n, String s, Object... args) {
|
||||||
|
super(i18n.getString(s, args));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,186 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2005, 2018, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.regtest;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.sun.javatest.finder.CommentStream;
|
||||||
|
import com.sun.javatest.finder.HTMLCommentStream;
|
||||||
|
import com.sun.javatest.finder.JavaCommentStream;
|
||||||
|
import com.sun.javatest.finder.ShScriptCommentStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple utility to check for files containing comments which may contain action tags,
|
||||||
|
* (such as {@code @run}, {@code @compile}, etc.) but which do not contain {@code @test}.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* Usage:
|
||||||
|
* java -cp jtreg.jar:javatest.jar com.sun.javatest.regtest.CheckFiles options... files-or-directories...
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* One option is supported:
|
||||||
|
* <dl>
|
||||||
|
* <dt>{@code -l}line-length
|
||||||
|
* <dd>the amount of each suspect comment to display
|
||||||
|
* </dl>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* After the option, a series of directories and/or files to check can be specified.
|
||||||
|
* Directories will be recursively expanded looking for files to check.
|
||||||
|
* Source-code management directories are ignored.
|
||||||
|
* Files with the following extensions will be checked: {@code .java}, {@code .html}, {@code .sh}.
|
||||||
|
* Other files will be ignored.
|
||||||
|
*/
|
||||||
|
public class CheckFiles {
|
||||||
|
/**
|
||||||
|
* Main entry point.
|
||||||
|
* @param args options, followed by a series of directories or files to check for
|
||||||
|
* possibly-malformed test descriptions.
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
new CheckFiles().run(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the utility.
|
||||||
|
* @param args options, followed by a series of directories or files to check for
|
||||||
|
* possibly-malformed test descriptions
|
||||||
|
*/
|
||||||
|
public void run(String[] args) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < args.length; i++) {
|
||||||
|
String arg = args[i];
|
||||||
|
if (arg.equals("-l") && i+1 < args.length)
|
||||||
|
lineLength = Integer.parseInt(args[++i]);
|
||||||
|
else if (arg.startsWith("-")) {
|
||||||
|
System.err.println("bad arg: " + arg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
count = 0;
|
||||||
|
for (i = 0; i < args.length; i++) {
|
||||||
|
File dir = new File(args[i]);
|
||||||
|
scan(dir);
|
||||||
|
}
|
||||||
|
System.err.println(count + " suspect comments found");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scan a series of directories and files to check for possibly-malformed test descriptions.
|
||||||
|
* @param files the files to check
|
||||||
|
*/
|
||||||
|
public void scan(File... files) {
|
||||||
|
for (File file : files) {
|
||||||
|
scan(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void scan(File file) {
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
if (!excludes.contains(file.getName()))
|
||||||
|
scan(file.listFiles());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
switch (getExtension(file)) {
|
||||||
|
case JAVA:
|
||||||
|
check(file, new JavaCommentStream());
|
||||||
|
break;
|
||||||
|
case HTML:
|
||||||
|
check(file, new HTMLCommentStream());
|
||||||
|
break;
|
||||||
|
case SH:
|
||||||
|
check(file, new ShScriptCommentStream());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void check(File f, CommentStream cs) {
|
||||||
|
try (BufferedReader r = new BufferedReader(new FileReader(f))) {
|
||||||
|
cs.init(r);
|
||||||
|
String comment;
|
||||||
|
while ((comment = cs.readComment()) != null)
|
||||||
|
check(f, comment);
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
System.err.println("error for " + f + ": " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void check(File f, String comment) {
|
||||||
|
comment = comment.replace('\r', ' ');
|
||||||
|
comment = comment.replace('\n', ' ');
|
||||||
|
if (comment.contains("@test"))
|
||||||
|
return;
|
||||||
|
if (comment.matches(".*@(run|main|compile|summary|bug).*")) {
|
||||||
|
System.out.println(f + ": " + comment.substring(0, Math.min(lineLength, comment.length())));
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int count;
|
||||||
|
private int lineLength = 80;
|
||||||
|
|
||||||
|
private static final int HTML = 0;
|
||||||
|
private static final int JAVA = 1;
|
||||||
|
private static final int SH = 2;
|
||||||
|
private static final int OTHER = 3;
|
||||||
|
|
||||||
|
static int getExtension(File f) {
|
||||||
|
String name = f.getName();
|
||||||
|
int dot = name.lastIndexOf('.');
|
||||||
|
if (dot == -1)
|
||||||
|
return OTHER;
|
||||||
|
String e = name.toLowerCase().substring(dot + 1);
|
||||||
|
switch (e) {
|
||||||
|
case "java":
|
||||||
|
return JAVA;
|
||||||
|
case "html":
|
||||||
|
return HTML;
|
||||||
|
case "sh":
|
||||||
|
return SH;
|
||||||
|
default:
|
||||||
|
return OTHER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Set<String> excludes;
|
||||||
|
static {
|
||||||
|
excludes = new HashSet<>();
|
||||||
|
excludes.add("SCCS");
|
||||||
|
excludes.add("Codemgr_wsdata");
|
||||||
|
excludes.add(".hg");
|
||||||
|
excludes.add(".svn");
|
||||||
|
excludes.add("RCS");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,321 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1997, 2019, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.regtest;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.tools.ant.BuildException;
|
||||||
|
import org.apache.tools.ant.DirectoryScanner;
|
||||||
|
import org.apache.tools.ant.Project;
|
||||||
|
import org.apache.tools.ant.taskdefs.MatchingTask;
|
||||||
|
import org.apache.tools.ant.types.Commandline;
|
||||||
|
|
||||||
|
import com.sun.javatest.Harness;
|
||||||
|
import com.sun.javatest.regtest.tool.AntOptionDecoder;
|
||||||
|
import com.sun.javatest.regtest.tool.Tool;
|
||||||
|
import com.sun.javatest.util.I18NResourceBundle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main entry point to be used to access the Regression Test Harness for JDK: jtreg.
|
||||||
|
*/
|
||||||
|
public class Main {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard entry point.
|
||||||
|
* Only returns if GUI mode is initiated; otherwise, it calls System.exit with an
|
||||||
|
* appropriate exit code.
|
||||||
|
* @param args An array of options and arguments, such as might be supplied on the command line.
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Tool.main(args);
|
||||||
|
} // main()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception to report a problem while running the test harness.
|
||||||
|
*/
|
||||||
|
public static class Fault extends Exception {
|
||||||
|
static final long serialVersionUID = -6780999176737139046L;
|
||||||
|
public Fault(I18NResourceBundle i18n, String s, Object... args) {
|
||||||
|
super(i18n.getString(s, args));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Execution OK. */
|
||||||
|
public static final int EXIT_OK = 0;
|
||||||
|
/** No tests found. */
|
||||||
|
public static final int EXIT_NO_TESTS = 1;
|
||||||
|
/** One or more tests failed. */
|
||||||
|
public static final int EXIT_TEST_FAILED = 2;
|
||||||
|
/** One or more tests had an error. */
|
||||||
|
public static final int EXIT_TEST_ERROR = 3;
|
||||||
|
/** Bad user args. */
|
||||||
|
public static final int EXIT_BAD_ARGS = 4;
|
||||||
|
/** Other fault occurred. */
|
||||||
|
public static final int EXIT_FAULT = 5;
|
||||||
|
/** Unexpected exception occurred. */
|
||||||
|
public static final int EXIT_EXCEPTION = 6;
|
||||||
|
|
||||||
|
|
||||||
|
public Main() {
|
||||||
|
this(new PrintWriter(System.out, true), new PrintWriter(System.err, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Main(PrintWriter out, PrintWriter err) {
|
||||||
|
tool = new Tool(out, err);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode command line args and perform the requested operations.
|
||||||
|
* @param args An array of args, such as might be supplied on the command line.
|
||||||
|
* @throws BadArgs if problems are found with any of the supplied args
|
||||||
|
* @throws Main.Fault if a serious error occurred during execution
|
||||||
|
* @throws Harness.Fault if exception problems are found while trying to run the tests
|
||||||
|
* @throws InterruptedException if the harness is interrupted while running the tests
|
||||||
|
* @return an exit code: 0 for success, greater than 0 for an error
|
||||||
|
*/
|
||||||
|
public int run(String[] args) throws
|
||||||
|
BadArgs, Fault, Harness.Fault, InterruptedException {
|
||||||
|
return tool.run(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Tool tool;
|
||||||
|
|
||||||
|
//---------- Ant Invocation ------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ant task to invoke jtreg.
|
||||||
|
*/
|
||||||
|
public static class Ant extends MatchingTask {
|
||||||
|
private final Tool tool = new Tool();
|
||||||
|
private File jdk;
|
||||||
|
private File dir;
|
||||||
|
private File reportDir;
|
||||||
|
private File workDir;
|
||||||
|
private File nativeDir;
|
||||||
|
private boolean wsl;
|
||||||
|
private String concurrency;
|
||||||
|
private String status;
|
||||||
|
private String vmOption;
|
||||||
|
private String vmOptions;
|
||||||
|
private String javacOption;
|
||||||
|
private String javacOptions;
|
||||||
|
private String javaOption;
|
||||||
|
private String javaOptions;
|
||||||
|
private String verbose;
|
||||||
|
private boolean agentVM;
|
||||||
|
private boolean sameVM;
|
||||||
|
private boolean otherVM;
|
||||||
|
private Boolean failOnError; // yes, no, or unset
|
||||||
|
private String resultProperty;
|
||||||
|
private String failureProperty;
|
||||||
|
private String errorProperty;
|
||||||
|
private final List<Commandline.Argument> args = new ArrayList<>();
|
||||||
|
|
||||||
|
public void setDir(File dir) {
|
||||||
|
this.dir = dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReportDir(File reportDir) {
|
||||||
|
this.reportDir = reportDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWorkDir(File workDir) {
|
||||||
|
this.workDir = workDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNativeDir(File nativeDir) {
|
||||||
|
this.nativeDir = nativeDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWSL(boolean wsl) {
|
||||||
|
this.wsl = wsl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJDK(File jdk) {
|
||||||
|
this.jdk = jdk;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConcurrency(String concurrency) {
|
||||||
|
this.concurrency = concurrency;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Should rethink this, and perhaps allow nested vmoption elements.
|
||||||
|
// On the other hand, users can give nested <args> for vmoptions too.
|
||||||
|
public void setVMOption(String vmOpt) {
|
||||||
|
this.vmOption = vmOpt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVMOptions(String vmOpts) {
|
||||||
|
this.vmOptions = vmOpts;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Should rethink this, and perhaps allow nested javacoption elements.
|
||||||
|
// On the other hand, users can give nested <args> for vmoptions too.
|
||||||
|
public void setJavacOption(String javacOpt) {
|
||||||
|
this.javacOption = javacOpt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJavacOptions(String javacOpts) {
|
||||||
|
this.javacOptions = javacOpts;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Should rethink this, and perhaps allow nested javaoption elements.
|
||||||
|
// On the other hand, users can give nested <args> for vmoptions too.
|
||||||
|
public void setJavaOption(String javaOpt) {
|
||||||
|
this.javaOption = javaOpt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJavaOptions(String javaOpts) {
|
||||||
|
this.javaOptions = javaOpts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVerbose(String verbose) {
|
||||||
|
this.verbose = verbose;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAgentVM(boolean yes) {
|
||||||
|
this.agentVM = yes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSameVM(boolean yes) {
|
||||||
|
this.sameVM = yes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOtherVM(boolean yes) {
|
||||||
|
this.otherVM = yes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResultProperty(String name) {
|
||||||
|
this.resultProperty = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFailureProperty(String name) {
|
||||||
|
this.failureProperty = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrorProperty(String name) {
|
||||||
|
this.errorProperty = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFailOnError(boolean yes) {
|
||||||
|
this.failOnError = yes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addArg(Commandline.Argument arg) {
|
||||||
|
args.add(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
Project p = getProject();
|
||||||
|
|
||||||
|
// import javatest.* properties as system properties
|
||||||
|
Map<?, ?> properties = p.getProperties();
|
||||||
|
for (Map.Entry<?, ?> e: properties.entrySet()) {
|
||||||
|
String key = (String) e.getKey();
|
||||||
|
if (key.startsWith("javatest."))
|
||||||
|
System.setProperty(key, (String) e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
AntOptionDecoder decoder = new AntOptionDecoder(tool.options);
|
||||||
|
decoder.process("-concurrency", concurrency);
|
||||||
|
decoder.process("-dir", dir);
|
||||||
|
decoder.process("-reportDir", reportDir);
|
||||||
|
decoder.process("-workDir", workDir);
|
||||||
|
decoder.process("-nativeDir", nativeDir);
|
||||||
|
decoder.process("-wsl", wsl);
|
||||||
|
decoder.process("-jdk", jdk);
|
||||||
|
decoder.process("-verbose", verbose);
|
||||||
|
decoder.process("-agentVM", agentVM);
|
||||||
|
decoder.process("-sameVM", sameVM);
|
||||||
|
decoder.process("-otherVM", otherVM);
|
||||||
|
decoder.process("-vmoption", vmOption);
|
||||||
|
decoder.process("-vmoptions", vmOptions);
|
||||||
|
decoder.process("-javaoption", javaOption);
|
||||||
|
decoder.process("-javaoptions", javaOptions);
|
||||||
|
decoder.process("-javacoption", javacOption);
|
||||||
|
decoder.process("-javacoptions", javacOptions);
|
||||||
|
decoder.process("-status", status);
|
||||||
|
|
||||||
|
if (args.size() > 0) {
|
||||||
|
List<String> allArgs = new ArrayList<>();
|
||||||
|
for (Commandline.Argument a: args)
|
||||||
|
allArgs.addAll(Arrays.asList(a.getParts()));
|
||||||
|
decoder.decodeArgs(allArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tool.testFileArgs.isEmpty()
|
||||||
|
&& tool.testFileIdArgs.isEmpty()
|
||||||
|
&& tool.testGroupArgs.isEmpty()
|
||||||
|
&& dir != null) {
|
||||||
|
DirectoryScanner s = getDirectoryScanner(dir);
|
||||||
|
addPaths(dir, s.getIncludedFiles());
|
||||||
|
}
|
||||||
|
|
||||||
|
int rc = tool.run();
|
||||||
|
|
||||||
|
if (resultProperty != null)
|
||||||
|
p.setProperty(resultProperty, String.valueOf(rc));
|
||||||
|
|
||||||
|
if (failureProperty != null && (rc >= EXIT_TEST_FAILED))
|
||||||
|
p.setProperty(failureProperty, i18n.getString("main.testsFailed"));
|
||||||
|
|
||||||
|
if (errorProperty != null && (rc >= EXIT_TEST_ERROR))
|
||||||
|
p.setProperty(errorProperty, i18n.getString("main.testsError"));
|
||||||
|
|
||||||
|
if (failOnError == null)
|
||||||
|
failOnError = (resultProperty == null && failureProperty == null && errorProperty == null);
|
||||||
|
|
||||||
|
if (failOnError && rc != EXIT_OK)
|
||||||
|
throw new BuildException(i18n.getString("main.testsFailed"));
|
||||||
|
|
||||||
|
} catch (BadArgs | Fault | Harness.Fault e) {
|
||||||
|
throw new BuildException(e.getMessage(), e);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new BuildException(i18n.getString("main.interrupted"), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addPaths(File dir, String[] paths) {
|
||||||
|
if (paths != null) {
|
||||||
|
for (String p: paths)
|
||||||
|
tool.antFileArgs.add(new File(dir, p));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static I18NResourceBundle i18n = I18NResourceBundle.getBundleForClass(Main.class);
|
||||||
|
}
|
|
@ -0,0 +1,92 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2013, 2017, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.regtest;
|
||||||
|
|
||||||
|
import com.sun.javatest.Status;
|
||||||
|
|
||||||
|
/** JDK 1.1 factory for normalized status objects. */
|
||||||
|
public class RStatus {
|
||||||
|
|
||||||
|
private RStatus() { }
|
||||||
|
|
||||||
|
public static Status passed(String msg) {
|
||||||
|
return Status.passed(normalize(msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Status failed(String msg) {
|
||||||
|
return Status.failed(normalize(msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Status error(String msg) {
|
||||||
|
return Status.error(normalize(msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Status createStatus(int code, String msg) {
|
||||||
|
return new Status(code, normalize(msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Status normalize(Status s) {
|
||||||
|
return new Status(s.getType(), normalize(s.getReason()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// equivalent to msg.trim().replaceAll("\\s+", " ");
|
||||||
|
private static String normalize(String msg) {
|
||||||
|
boolean ok = true;
|
||||||
|
boolean prevIsWhite = false;
|
||||||
|
for (int i = 0; ok && i < msg.length(); i++) {
|
||||||
|
char ch = msg.charAt(i);
|
||||||
|
if (Character.isWhitespace(ch)) {
|
||||||
|
if (prevIsWhite || ch != ' ' || i == 0) {
|
||||||
|
ok = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
prevIsWhite = true;
|
||||||
|
} else {
|
||||||
|
prevIsWhite = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (prevIsWhite)
|
||||||
|
ok = false;
|
||||||
|
if (ok)
|
||||||
|
return msg;
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
boolean needWhite = false;
|
||||||
|
for (int i = 0; i < msg.length(); i++) {
|
||||||
|
char ch = msg.charAt(i);
|
||||||
|
if (Character.isWhitespace(ch)) {
|
||||||
|
if (sb.length() > 0)
|
||||||
|
needWhite = true;
|
||||||
|
} else {
|
||||||
|
if (needWhite)
|
||||||
|
sb.append(' ');
|
||||||
|
sb.append(ch);
|
||||||
|
needWhite = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,178 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2014, 2016, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.regtest;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import com.sun.javatest.regtest.agent.Alarm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract superclass for timeout handlers.
|
||||||
|
*
|
||||||
|
* Instances of this class will be called when an action involving a process has timed out.
|
||||||
|
* jtreg provides a default implementation of this class;
|
||||||
|
* alternative implementation may be specified on the {@code jtreg} command line.
|
||||||
|
*/
|
||||||
|
public abstract class TimeoutHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The log to which messages should be written.
|
||||||
|
*/
|
||||||
|
protected final PrintWriter log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The directory in which diagnostic information may be written.
|
||||||
|
*/
|
||||||
|
protected final File outputDir;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The JDK being tested.
|
||||||
|
*/
|
||||||
|
protected final File testJdk;
|
||||||
|
|
||||||
|
private long timeout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a timeout handler.
|
||||||
|
*
|
||||||
|
* @param log to which messages should be written
|
||||||
|
* @param outputDir a directory in which diagnostic information may be written
|
||||||
|
* @param testJdk the JDK being tested
|
||||||
|
*/
|
||||||
|
public TimeoutHandler(PrintWriter log, File outputDir, File testJdk) {
|
||||||
|
this.log = log;
|
||||||
|
this.outputDir = outputDir;
|
||||||
|
this.testJdk = testJdk;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the timeout, in seconds, after which the handler itself will be interrupted.
|
||||||
|
* A negative or zero value disables the timeout.
|
||||||
|
*
|
||||||
|
* @param timeout the timeout
|
||||||
|
*/
|
||||||
|
public void setTimeout(long timeout) {
|
||||||
|
this.timeout = timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the timeout, in seconds, after which the handler itself will be interrupted.
|
||||||
|
* A negative or zero value disables the timeout.
|
||||||
|
*
|
||||||
|
* @return the timeout
|
||||||
|
*/
|
||||||
|
public long getTimeout() {
|
||||||
|
return timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initiates the timeout handler, to analyze a specified process, by calling {@link #runActions}.
|
||||||
|
* The handler itself is subject to a secondary timeout, which can be specified with
|
||||||
|
* {@link #setTimeout}.
|
||||||
|
*
|
||||||
|
* @param proc the process
|
||||||
|
*/
|
||||||
|
public final void handleTimeout(Process proc) {
|
||||||
|
log.println("Timeout information:");
|
||||||
|
long pid = 0;
|
||||||
|
try {
|
||||||
|
pid = getProcessId(proc);
|
||||||
|
} catch(Exception ex) {
|
||||||
|
ex.printStackTrace(log);
|
||||||
|
}
|
||||||
|
if (pid == 0) {
|
||||||
|
log.println("Could not find process id for the process that timed out.");
|
||||||
|
log.println("Skipping timeout handling.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Alarm a = (timeout <= 0)
|
||||||
|
? Alarm.NONE
|
||||||
|
: Alarm.scheduleInterrupt(timeout, TimeUnit.SECONDS, log, Thread.currentThread());
|
||||||
|
try {
|
||||||
|
runActions(proc, pid);
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
a.cancel();
|
||||||
|
log.println("Timeout handler interrupted: ");
|
||||||
|
ex.printStackTrace(log);
|
||||||
|
} finally {
|
||||||
|
a.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
log.println("--- Timeout information end.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs actions on the process to gather data that can be used to analyze the time out.
|
||||||
|
*
|
||||||
|
* @param process the process that has timed out
|
||||||
|
* @param pid the pid of the process
|
||||||
|
* @throws InterruptedException if the actions exceed the specified timeout
|
||||||
|
*/
|
||||||
|
protected abstract void runActions(Process process, long pid) throws InterruptedException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the process id of the specified process.
|
||||||
|
*
|
||||||
|
* @param proc the process
|
||||||
|
* @return The process id, or 0 if the process id cannot be found
|
||||||
|
*/
|
||||||
|
protected long getProcessId(Process proc) {
|
||||||
|
try {
|
||||||
|
try {
|
||||||
|
Method pid = Process.class.getMethod("pid");
|
||||||
|
return (Long) pid.invoke(proc);
|
||||||
|
} catch (NoSuchMethodException ignore) {
|
||||||
|
// This exception is expected on pre-JDK 9,
|
||||||
|
// try a fallback method that only works on Unix platforms
|
||||||
|
return getProcessIdPreJdk9(proc);
|
||||||
|
}
|
||||||
|
} catch (ReflectiveOperationException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static long getProcessIdPreJdk9(Process proc)
|
||||||
|
throws IllegalAccessException, NoSuchFieldException {
|
||||||
|
if (proc.getClass().getName().equals("java.lang.UNIXProcess")) {
|
||||||
|
int pid;
|
||||||
|
Field f = proc.getClass().getDeclaredField("pid");
|
||||||
|
boolean oldValue = f.isAccessible();
|
||||||
|
try {
|
||||||
|
f.setAccessible(true);
|
||||||
|
pid = f.getInt(proc);
|
||||||
|
} finally {
|
||||||
|
f.setAccessible(oldValue);
|
||||||
|
}
|
||||||
|
return pid;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,395 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1996, 2018, 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.
|
||||||
|
*/
|
||||||
|
package com.sun.javatest.regtest.agent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class to embody the result of a test: a status-code and a related message.
|
||||||
|
*
|
||||||
|
* This is a reduced copy of com.sun.javatest.Status, sufficient to the needs
|
||||||
|
* of returning test results from a test VM. In particular, it implements the
|
||||||
|
* same protocol to transfer results across process boundaries, meaning the
|
||||||
|
* encoding of the status type and reason.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class AStatus
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a Status to indicate the successful outcome of a test.
|
||||||
|
* @param reason A short string describing why the test passed.
|
||||||
|
* @return a Status to indicate the successful outcome of a test.
|
||||||
|
*/
|
||||||
|
public static AStatus passed(String reason) {
|
||||||
|
return new AStatus(PASSED, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Status to indicate the unsuccessful outcome of a test:
|
||||||
|
* i.e. the test completed, but the test determined that what was being tested
|
||||||
|
* did not pass the test.
|
||||||
|
* @param reason A short string describing why the test failed.
|
||||||
|
* @return a Status to indicate the unsuccessful outcome of a test.
|
||||||
|
*/
|
||||||
|
public static AStatus failed(String reason) {
|
||||||
|
return new AStatus(FAILED, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Status to indicate that an error occurred while trying to run a test:
|
||||||
|
* i.e. the test did not complete for some reason, and so it could not determine
|
||||||
|
* whether what was being tested passed or failed.
|
||||||
|
* @param reason A short string describing the error that occurred.
|
||||||
|
* @return a Status to indicate the error outcome of a test.
|
||||||
|
*/
|
||||||
|
public static AStatus error(String reason) {
|
||||||
|
return new AStatus(ERROR, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the type code of the status is PASSED.
|
||||||
|
* @return true if the type code is PASSED.
|
||||||
|
* @see #passed
|
||||||
|
* @see #getType
|
||||||
|
* @see #PASSED
|
||||||
|
*/
|
||||||
|
public boolean isPassed() {
|
||||||
|
return (type == PASSED);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the type code of the status is FAILED.
|
||||||
|
* @return true if the type code is FAILED.
|
||||||
|
* @see #failed
|
||||||
|
* @see #getType
|
||||||
|
* @see #FAILED
|
||||||
|
*/
|
||||||
|
public boolean isFailed() {
|
||||||
|
return (type == FAILED);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the type code of the status is ERROR.
|
||||||
|
* @return true if the type code is ERROR.
|
||||||
|
* @see #error
|
||||||
|
* @see #getType
|
||||||
|
* @see #ERROR
|
||||||
|
*/
|
||||||
|
public boolean isError() {
|
||||||
|
return (type == ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the type code of the status is NOT_RUN.
|
||||||
|
* @return true if the type code is ERROR.
|
||||||
|
* @see #getType
|
||||||
|
* @see #NOT_RUN
|
||||||
|
*/
|
||||||
|
public boolean isNotRun() {
|
||||||
|
return (type == NOT_RUN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A return code indicating that the test was executed and was successful.
|
||||||
|
* @see #passed
|
||||||
|
* @see #getType
|
||||||
|
*/
|
||||||
|
public static final int PASSED = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A return code indicating that the test was executed but the test
|
||||||
|
* reported that it failed.
|
||||||
|
* @see #failed
|
||||||
|
* @see #getType
|
||||||
|
*/
|
||||||
|
public static final int FAILED = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A return code indicating that the test was not run because some error
|
||||||
|
* occurred before the test could even be attempted. This is generally
|
||||||
|
* a more serious error than FAILED.
|
||||||
|
* @see #getType
|
||||||
|
*/
|
||||||
|
public static final int ERROR = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A return code indicating that the test has not yet been run in this context.
|
||||||
|
* (More specifically, no status file has been recorded for this test in the
|
||||||
|
* current work directory.) This is for the internal use of the harness only.
|
||||||
|
* @see #getType
|
||||||
|
*/
|
||||||
|
public static final int NOT_RUN = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of states which are predefined as "constants".
|
||||||
|
*/
|
||||||
|
public static final int NUM_STATES = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the type code indicating the type of this Status object.
|
||||||
|
* @return the type code indicating the type of this Status object.
|
||||||
|
* @see #PASSED
|
||||||
|
* @see #FAILED
|
||||||
|
* @see #ERROR
|
||||||
|
*/
|
||||||
|
public int getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message given when the status was created.
|
||||||
|
* @return the string given when this Status object was created.
|
||||||
|
*/
|
||||||
|
public String getReason() {
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a Status to a string.
|
||||||
|
* @see #parse
|
||||||
|
*/
|
||||||
|
public String toString() {
|
||||||
|
if (reason == null || reason.length() == 0)
|
||||||
|
return texts[type];
|
||||||
|
else
|
||||||
|
return texts[type] + " " + reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience exit() function for the main() of tests to exit in such a
|
||||||
|
* way that the status passes up across process boundaries without losing
|
||||||
|
* information (ie exit codes don't give the associated text of the status
|
||||||
|
* and return codes when exceptions are thrown could cause unintended
|
||||||
|
* results). <p>
|
||||||
|
*
|
||||||
|
* An identifying marker is written to the error stream, which the script
|
||||||
|
* running the test watches for as the last output before returning,
|
||||||
|
* followed by the type and reason
|
||||||
|
*
|
||||||
|
* The method does not return. It calls System.exit with a value
|
||||||
|
* dependent on the type.
|
||||||
|
*/
|
||||||
|
public void exit() {
|
||||||
|
if (System.err != null) {
|
||||||
|
System.err.print(EXIT_PREFIX);
|
||||||
|
System.err.print(texts[type]);
|
||||||
|
System.err.println(encode(reason));
|
||||||
|
System.err.flush();
|
||||||
|
}
|
||||||
|
System.exit(exitCodes[type]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Status object. See {@link #passed}, {@link #failed}, {@link #error}
|
||||||
|
* etc. for more convenient factory methods to create Status objects.
|
||||||
|
* @param type The type code for the Status object.
|
||||||
|
* @param reason A short string to store in the status. Unprintable
|
||||||
|
* characters (i.e. outside the range 040C to 177C) in the string are
|
||||||
|
* replaced by a space. All whitespace runs are reduced to a single
|
||||||
|
* whitespace.
|
||||||
|
* @throws IllegalArgumentException if the specified type is invalid.
|
||||||
|
*/
|
||||||
|
public AStatus(int type, String reason) throws IllegalArgumentException {
|
||||||
|
if (type < 0 || type >= NUM_STATES)
|
||||||
|
throw new IllegalArgumentException(String.valueOf(type));
|
||||||
|
|
||||||
|
this.type = type;
|
||||||
|
this.reason = normalize(reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----internal routines----------------------------------------------------
|
||||||
|
// equivalent to msg.trim().replaceAll("\\s+", " ");
|
||||||
|
private static String normalize(String msg) {
|
||||||
|
boolean ok = true;
|
||||||
|
boolean prevIsWhite = false;
|
||||||
|
for (int i = 0; ok && i < msg.length(); i++) {
|
||||||
|
char ch = msg.charAt(i);
|
||||||
|
if (Character.isWhitespace(ch)) {
|
||||||
|
if (prevIsWhite || ch != ' ' || i == 0) {
|
||||||
|
ok = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
prevIsWhite = true;
|
||||||
|
} else {
|
||||||
|
prevIsWhite = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (prevIsWhite) {
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
boolean needWhite = false;
|
||||||
|
for (int i = 0; i < msg.length(); i++) {
|
||||||
|
char ch = msg.charAt(i);
|
||||||
|
if (Character.isWhitespace(ch)) {
|
||||||
|
if (sb.length() > 0) {
|
||||||
|
needWhite = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (needWhite) {
|
||||||
|
sb.append(' ');
|
||||||
|
}
|
||||||
|
sb.append(ch);
|
||||||
|
needWhite = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final boolean isPrintable(char c) {
|
||||||
|
return (32 <= c && c < 127);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------Data members----------------------------------------------------
|
||||||
|
|
||||||
|
private final int type;
|
||||||
|
private final String reason;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A string used to prefix the status when it is written to System.err
|
||||||
|
* by {@link #exit}.
|
||||||
|
*/
|
||||||
|
public static final String EXIT_PREFIX = "STATUS:";
|
||||||
|
|
||||||
|
private static final String[] texts = {
|
||||||
|
// correspond to PASSED, FAILED, ERROR, NOT_RUN
|
||||||
|
"Passed.",
|
||||||
|
"Failed.",
|
||||||
|
"Error.",
|
||||||
|
"Not run."
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exit codes used by Status.exit corresponding to
|
||||||
|
* PASSED, FAILED, ERROR, NOT_RUN.
|
||||||
|
* The only values that should normally be returned from a test
|
||||||
|
* are the first three; the other value is provided for completeness.
|
||||||
|
* <font size=-1> Note: The assignment is historical and cannot easily be changed. </font>
|
||||||
|
*/
|
||||||
|
public static final int[] exitCodes = { 95, 97, 98, 99 };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes strings containing non-ascii characters, where all characters
|
||||||
|
* are replaced with with their Unicode code. Encoded string will have
|
||||||
|
* the certain prefix and suffix to be distinguished from non-encode one.
|
||||||
|
* Strings of ASCII chars only are encoded into themselves.<br>
|
||||||
|
* Example:
|
||||||
|
* <pre>
|
||||||
|
* System.out.println(Status.encode("X \u01AB")); //<Encoded>58 20 1AB </Encoded>
|
||||||
|
* System.out.println(Status.encode("Abc1")); // Abc1
|
||||||
|
* </pre>
|
||||||
|
* @param str - string to encode
|
||||||
|
* @return Encoded string or the same string if none non-ascii chars were found
|
||||||
|
*
|
||||||
|
* @see #decode(java.lang.String)
|
||||||
|
*/
|
||||||
|
public static String encode(String str) {
|
||||||
|
if (str == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
boolean isAscii = true;
|
||||||
|
for (int i = 0; i < str.length(); i++) {
|
||||||
|
if (!isPrintable(str.charAt(i))) {
|
||||||
|
isAscii = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isAscii) {
|
||||||
|
return str; // no need to decode;
|
||||||
|
}
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(ENC_PREFFIX);
|
||||||
|
for (int i = 0; i < str.length(); i++) {
|
||||||
|
sb.append(encodeChar(str.charAt(i)));
|
||||||
|
sb.append(ENC_SEPARATOR);
|
||||||
|
}
|
||||||
|
sb.append(ENC_SUFFFIX);
|
||||||
|
return sb.toString();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes string encoded by encode(String) method.
|
||||||
|
* @param str - string to decode
|
||||||
|
* @return Decoded string or the same string if encoded prefix/suffix
|
||||||
|
* were found
|
||||||
|
*
|
||||||
|
* @see #encode(java.lang.String)
|
||||||
|
*/
|
||||||
|
public static String decode(String str) {
|
||||||
|
if (str == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int ind = str.indexOf(ENC_PREFFIX);
|
||||||
|
if (ind < 0 || !str.endsWith(ENC_SUFFFIX)) {
|
||||||
|
return str; // not encoded
|
||||||
|
}
|
||||||
|
|
||||||
|
// identify encoded part
|
||||||
|
String encoded = str.substring(ind + ENC_PREFFIX.length(),
|
||||||
|
str.length() - ENC_SUFFFIX.length());
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(str, 0, ind);
|
||||||
|
|
||||||
|
// emulate StringTokenizer(encoded, ENC_SEPARATOR) to find tokens
|
||||||
|
int begin = 0;
|
||||||
|
int end = encoded.indexOf(ENC_SEPARATOR);
|
||||||
|
while (end >= 0) {
|
||||||
|
sb.append(decodeChar(encoded.substring(begin, end)));
|
||||||
|
begin = end + ENC_SEPARATOR.length();
|
||||||
|
end = encoded.indexOf(ENC_SEPARATOR, begin);
|
||||||
|
}
|
||||||
|
sb.append(encoded.substring(begin));
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String encodeChar(char c) {
|
||||||
|
return Integer.toString((int)c, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static char decodeChar(String s) {
|
||||||
|
return (char)Integer.parseInt(s, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefix signaling that string is encoded
|
||||||
|
*/
|
||||||
|
private static final String ENC_PREFFIX = "<EncodeD>";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Suffix signaling that string is encoded
|
||||||
|
*/
|
||||||
|
private static final String ENC_SUFFFIX = "</EncodeD>";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Separator of encoded chars
|
||||||
|
*/
|
||||||
|
private static final String ENC_SEPARATOR = " ";
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,276 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998, 2018, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.regtest.agent;
|
||||||
|
|
||||||
|
import java.io.PrintStream;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.security.AccessController;
|
||||||
|
import java.security.PrivilegedAction;
|
||||||
|
import java.security.Provider;
|
||||||
|
import java.security.Security;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import static com.sun.javatest.regtest.agent.AStatus.error;
|
||||||
|
import static com.sun.javatest.regtest.agent.AStatus.passed;
|
||||||
|
|
||||||
|
public class ActionHelper {
|
||||||
|
|
||||||
|
// <editor-fold defaultstate="collapsed" desc=" Save State ">
|
||||||
|
/**
|
||||||
|
* SaveState captures important system state, such as the security manager,
|
||||||
|
* standard IO streams and system properties, and provides a way to
|
||||||
|
* subsequently restore that state.
|
||||||
|
*/
|
||||||
|
static class SaveState {
|
||||||
|
|
||||||
|
SaveState() {
|
||||||
|
if (sysProps == null) {
|
||||||
|
sysProps = copyProperties(System.getProperties());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save and setup streams for the test
|
||||||
|
stdOut = System.out;
|
||||||
|
stdErr = System.err;
|
||||||
|
|
||||||
|
// Default Locale
|
||||||
|
locale = Locale.getDefault();
|
||||||
|
|
||||||
|
// Save security manager in case changed by test
|
||||||
|
secMgr = System.getSecurityManager();
|
||||||
|
|
||||||
|
// If using default security manager, allow props access, and reset dirty bit
|
||||||
|
if (secMgr instanceof RegressionSecurityManager) {
|
||||||
|
RegressionSecurityManager rsm = (RegressionSecurityManager) secMgr;
|
||||||
|
rsm.setAllowPropertiesAccess(true);
|
||||||
|
rsm.resetPropertiesModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
securityProviders = Security.getProviders();
|
||||||
|
}
|
||||||
|
|
||||||
|
AStatus restore(String testName, AStatus status) {
|
||||||
|
AStatus cleanupStatus = null;
|
||||||
|
|
||||||
|
// Reset security manager, if necessary
|
||||||
|
// Do this first, to ensure we reset permissions
|
||||||
|
try {
|
||||||
|
if (System.getSecurityManager() != secMgr) {
|
||||||
|
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||||
|
@Override
|
||||||
|
public Object run() {
|
||||||
|
System.setSecurityManager(secMgr);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//System.setSecurityManager(secMgr);
|
||||||
|
}
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
// If we cannot reset the security manager, we might not be able to do
|
||||||
|
// much at all -- such as write files. So, be very noisy to the
|
||||||
|
// primary system error stream about this badly behaved test.
|
||||||
|
stdErr.println();
|
||||||
|
stdErr.println("***");
|
||||||
|
stdErr.println("*** " + testName);
|
||||||
|
stdErr.println("*** Cannot reset security manager after test");
|
||||||
|
stdErr.println("*** " + e.getMessage());
|
||||||
|
stdErr.println("***");
|
||||||
|
stdErr.println();
|
||||||
|
cleanupStatus = error(AGENTVM_CANT_RESET_SECMGR + ": " + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
final Provider[] sp = Security.getProviders();
|
||||||
|
if (!equal(securityProviders, sp)) {
|
||||||
|
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||||
|
@Override
|
||||||
|
public Object run() {
|
||||||
|
for (Provider p : sp) {
|
||||||
|
Security.removeProvider(p.getName());
|
||||||
|
}
|
||||||
|
for (Provider p : securityProviders) {
|
||||||
|
Security.addProvider(p);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
cleanupStatus = error(AGENTVM_CANT_RESET_SECPROVS + ": " + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset system properties, if necessary
|
||||||
|
// The default security manager tracks whether system properties may have
|
||||||
|
// been written: if so, we reset all the system properties, otherwise
|
||||||
|
// we just reset important props that were written in the test setup
|
||||||
|
boolean resetAllSysProps;
|
||||||
|
SecurityManager sm = System.getSecurityManager();
|
||||||
|
if (sm instanceof RegressionSecurityManager) {
|
||||||
|
resetAllSysProps = ((RegressionSecurityManager) sm).isPropertiesModified();
|
||||||
|
} else {
|
||||||
|
resetAllSysProps = true;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (resetAllSysProps) {
|
||||||
|
System.setProperties(newProperties(sysProps));
|
||||||
|
// System.err.println("reset properties");
|
||||||
|
} else {
|
||||||
|
System.setProperty("java.class.path", (String) sysProps.get("java.class.path"));
|
||||||
|
// System.err.println("no need to reset properties");
|
||||||
|
}
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
if (cleanupStatus == null) {
|
||||||
|
cleanupStatus = error(AGENTVM_CANT_RESET_PROPS + ": " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset output streams
|
||||||
|
AStatus stat = redirectOutput(stdOut, stdErr);
|
||||||
|
if (cleanupStatus == null && !stat.isPassed()) {
|
||||||
|
cleanupStatus = stat;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset locale
|
||||||
|
if (locale != Locale.getDefault()) {
|
||||||
|
Locale.setDefault(locale);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (cleanupStatus != null ? cleanupStatus : status);
|
||||||
|
}
|
||||||
|
|
||||||
|
final SecurityManager secMgr;
|
||||||
|
final PrintStream stdOut;
|
||||||
|
final PrintStream stdErr;
|
||||||
|
final Locale locale;
|
||||||
|
final Provider[] securityProviders;
|
||||||
|
static Map<?, ?> sysProps;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T> boolean equal(T[] a, T[] b) {
|
||||||
|
if (a == null || b == null) {
|
||||||
|
return a == b;
|
||||||
|
}
|
||||||
|
if (a.length != b.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < a.length; i++) {
|
||||||
|
if (a[i] != b[i]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------for saving/restoring properties---------------------------------
|
||||||
|
|
||||||
|
private static Map<?, ?> copyProperties(Properties p) {
|
||||||
|
Map<Object, Object> h = new HashMap<Object, Object>();
|
||||||
|
for (Enumeration<?> e = p.propertyNames(); e.hasMoreElements(); ) {
|
||||||
|
Object key = e.nextElement();
|
||||||
|
h.put(key, p.get(key));
|
||||||
|
}
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Properties newProperties(Map<?, ?> h) {
|
||||||
|
Properties p = new Properties();
|
||||||
|
p.putAll(h);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
// </editor-fold>
|
||||||
|
|
||||||
|
//----------output handler--------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OutputHandler provides an abstract way to get the streams used to record
|
||||||
|
* the output from an action of a test.
|
||||||
|
*/
|
||||||
|
public interface OutputHandler {
|
||||||
|
enum OutputKind {
|
||||||
|
LOG(""),
|
||||||
|
STDOUT("System.out"),
|
||||||
|
STDERR("System.err"),
|
||||||
|
DIRECT("direct"),
|
||||||
|
DIRECT_LOG("direct.log");
|
||||||
|
OutputKind(String name) { this.name = name; }
|
||||||
|
public final String name;
|
||||||
|
}
|
||||||
|
PrintStream getPrintStream(OutputKind kind, boolean autoFlush);
|
||||||
|
PrintWriter getPrintWriter(OutputKind kind, boolean autoFlush);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------in memory streams-----------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static class PrintStringWriter extends PrintWriter {
|
||||||
|
public PrintStringWriter() {
|
||||||
|
super(new StringWriter());
|
||||||
|
w = (StringWriter) out;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOutput() {
|
||||||
|
return w.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final StringWriter w;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------redirect streams------------------------------------------------
|
||||||
|
|
||||||
|
// if we wanted to allow more concurrency, we could try and acquire a lock here
|
||||||
|
protected static AStatus redirectOutput(PrintStream out, PrintStream err) {
|
||||||
|
synchronized (System.class) {
|
||||||
|
SecurityManager sc = System.getSecurityManager();
|
||||||
|
if (sc instanceof RegressionSecurityManager) {
|
||||||
|
boolean prev = ((RegressionSecurityManager) sc).setAllowSetIO(true);
|
||||||
|
System.setOut(out);
|
||||||
|
System.setErr(err);
|
||||||
|
((RegressionSecurityManager) sc).setAllowSetIO(prev);
|
||||||
|
} else {
|
||||||
|
//return Status.error(MAIN_SECMGR_BAD);
|
||||||
|
System.setOut(out);
|
||||||
|
System.setErr(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return passed("OK");
|
||||||
|
} // redirectOutput()
|
||||||
|
|
||||||
|
protected static final String
|
||||||
|
EXEC_ERROR_CLEANUP = "Error while cleaning up threads after test",
|
||||||
|
EXEC_PASS = "Execution successful",
|
||||||
|
|
||||||
|
UNEXPECT_SYS_EXIT = "Unexpected exit from test",
|
||||||
|
|
||||||
|
AGENTVM_CANT_RESET_SECMGR = "Cannot reset security manager",
|
||||||
|
AGENTVM_CANT_RESET_SECPROVS = "Cannot reset security providers",
|
||||||
|
AGENTVM_CANT_RESET_PROPS = "Cannot reset system properties";
|
||||||
|
}
|
|
@ -0,0 +1,508 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2021, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.regtest.agent;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.BufferedOutputStream;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.Socket;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.CharBuffer;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.CharsetDecoder;
|
||||||
|
import java.nio.charset.CoderResult;
|
||||||
|
import java.nio.charset.CodingErrorAction;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
|
||||||
|
public class AgentServer implements ActionHelper.OutputHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main program used to invoke and run the server in child JVMs
|
||||||
|
* @param args command-line arguments, used to configure the server
|
||||||
|
*/
|
||||||
|
public static void main(String... args) {
|
||||||
|
if (traceServer)
|
||||||
|
System.err.println("AgentServer.main");
|
||||||
|
|
||||||
|
try {
|
||||||
|
new AgentServer(args).run();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace(System.err);
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final boolean traceServer = Flags.get("traceServer");
|
||||||
|
|
||||||
|
public static final String ALLOW_SET_SECURITY_MANAGER = "-allowSetSecurityManager";
|
||||||
|
public static final String ID = "-id";
|
||||||
|
public static final String LOGFILE = "-logfile";
|
||||||
|
public static final String HOST = "-host";
|
||||||
|
public static final String PORT = "-port";
|
||||||
|
public static final String TIMEOUTFACTOR = "-timeoutFactor";
|
||||||
|
|
||||||
|
public static final byte DO_COMPILE = 1;
|
||||||
|
public static final byte DO_MAIN = 2;
|
||||||
|
public static final byte OUTPUT = 3;
|
||||||
|
public static final byte STATUS = 4;
|
||||||
|
public static final byte KEEPALIVE = 5;
|
||||||
|
public static final byte CLOSE = 6;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send KEEPALIVE bytes periodically to a stream.
|
||||||
|
* The bytes are written every {@code WRITE_TIMEOUT} milliseconds.
|
||||||
|
* The client reading the stream may use {@code READ_TIMEOUT} as a
|
||||||
|
* corresponding timeout to determine if the sending has stopped
|
||||||
|
* sending KEEPALIVE bytes.
|
||||||
|
*/
|
||||||
|
public static class KeepAlive {
|
||||||
|
public static final int WRITE_TIMEOUT = 60 * 1000; // 1 minute
|
||||||
|
public static final int READ_TIMEOUT = 2 * WRITE_TIMEOUT;
|
||||||
|
|
||||||
|
public KeepAlive(DataOutputStream out, boolean trace) {
|
||||||
|
this.out = out;
|
||||||
|
this.trace = trace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void setEnabled(boolean on) {
|
||||||
|
alarm.cancel();
|
||||||
|
if (on) {
|
||||||
|
alarm = Alarm.schedule(WRITE_TIMEOUT, TimeUnit.MILLISECONDS, null, ping);
|
||||||
|
} else {
|
||||||
|
alarm = Alarm.NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void finished() {
|
||||||
|
setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
final DataOutputStream out;
|
||||||
|
|
||||||
|
final Runnable ping = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
synchronized (out) {
|
||||||
|
if (trace)
|
||||||
|
traceOut.println("KeepAlive.ping");
|
||||||
|
out.writeByte(KEEPALIVE);
|
||||||
|
out.flush();
|
||||||
|
}
|
||||||
|
setEnabled(true);
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Alarm alarm = Alarm.NONE;
|
||||||
|
final PrintStream traceOut = System.err;
|
||||||
|
final boolean trace;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float timeoutFactor = 1.0f;
|
||||||
|
|
||||||
|
public AgentServer(String... args) throws IOException {
|
||||||
|
if (traceServer) {
|
||||||
|
traceOut.println("Agent.Server started");
|
||||||
|
}
|
||||||
|
boolean allowSetSecurityManagerFlag = false;
|
||||||
|
// use explicit localhost to avoid VPN issues
|
||||||
|
InetAddress host = InetAddress.getByName("localhost");
|
||||||
|
int id = 0;
|
||||||
|
int port = -1;
|
||||||
|
File logFile = null;
|
||||||
|
for (int i = 0; i < args.length; i++) {
|
||||||
|
String arg = args[i];
|
||||||
|
if (arg.equals(ID)) {
|
||||||
|
try {
|
||||||
|
id = Integer.parseInt(args[++i]);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
id = 0;
|
||||||
|
}
|
||||||
|
} else if (arg.equals(LOGFILE)) {
|
||||||
|
logFile = new File(args[++i]);
|
||||||
|
} else if (arg.equals(ALLOW_SET_SECURITY_MANAGER)) {
|
||||||
|
allowSetSecurityManagerFlag = true;
|
||||||
|
} else if (arg.equals(PORT) && i + 1 < args.length) {
|
||||||
|
port = Integer.valueOf(args[++i]);
|
||||||
|
} else if (arg.equals(HOST) && i + 1 < args.length) {
|
||||||
|
host = InetAddress.getByName(args[++i]);
|
||||||
|
} else if (arg.equals(TIMEOUTFACTOR) && i + 1 < args.length) {
|
||||||
|
timeoutFactor = Float.valueOf(args[++i]);
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException(arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.id = id;
|
||||||
|
|
||||||
|
PrintWriter pw = null;
|
||||||
|
if (logFile != null) {
|
||||||
|
try {
|
||||||
|
pw = new PrintWriter(new FileWriter(logFile));
|
||||||
|
} catch (IOException e) {
|
||||||
|
traceOut.println("Cannot open log writer: " + e);
|
||||||
|
pw = new PrintWriter(System.err) {
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
flush();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logWriter = pw;
|
||||||
|
log("Started");
|
||||||
|
|
||||||
|
if (port > 0) {
|
||||||
|
Socket s = new Socket(host, port);
|
||||||
|
s.setSoTimeout((int)(KeepAlive.READ_TIMEOUT * timeoutFactor));
|
||||||
|
in = new DataInputStream(new BufferedInputStream(s.getInputStream()));
|
||||||
|
out = new DataOutputStream(new BufferedOutputStream(s.getOutputStream()));
|
||||||
|
log("Listening on port " + port);
|
||||||
|
} else {
|
||||||
|
in = new DataInputStream(new BufferedInputStream(System.in));
|
||||||
|
out = new DataOutputStream(new BufferedOutputStream(System.out));
|
||||||
|
}
|
||||||
|
|
||||||
|
keepAlive = new KeepAlive(out, traceServer);
|
||||||
|
RegressionSecurityManager.install();
|
||||||
|
SecurityManager sm = System.getSecurityManager();
|
||||||
|
if (sm instanceof RegressionSecurityManager) {
|
||||||
|
RegressionSecurityManager rsm = (RegressionSecurityManager) sm;
|
||||||
|
rsm.setAllowPropertiesAccess(true);
|
||||||
|
if (allowSetSecurityManagerFlag) {
|
||||||
|
rsm.setAllowSetSecurityManager(true);
|
||||||
|
}
|
||||||
|
rsm.setAllowSetIO(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() throws IOException {
|
||||||
|
log("Running");
|
||||||
|
try {
|
||||||
|
int op;
|
||||||
|
while ((op = in.read()) != -1) {
|
||||||
|
switch (op) {
|
||||||
|
case DO_COMPILE:
|
||||||
|
doCompile();
|
||||||
|
break;
|
||||||
|
case DO_MAIN:
|
||||||
|
doMain();
|
||||||
|
break;
|
||||||
|
case KEEPALIVE:
|
||||||
|
break;
|
||||||
|
case CLOSE:
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
// Thread.dumpStack();
|
||||||
|
throw new Error("Agent.Server: unexpected op: " + op);
|
||||||
|
}
|
||||||
|
out.flush();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
keepAlive.finished();
|
||||||
|
log("Exiting");
|
||||||
|
logWriter.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doCompile() throws IOException {
|
||||||
|
if (traceServer) {
|
||||||
|
traceOut.println("Agent.Server.doCompile");
|
||||||
|
}
|
||||||
|
// See corresponding list in Agent.doCompile
|
||||||
|
String testName = in.readUTF();
|
||||||
|
Map<String, String> testProps = readMap(in);
|
||||||
|
List<String> cmdArgs = readList(in);
|
||||||
|
log(testName + ": starting compilation");
|
||||||
|
keepAlive.setEnabled(true);
|
||||||
|
try {
|
||||||
|
AStatus status = CompileActionHelper.runCompile(testName, testProps, cmdArgs, 0, this);
|
||||||
|
writeStatus(status);
|
||||||
|
} finally {
|
||||||
|
keepAlive.setEnabled(false);
|
||||||
|
log(testName + ": finished compilation");
|
||||||
|
}
|
||||||
|
if (traceServer) {
|
||||||
|
traceOut.println("Agent.Server.doCompile DONE");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doMain() throws IOException {
|
||||||
|
if (traceServer) {
|
||||||
|
traceOut.println("Agent.Server.doMain");
|
||||||
|
}
|
||||||
|
// See corresponding list in Agent.doMainAction
|
||||||
|
String testName = in.readUTF();
|
||||||
|
Map<String, String> testProps = readMap(in);
|
||||||
|
Set<String> addExports = readSet(in);
|
||||||
|
Set<String> addOpens = readSet(in);
|
||||||
|
Set<String> addMods = readSet(in);
|
||||||
|
SearchPath classPath = new SearchPath(in.readUTF());
|
||||||
|
SearchPath modulePath = new SearchPath(in.readUTF());
|
||||||
|
String className = in.readUTF();
|
||||||
|
List<String> classArgs = readList(in);
|
||||||
|
if (traceServer) {
|
||||||
|
traceOut.println("Agent.Server.doMain: " + testName);
|
||||||
|
}
|
||||||
|
log(testName + ": starting execution of " + className);
|
||||||
|
keepAlive.setEnabled(true);
|
||||||
|
try {
|
||||||
|
AStatus status = new MainActionHelper(testName)
|
||||||
|
.properties(testProps)
|
||||||
|
.addExports(addExports)
|
||||||
|
.addOpens(addOpens)
|
||||||
|
.addMods(addMods)
|
||||||
|
.classpath(classPath)
|
||||||
|
.modulepath(modulePath)
|
||||||
|
.className(className)
|
||||||
|
.classArgs(classArgs)
|
||||||
|
.timeout(0)
|
||||||
|
.timeoutFactor(timeoutFactor)
|
||||||
|
.outputHandler(this)
|
||||||
|
.runClass();
|
||||||
|
writeStatus(status);
|
||||||
|
} finally {
|
||||||
|
keepAlive.setEnabled(false);
|
||||||
|
log(testName + ": finished execution of " + className);
|
||||||
|
}
|
||||||
|
if (traceServer) {
|
||||||
|
traceOut.println("Agent.Server.doMain DONE");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static List<String> readList(DataInputStream in) throws IOException {
|
||||||
|
int n = in.readShort();
|
||||||
|
List<String> l = new ArrayList<String>(n);
|
||||||
|
for (int i = 0; i < n; i++)
|
||||||
|
l.add(in.readUTF());
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Set<String> readSet(DataInputStream in) throws IOException {
|
||||||
|
int n = in.readShort();
|
||||||
|
Set<String> s = new LinkedHashSet<String>(n);
|
||||||
|
for (int i = 0; i < n; i++)
|
||||||
|
s.add(in.readUTF());
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Map<String, String> readMap(DataInputStream in) throws IOException {
|
||||||
|
int n = in.readShort();
|
||||||
|
Map<String, String> p = new HashMap<String, String>(n, 1.0f);
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
String key = in.readUTF();
|
||||||
|
String value = in.readUTF();
|
||||||
|
p.put(key, value);
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeStatus(AStatus s) throws IOException {
|
||||||
|
if (traceServer) {
|
||||||
|
traceOut.println("Agent.Server.writeStatus: " + s);
|
||||||
|
}
|
||||||
|
synchronized (out) {
|
||||||
|
out.writeByte(STATUS);
|
||||||
|
out.writeByte(s.getType());
|
||||||
|
out.writeUTF(s.getReason());
|
||||||
|
}
|
||||||
|
writers.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// This format is also used by Agent.java in the client-side log messages.
|
||||||
|
// The format is like this:
|
||||||
|
// 2016-12-21 13:19:46,998
|
||||||
|
// It is "sort-friendly" so that the lines in all the logs for a test run
|
||||||
|
// can be merged and sorted into a single log.
|
||||||
|
public static final SimpleDateFormat logDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS");
|
||||||
|
|
||||||
|
void log(String message) {
|
||||||
|
logWriter.printf("[%s] AgentServer[%d]: %s%n",
|
||||||
|
AgentServer.logDateFormat.format(new Date()),
|
||||||
|
id,
|
||||||
|
message);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private final KeepAlive keepAlive;
|
||||||
|
private final DataInputStream in;
|
||||||
|
private final DataOutputStream out;
|
||||||
|
private final PrintStream traceOut = System.err;
|
||||||
|
private final PrintWriter logWriter;
|
||||||
|
private final int id;
|
||||||
|
private final Map<OutputKind, Writer> writers = new EnumMap<OutputKind, Writer>(OutputKind.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an output stream for output to be sent back to the client via the server connection.
|
||||||
|
* @param kind the kind of stream
|
||||||
|
* @return the output stream
|
||||||
|
*/
|
||||||
|
public PrintWriter getPrintWriter(OutputKind kind, boolean autoFlush) {
|
||||||
|
return new PrintWriter(getWriter(kind), autoFlush);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Writer getWriter(final OutputKind kind) {
|
||||||
|
Writer w = writers.get(kind);
|
||||||
|
if (w == null) {
|
||||||
|
w = new Writer() {
|
||||||
|
@Override
|
||||||
|
public void write(char[] cbuf, int off, int len) throws IOException {
|
||||||
|
if (traceServer) {
|
||||||
|
traceOut.println("Agent.Server.write[" + kind + ",writer] " + new String(cbuf, off, len));
|
||||||
|
}
|
||||||
|
final int BLOCKSIZE = 4096;
|
||||||
|
while (len > 0) {
|
||||||
|
int n = len > BLOCKSIZE ? BLOCKSIZE : len;
|
||||||
|
synchronized (out) {
|
||||||
|
out.writeByte(OUTPUT);
|
||||||
|
out.writeUTF(kind.name);
|
||||||
|
out.writeUTF(new String(cbuf, off, n));
|
||||||
|
}
|
||||||
|
off += n;
|
||||||
|
len -= n;
|
||||||
|
}
|
||||||
|
if (traceServer) {
|
||||||
|
traceOut.println("Agent.Server.write[" + kind + ",writer]--done");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void flush() throws IOException {
|
||||||
|
out.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
out.flush();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
writers.put(kind, w);
|
||||||
|
}
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an output stream for output to be sent back to the client via the server connection,
|
||||||
|
* and use it to write the given content.
|
||||||
|
* @param kind the kind of stream
|
||||||
|
* @param autoFlush whether or not to flush the stream on '\n'
|
||||||
|
*/
|
||||||
|
public PrintStream getPrintStream(OutputKind kind, boolean autoFlush) {
|
||||||
|
return new PrintStream(getOutputStream(kind), autoFlush);
|
||||||
|
}
|
||||||
|
|
||||||
|
private OutputStream getOutputStream(final OutputKind kind) {
|
||||||
|
final Writer w = getWriter(kind);
|
||||||
|
return new OutputStream() {
|
||||||
|
private static final int BUFSIZE = 1024;
|
||||||
|
private ByteBuffer byteBuffer = ByteBuffer.allocate(BUFSIZE);
|
||||||
|
private CharBuffer charBuffer = CharBuffer.allocate(BUFSIZE);
|
||||||
|
private CharsetDecoder decoder = Charset.forName(
|
||||||
|
System.getProperty("sun.stdout.encoding", System.getProperty("sun.jnu.encoding",
|
||||||
|
Charset.defaultCharset().name())))
|
||||||
|
.newDecoder()
|
||||||
|
.onMalformedInput(CodingErrorAction.REPLACE)
|
||||||
|
.onUnmappableCharacter(CodingErrorAction.REPLACE);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(byte[] bytes, int off, int len) throws IOException {
|
||||||
|
if (traceServer) {
|
||||||
|
traceOut.println("Agent.Server.write[" + kind + ",stream] " + new String(bytes, off, len));
|
||||||
|
}
|
||||||
|
int n;
|
||||||
|
while (len > 0 && len >= (n = byteBuffer.remaining())) {
|
||||||
|
byteBuffer.put(bytes, off, n);
|
||||||
|
decode();
|
||||||
|
off += n;
|
||||||
|
len -= n;
|
||||||
|
}
|
||||||
|
byteBuffer.put(bytes, off, len);
|
||||||
|
if (traceServer) {
|
||||||
|
traceOut.println("Agent.Server.write[" + kind + ",stream]--done");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(int b) throws IOException {
|
||||||
|
byteBuffer.put((byte) b);
|
||||||
|
if (!byteBuffer.hasRemaining()) {
|
||||||
|
decode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void flush() throws IOException {
|
||||||
|
decode();
|
||||||
|
w.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
decode();
|
||||||
|
byteBuffer.flip();
|
||||||
|
decoder.decode(byteBuffer, charBuffer, true);
|
||||||
|
writeCharBuffer();
|
||||||
|
w.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void decode() throws IOException {
|
||||||
|
byteBuffer.flip();
|
||||||
|
CoderResult cr;
|
||||||
|
while ((cr = decoder.decode(byteBuffer, charBuffer, false)) != CoderResult.UNDERFLOW) {
|
||||||
|
writeCharBuffer();
|
||||||
|
}
|
||||||
|
byteBuffer.compact();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeCharBuffer() throws IOException {
|
||||||
|
charBuffer.flip();
|
||||||
|
w.write(charBuffer.toString());
|
||||||
|
charBuffer.clear();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,229 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2017, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.regtest.agent;
|
||||||
|
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||||
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a lightweight way of setting up and canceling timeouts.
|
||||||
|
*/
|
||||||
|
public class Alarm {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schedule an Alarm to periodically interrupt() a specified thread.
|
||||||
|
* The first interrupt() will happen after the time specified by {@code delay}
|
||||||
|
* and {@code delayUnit}. Thereafter the thread will be interrupted every 100ms
|
||||||
|
* until the Alarm is canceled.
|
||||||
|
* @param delay run the first interrupt after this time
|
||||||
|
* @param unit TimeUnit for {@code delay}
|
||||||
|
* @param msgOut PrintWriter for logging
|
||||||
|
* @param threadToInterrupt The thread to call interrupt() on
|
||||||
|
* @return a new Alarm instance
|
||||||
|
*/
|
||||||
|
public static Alarm schedulePeriodicInterrupt(long delay,
|
||||||
|
TimeUnit unit,
|
||||||
|
PrintWriter msgOut,
|
||||||
|
final Thread threadToInterrupt) {
|
||||||
|
Interruptor runner = new Interruptor(delay, unit, msgOut, threadToInterrupt);
|
||||||
|
runner.future = executor
|
||||||
|
.scheduleWithFixedDelay(runner,
|
||||||
|
TimeUnit.MILLISECONDS.convert(delay, unit),
|
||||||
|
100,
|
||||||
|
TimeUnit.MILLISECONDS);
|
||||||
|
return runner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schedule an Alarm to interrupt() a specified thread.
|
||||||
|
* The interrupt() will happen after the time specified by {@code delay}
|
||||||
|
* and {@code delayUnit}.
|
||||||
|
* @param delay run the interrupt after this time
|
||||||
|
* @param unit TimeUnit for {@code delay}
|
||||||
|
* @param msgOut PrintWriter for logging
|
||||||
|
* @param threadToInterrupt The thread to call interrupt() on
|
||||||
|
* @return a new Alarm instance
|
||||||
|
*/
|
||||||
|
public static Alarm scheduleInterrupt(long delay,
|
||||||
|
TimeUnit unit,
|
||||||
|
PrintWriter msgOut,
|
||||||
|
final Thread threadToInterrupt) {
|
||||||
|
Interruptor runner = new Interruptor(delay, unit, msgOut, threadToInterrupt);
|
||||||
|
runner.future = executor.schedule(runner, delay, unit);
|
||||||
|
return runner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schedule an Alarm to run the specified Runnable.
|
||||||
|
* The Runnable will be run after the time specified by {@code delay}
|
||||||
|
* and {@code delayUnit}.
|
||||||
|
*
|
||||||
|
* Note: Because Alarms are serviced by just a single thread, Alarm actions must
|
||||||
|
* be quick so that other Alarms are not blocked from running as scheduled.
|
||||||
|
*
|
||||||
|
* @param delay run after this time
|
||||||
|
* @param unit TimeUnit for {@code delay}
|
||||||
|
* @param msgOut PrintWriter for logging
|
||||||
|
* @param r the Runnable
|
||||||
|
* @return a new Alarm instance
|
||||||
|
*/
|
||||||
|
public static Alarm schedule(long delay,
|
||||||
|
TimeUnit unit,
|
||||||
|
PrintWriter msgOut,
|
||||||
|
Runnable r) {
|
||||||
|
RunnableAlarm runner = new RunnableAlarm(delay, unit, msgOut, r);
|
||||||
|
runner.future = executor.schedule(runner, delay, unit);
|
||||||
|
return runner;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected volatile boolean fired;
|
||||||
|
protected ScheduledFuture<?> future;
|
||||||
|
protected int count;
|
||||||
|
protected final long delay;
|
||||||
|
protected final TimeUnit delayUnit;
|
||||||
|
protected final PrintWriter msgOut;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal constructor.
|
||||||
|
* @param delay run the interrupt after this time
|
||||||
|
* @param delayUnit TimeUnit for {@code delay}
|
||||||
|
* @param msgOut PrintWriter for logging
|
||||||
|
*/
|
||||||
|
protected Alarm(long delay, TimeUnit delayUnit, PrintWriter msgOut) {
|
||||||
|
this.delay = delay;
|
||||||
|
this.delayUnit = delayUnit;
|
||||||
|
this.msgOut = msgOut;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel the Alarm.
|
||||||
|
*/
|
||||||
|
public void cancel() {
|
||||||
|
future.cancel(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the Alarm has fired at least once.
|
||||||
|
* @return true if the alarm has fired, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean didFire() {
|
||||||
|
return fired;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shared logic for all Alarms
|
||||||
|
*/
|
||||||
|
protected void run() {
|
||||||
|
if (msgOut != null) {
|
||||||
|
if (count == 0) {
|
||||||
|
msgOut.println(String.format("Timeout refired %s times", TimeUnit.SECONDS.convert(delay, delayUnit)));
|
||||||
|
} else if (count % 100 == 0) {
|
||||||
|
msgOut.println(String.format("Timeout signalled after %d seconds", count));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
fired = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper class to implement the Thread.interrupt() calls.
|
||||||
|
*/
|
||||||
|
private static class Interruptor extends Alarm implements Runnable {
|
||||||
|
Thread threadToInterrupt;
|
||||||
|
|
||||||
|
public Interruptor(long delay, TimeUnit unit, PrintWriter msgOut, Thread t) {
|
||||||
|
super(delay, unit, msgOut);
|
||||||
|
threadToInterrupt = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
super.run();
|
||||||
|
threadToInterrupt.interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper class to run a Runnable.
|
||||||
|
*/
|
||||||
|
private static class RunnableAlarm extends Alarm implements Runnable {
|
||||||
|
Runnable r;
|
||||||
|
|
||||||
|
public RunnableAlarm(long delay, TimeUnit unit, PrintWriter msgOut, Runnable r) {
|
||||||
|
super(delay, unit, msgOut);
|
||||||
|
this.r = r;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
super.run();
|
||||||
|
r.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An Alarm instance that can be used to initialize an Alarm variable.
|
||||||
|
* This instance of Alarm will never fire.
|
||||||
|
*/
|
||||||
|
public static final Alarm NONE = new NoAlarm(0, TimeUnit.MILLISECONDS, null);
|
||||||
|
|
||||||
|
private static class NoAlarm extends Alarm {
|
||||||
|
protected NoAlarm(long delay, TimeUnit delayUnit, PrintWriter msgOut) {
|
||||||
|
super(delay, delayUnit, msgOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancel() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean didFire() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Our own ThreadFactory to make the thread in the pool be a daemon threads.
|
||||||
|
*/
|
||||||
|
private static class DaemonThreadFactory implements ThreadFactory {
|
||||||
|
|
||||||
|
ThreadFactory defaultFactory = Executors.defaultThreadFactory();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Thread newThread(Runnable r) {
|
||||||
|
Thread thread = defaultFactory.newThread(r);
|
||||||
|
thread.setDaemon(true);
|
||||||
|
return thread;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final ScheduledThreadPoolExecutor executor =
|
||||||
|
new ScheduledThreadPoolExecutor(1, new DaemonThreadFactory());
|
||||||
|
}
|
|
@ -0,0 +1,686 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998, 2017, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.regtest.agent;
|
||||||
|
|
||||||
|
import java.applet.Applet;
|
||||||
|
import java.applet.AppletContext;
|
||||||
|
import java.applet.AppletStub;
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Button;
|
||||||
|
import java.awt.Checkbox;
|
||||||
|
import java.awt.CheckboxGroup;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.EventQueue;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Frame;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.Label;
|
||||||
|
import java.awt.Panel;
|
||||||
|
import java.awt.TextArea;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ItemEvent;
|
||||||
|
import java.awt.event.ItemListener;
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Dictionary;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is the wrapper for all applet tests.
|
||||||
|
*
|
||||||
|
* @author Iris A Garcia
|
||||||
|
*/
|
||||||
|
public class AppletWrapper
|
||||||
|
{
|
||||||
|
public static void main(String [] args) {
|
||||||
|
String [] appArgs;
|
||||||
|
try {
|
||||||
|
FileReader in = new FileReader(args[0]);
|
||||||
|
|
||||||
|
StringWriter out = new StringWriter();
|
||||||
|
char [] buf = new char[1024];
|
||||||
|
int howMany;
|
||||||
|
|
||||||
|
while ((howMany = in.read(buf)) > 0)
|
||||||
|
out.write(buf, 0, howMany);
|
||||||
|
out.close();
|
||||||
|
in.close();
|
||||||
|
appArgs = StringArray.splitTerminator("\0", out.toString());
|
||||||
|
|
||||||
|
// order determined by the associated write in
|
||||||
|
// AppletAction.runOtherJVM()
|
||||||
|
int i = 0;
|
||||||
|
className = appArgs[i++];
|
||||||
|
sourceDir = appArgs[i++];
|
||||||
|
classDir = appArgs[i++];
|
||||||
|
classpath = appArgs[i++];
|
||||||
|
manual = appArgs[i++];
|
||||||
|
body = appArgs[i++];
|
||||||
|
appletParams = stringToDictionary(appArgs[i++]);
|
||||||
|
appletAtts = stringToDictionary(appArgs[i++]);
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
status = AStatus.failed("JavaTest Error: Can't read applet args file.");
|
||||||
|
status.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
AppletThreadGroup tg = new AppletThreadGroup();
|
||||||
|
Thread t = new Thread(tg, new AppletRunnable(), "AppletThread");
|
||||||
|
t.start();
|
||||||
|
try {
|
||||||
|
t.join();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
status = AStatus.failed("Thread interrupted: " + t.toString());
|
||||||
|
status.exit();
|
||||||
|
}
|
||||||
|
// never get here because t.run() always calls Status.exit() in the
|
||||||
|
// non-interrupted case
|
||||||
|
} // main()
|
||||||
|
|
||||||
|
private static Dictionary stringToDictionary(String s) {
|
||||||
|
String[] pairs = StringArray.splitTerminator("\034", s);
|
||||||
|
Dictionary retVal = new Hashtable(3);
|
||||||
|
for (int i = 0; i < pairs.length; i+=2)
|
||||||
|
retVal.put(pairs[i], pairs[i+1]);
|
||||||
|
return retVal;
|
||||||
|
} // stringToDictionary()
|
||||||
|
|
||||||
|
// // For printing debug messages
|
||||||
|
// private static void Msg(String s) {
|
||||||
|
// System.out.println(Thread.currentThread().getName() + ": " + s);
|
||||||
|
// System.out.println(Thread.currentThread().getThreadGroup());
|
||||||
|
// } // Msg()
|
||||||
|
|
||||||
|
static class AppletRunnable implements Runnable
|
||||||
|
{
|
||||||
|
public void run() {
|
||||||
|
waiter = new AppletWaiter();
|
||||||
|
|
||||||
|
int width = Integer.parseInt((String) appletAtts.get("width"));
|
||||||
|
int height = Integer.parseInt((String) appletAtts.get("height"));
|
||||||
|
AppletFrame app = new AppletFrame(className, body, manual, width, height);
|
||||||
|
Applet applet = app.getApplet();
|
||||||
|
AppletStubImpl stub = new AppletStubImpl();
|
||||||
|
applet.setStub(stub);
|
||||||
|
|
||||||
|
// center the frame
|
||||||
|
app.pack();
|
||||||
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
|
Dimension fSize = app.getSize();
|
||||||
|
app.setLocation(screenSize.width/2 - fSize.width/2,
|
||||||
|
screenSize.height/2 - fSize.height/2);
|
||||||
|
|
||||||
|
// We want to show the frame which contains the running applet as
|
||||||
|
// soon as possible. If the tests runs a dialog in the init() or
|
||||||
|
// start() that would end up blocking, our frame will still be
|
||||||
|
// shown.
|
||||||
|
app.setVisible(true);
|
||||||
|
|
||||||
|
applet.init();
|
||||||
|
validate(applet);
|
||||||
|
stub.isActive = true;
|
||||||
|
applet.start();
|
||||||
|
|
||||||
|
app.setVisible(true);
|
||||||
|
validate(app);
|
||||||
|
|
||||||
|
if (manual.equals("novalue") || manual.equals("unset")) {
|
||||||
|
// short pause for vaguely automated stuff, per the spec
|
||||||
|
// which requires a delay of "a few seconds" at this point
|
||||||
|
try {
|
||||||
|
Thread.sleep(2000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
status = AStatus.failed("Thread interrupted: " + e.toString());
|
||||||
|
status.exit();
|
||||||
|
}
|
||||||
|
// just in case the system is slow, ensure paint is called
|
||||||
|
applet.paint(app.getApplet().getGraphics());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// wait for user to click on "Pass", "Fail", or "Done"
|
||||||
|
waiter.waitForDone();
|
||||||
|
}
|
||||||
|
|
||||||
|
stub.isActive = false;
|
||||||
|
applet.stop();
|
||||||
|
applet.destroy();
|
||||||
|
|
||||||
|
app.dispose();
|
||||||
|
|
||||||
|
//Toolkit.getDefaultToolkit().beep();
|
||||||
|
status.exit();
|
||||||
|
} // run()
|
||||||
|
|
||||||
|
private void validate(final Component c) {
|
||||||
|
try {
|
||||||
|
Class eventQueueClass = EventQueue.class;
|
||||||
|
Method isDispatchThread = eventQueueClass.getMethod("isDispatchThread", new Class[] {});
|
||||||
|
Method invokeAndWait = eventQueueClass.getMethod("invokeAndWait", new Class[] { Runnable.class });
|
||||||
|
if (!((Boolean) (isDispatchThread.invoke(null, new Object[] { }))).booleanValue()) {
|
||||||
|
invokeAndWait.invoke(null, new Object[] { new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
c.validate();
|
||||||
|
}
|
||||||
|
}});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (NoSuchMethodException e) {
|
||||||
|
// must be JDK 1.1 -- fallthrough
|
||||||
|
}
|
||||||
|
catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
}
|
||||||
|
c.validate();
|
||||||
|
|
||||||
|
}
|
||||||
|
} // class AppletRunnable
|
||||||
|
|
||||||
|
static class AppletStubImpl implements AppletStub {
|
||||||
|
boolean isActive;
|
||||||
|
|
||||||
|
public boolean isActive() {
|
||||||
|
return isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public URL getDocumentBase() {
|
||||||
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public URL getCodeBase() {
|
||||||
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParameter(String name) {
|
||||||
|
return (String) appletParams.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AppletContext getAppletContext() {
|
||||||
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void appletResize(int width, int height) {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The actual applet being tested is run in its own thread group.
|
||||||
|
* We need to do this so that we can implement
|
||||||
|
* ThreadGroup.uncaughtException() so that we may catch all exceptions from
|
||||||
|
* the test (including those from subsidiary threads).
|
||||||
|
*/
|
||||||
|
static class AppletThreadGroup extends ThreadGroup
|
||||||
|
{
|
||||||
|
AppletThreadGroup() {
|
||||||
|
super("AppletThreadGroup");
|
||||||
|
} // AppletThreadGroup()
|
||||||
|
|
||||||
|
public void uncaughtException(Thread t, Throwable e) {
|
||||||
|
// !!!! major simplification - only works for otherJVM
|
||||||
|
// don't have to worry about whether the exception occurred due to
|
||||||
|
// our own cleanup since we always exit at the first exception
|
||||||
|
if (e instanceof ThreadDeath)
|
||||||
|
return;
|
||||||
|
e.printStackTrace();
|
||||||
|
status = AStatus.failed("Applet thread threw exception: " + e.toString());
|
||||||
|
status.exit();
|
||||||
|
} // uncaughtException()
|
||||||
|
|
||||||
|
} // class AppletThreadGroup
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A GUI object that contains the applet under test and any other GUI
|
||||||
|
* elements as specified by the JDK Test Framework.
|
||||||
|
*/
|
||||||
|
static class AppletFrame extends Frame implements ActionListener
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the AppletFrame frame which contains the running applet and
|
||||||
|
* any instructions, buttons, etc.
|
||||||
|
*
|
||||||
|
* @param className The name of the applet class which must extend
|
||||||
|
* java.awt.Applet.
|
||||||
|
* @param text A string containing the test instructions from the body
|
||||||
|
* of the HTML file.
|
||||||
|
* @param manual From the provided test description, an indicator of the
|
||||||
|
* type of the test ("novalue", "unset", "yesno", or "done").
|
||||||
|
* @param width The width obtained from the HTML applet tag's "width"
|
||||||
|
* attribute. The initial width of the applet.
|
||||||
|
* @param height The height obtained from the HTML applet tag's "height"
|
||||||
|
* attribute. The initial height of the applet.
|
||||||
|
*/
|
||||||
|
public AppletFrame(String className, String text, String manual, int width, int height) {
|
||||||
|
super(className);
|
||||||
|
|
||||||
|
GridBagLayout gridbag = new GridBagLayout();
|
||||||
|
setLayout(gridbag);
|
||||||
|
|
||||||
|
{ // "runnning applet:" label
|
||||||
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
|
c.anchor = GridBagConstraints.WEST;
|
||||||
|
c.gridx = 0;
|
||||||
|
c.gridy = 0;
|
||||||
|
c.gridwidth = 2;
|
||||||
|
c.weightx = 0.0;
|
||||||
|
makeLabel("running applet:", gridbag, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
{ // the applet
|
||||||
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
|
c.insets = new Insets(3, 3, 3, 3);
|
||||||
|
c.gridx = 0;
|
||||||
|
c.gridy = 1;
|
||||||
|
c.gridwidth = 2;
|
||||||
|
c.fill = GridBagConstraints.BOTH;
|
||||||
|
c.weightx = 1.0;
|
||||||
|
c.weighty = 1.0;
|
||||||
|
makeApplet(className, gridbag, c, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
// consider adding this anonymous class to makeApplet() or just
|
||||||
|
// moving it down to after the layout stuff
|
||||||
|
addWindowListener(new WindowAdapter() {
|
||||||
|
public void windowClosing(WindowEvent event) {
|
||||||
|
dispose();
|
||||||
|
status = AStatus.failed("Test canceled at user request");
|
||||||
|
status.exit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (! manual.equals("novalue") && ! manual.equals("unset")) {
|
||||||
|
{ // "applet size:" label and CheckBoxGroup
|
||||||
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
|
c.insets = new Insets(-3, -3, -3, -3);
|
||||||
|
c.gridx = 0;
|
||||||
|
c.gridy = 2;
|
||||||
|
c.gridwidth = 1;
|
||||||
|
c.weightx = 0.0;
|
||||||
|
c.anchor = GridBagConstraints.WEST;
|
||||||
|
String [] boxNames = {"fixed", "variable"};
|
||||||
|
makeCheckboxPanel(boxNames, gridbag, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// TAG-SPEC: If /manual is specified, the the HTML file itself will be
|
||||||
|
/// displayed.
|
||||||
|
{ // "html file instructions:" label
|
||||||
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
|
c.anchor = GridBagConstraints.WEST;
|
||||||
|
c.gridx = 0;
|
||||||
|
c.gridy = 3;
|
||||||
|
c.gridwidth = 2;
|
||||||
|
makeLabel("html file instructions:", gridbag, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
{ // The body of the html file.
|
||||||
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
|
c.insets = new Insets(3, 3, 3, 3);
|
||||||
|
c.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
c.gridx = 0;
|
||||||
|
c.gridy = 4;
|
||||||
|
c.gridwidth = 2;
|
||||||
|
makeTextArea(text, gridbag, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
{ // The buttons.
|
||||||
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
|
c.insets = new Insets(3, 3, 3, 3);
|
||||||
|
c.gridx = 0;
|
||||||
|
c.gridy = 5;
|
||||||
|
if (manual.equals("yesno")) {
|
||||||
|
c.gridwidth = 1;
|
||||||
|
makeButton("Pass", gridbag, c);
|
||||||
|
c.gridx = 1;
|
||||||
|
makeButton("Fail", gridbag, c);
|
||||||
|
} else {
|
||||||
|
c.gridwidth = 2;
|
||||||
|
makeButton("Done", gridbag, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now that we've figured out what we want to display, let the
|
||||||
|
// layout manager figure out how it wants to display it.
|
||||||
|
validate();
|
||||||
|
} // AppletFrame()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is an event handler for our button events.
|
||||||
|
*
|
||||||
|
* @param e The button event.
|
||||||
|
*/
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (e.getActionCommand().equals("Done")) {
|
||||||
|
status = AStatus.passed("");
|
||||||
|
} else if (e.getActionCommand().equals("Pass")) {
|
||||||
|
status = AStatus.passed("");
|
||||||
|
} else if (e.getActionCommand().equals("Fail")) {
|
||||||
|
status = AStatus.failed("");
|
||||||
|
} else {
|
||||||
|
status = AStatus.failed("Unexpected result");
|
||||||
|
}
|
||||||
|
// time to go home
|
||||||
|
waiter.done();
|
||||||
|
} // actionPerformed()
|
||||||
|
|
||||||
|
//----------accessor methods--------------------------------------------
|
||||||
|
|
||||||
|
public Applet getApplet() {
|
||||||
|
return applet;
|
||||||
|
} // getApplet()
|
||||||
|
|
||||||
|
//----------internal methods--------------------------------------------
|
||||||
|
|
||||||
|
private void makeApplet(String className, GridBagLayout gridbag, GridBagConstraints c,
|
||||||
|
int width, int height) {
|
||||||
|
try {
|
||||||
|
Class cls = Class.forName(className);
|
||||||
|
applet = (Applet) cls.newInstance();
|
||||||
|
} catch (InstantiationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
status = AStatus.error("Unable to instantiate: " + className +
|
||||||
|
" does not extend Applet");
|
||||||
|
status.exit();
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
status = AStatus.error("Illegal access to test: " + className);
|
||||||
|
status.exit();
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
//status = Status.error("JavaTest Error: Class not found: " +
|
||||||
|
// className);
|
||||||
|
status = AStatus.error(e.getMessage());
|
||||||
|
status.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// create the panel where the test applet will reside
|
||||||
|
appletPanel = new AppletPanel(applet, width, height);
|
||||||
|
gridbag.setConstraints(appletPanel, c);
|
||||||
|
add(appletPanel, c);
|
||||||
|
} // makeApplet()
|
||||||
|
|
||||||
|
private void makeButton(String name, GridBagLayout gridbag, GridBagConstraints c) {
|
||||||
|
Button button = new Button(name);
|
||||||
|
gridbag.setConstraints(button, c);
|
||||||
|
add(button);
|
||||||
|
// add a listener to receive events from the button
|
||||||
|
button.addActionListener(this);
|
||||||
|
} // makeButton()
|
||||||
|
|
||||||
|
private void makeLabel(String name, GridBagLayout gridbag, GridBagConstraints c) {
|
||||||
|
Label label = new Label(name);
|
||||||
|
label.setFont(new Font("Dialog", Font.BOLD, 12));
|
||||||
|
gridbag.setConstraints(label, c);
|
||||||
|
add(label);
|
||||||
|
} // makeLabel()
|
||||||
|
|
||||||
|
private void makeTextArea(String name, GridBagLayout gridbag, GridBagConstraints c) {
|
||||||
|
TextArea textArea = new TextArea(name, 16, 80);
|
||||||
|
gridbag.setConstraints(textArea, c);
|
||||||
|
textArea.setEditable(false);
|
||||||
|
add(textArea);
|
||||||
|
} // makeTextArea()
|
||||||
|
|
||||||
|
private void makeCheckboxPanel(String [] name, GridBagLayout gridbag, GridBagConstraints c) {
|
||||||
|
CheckboxPanel p = new CheckboxPanel(appletPanel, name);
|
||||||
|
gridbag.setConstraints(p, c);
|
||||||
|
add(p);
|
||||||
|
} // makeCheckboxPanel
|
||||||
|
|
||||||
|
//----------member variables--------------------------------------------
|
||||||
|
|
||||||
|
private Applet applet;
|
||||||
|
} // class AppletFrame
|
||||||
|
|
||||||
|
//----------member variables-----------------------------------------------
|
||||||
|
|
||||||
|
private static AStatus status = AStatus.passed("");
|
||||||
|
|
||||||
|
private static AppletWaiter waiter;
|
||||||
|
private static AppletPanel appletPanel;
|
||||||
|
|
||||||
|
private static String className;
|
||||||
|
private static String sourceDir;
|
||||||
|
private static String classDir;
|
||||||
|
private static String classpath;
|
||||||
|
private static String manual;
|
||||||
|
private static String body;
|
||||||
|
private static Dictionary appletParams;
|
||||||
|
private static Dictionary appletAtts;
|
||||||
|
} // class AppletWrapper
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the panel which contains the checkboxes which control the behaviour
|
||||||
|
* of the AppletPanel as resize events are sent to the AppletFrame frame.
|
||||||
|
*/
|
||||||
|
class CheckboxPanel extends Panel
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public CheckboxPanel(AppletPanel appletPanel, String [] boxNames) {
|
||||||
|
panel = appletPanel;
|
||||||
|
|
||||||
|
CheckboxGroup group = new CheckboxGroup();
|
||||||
|
b1 = new Checkbox(boxNames[0], true, group);
|
||||||
|
b2 = new Checkbox(boxNames[1], false, group);
|
||||||
|
|
||||||
|
Label label = new Label("applet size:");
|
||||||
|
label.setFont(new Font("Dialog", Font.BOLD, 12));
|
||||||
|
add(label);
|
||||||
|
|
||||||
|
add(b1);
|
||||||
|
add(b2);
|
||||||
|
|
||||||
|
b1.addItemListener(new ItemListener() {
|
||||||
|
public void itemStateChanged(ItemEvent event) {
|
||||||
|
panel.setFixedSize();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
b2.addItemListener(new ItemListener() {
|
||||||
|
public void itemStateChanged(ItemEvent event) {
|
||||||
|
panel.setVariableSize();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} // makeCheckBoxGroup()
|
||||||
|
|
||||||
|
private Checkbox b1, b2;
|
||||||
|
private AppletPanel panel;
|
||||||
|
|
||||||
|
} // class CheckboxPanel
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the panel which contains the test applet.
|
||||||
|
*/
|
||||||
|
class AppletPanel extends Panel
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
AppletPanel(Applet applet, int width, int height) {
|
||||||
|
layout = new GridBagLayout();
|
||||||
|
setLayout(layout);
|
||||||
|
|
||||||
|
int inc = 2 * borderWidth;
|
||||||
|
pSize = new Dimension(width + inc, height + inc);
|
||||||
|
mSize = new Dimension(width + inc, height + inc);
|
||||||
|
outerAppletPanel = this;
|
||||||
|
nestedAppletPanel = new NestedAppletPanel(applet);
|
||||||
|
setFixedSize();
|
||||||
|
this.applet = applet;
|
||||||
|
add(nestedAppletPanel);
|
||||||
|
} // AppletPanel()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method called if the "fixed" checkbox has been selected. The size of the
|
||||||
|
* applet will remain fixed regardless of resize events to the AppletFrame
|
||||||
|
* frame.
|
||||||
|
*/
|
||||||
|
public void setFixedSize() {
|
||||||
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
|
c.fill = GridBagConstraints.NONE;
|
||||||
|
c.weightx = 0.0;
|
||||||
|
c.weighty = 0.0;
|
||||||
|
|
||||||
|
// trick: To cause a GUI component resize to take effect immediately,
|
||||||
|
// remove it, change its constraints, then add it back.
|
||||||
|
remove(nestedAppletPanel);
|
||||||
|
layout.setConstraints(nestedAppletPanel, c);
|
||||||
|
add(nestedAppletPanel);
|
||||||
|
// may not be necessary since we should get auto validation on add
|
||||||
|
validate();
|
||||||
|
} // setFixedSize()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method called if the "variable" checkbox has been selected. The applet
|
||||||
|
* will expand to fill the available space. Resizing the frame will resize
|
||||||
|
* the applet.
|
||||||
|
*/
|
||||||
|
public void setVariableSize() {
|
||||||
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
|
c.fill = GridBagConstraints.BOTH;
|
||||||
|
c.weightx = 1.0;
|
||||||
|
c.weighty = 1.0;
|
||||||
|
|
||||||
|
// trick: To cause a GUI component resize to take effect immediately,
|
||||||
|
// remove it, change its constraints, then add it back.
|
||||||
|
remove(nestedAppletPanel);
|
||||||
|
layout.setConstraints(nestedAppletPanel, c);
|
||||||
|
add(nestedAppletPanel);
|
||||||
|
// may not be necessary since we should get auto validation on add
|
||||||
|
validate();
|
||||||
|
} // setVariableSize()
|
||||||
|
|
||||||
|
//----------layout manager callbacks----------------------------------------
|
||||||
|
|
||||||
|
public Dimension getMinimumSize() {
|
||||||
|
return mSize;
|
||||||
|
} // getMinimumSize()
|
||||||
|
|
||||||
|
public Dimension getPreferredSize() {
|
||||||
|
return pSize;
|
||||||
|
} // getPreferredSize()
|
||||||
|
|
||||||
|
public void setSize(int width, int height) {
|
||||||
|
if (initialSize == null)
|
||||||
|
initialSize = getSize();
|
||||||
|
else if (initialSize != getSize()) {
|
||||||
|
pSize = mSize = getSize();
|
||||||
|
getParent().invalidate();
|
||||||
|
getParent().validate();
|
||||||
|
}
|
||||||
|
} // setSize()
|
||||||
|
|
||||||
|
public Insets getInsets() {
|
||||||
|
return new Insets(0, 0, 0, 0);
|
||||||
|
} // getInsets()
|
||||||
|
|
||||||
|
//----------internal classes------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class used to manage the geometry of the test applet and to draw a box
|
||||||
|
* around the space available for the applet.
|
||||||
|
*/
|
||||||
|
class NestedAppletPanel extends Panel
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
NestedAppletPanel(Applet applet) {
|
||||||
|
setLayout(new BorderLayout());
|
||||||
|
add(applet, "Center");
|
||||||
|
} // NestedAppletPanel()
|
||||||
|
|
||||||
|
public void paint(Graphics g) {
|
||||||
|
g.drawRect(0, 0, getSize().width -1, getSize().height -1);
|
||||||
|
super.paint(g);
|
||||||
|
} // paint()
|
||||||
|
|
||||||
|
public Dimension getMinimumSize() {
|
||||||
|
return mSize;
|
||||||
|
} // getMinimumSize()
|
||||||
|
|
||||||
|
public Dimension getPreferredSize() {
|
||||||
|
return pSize;
|
||||||
|
} // getPreferrredSize()
|
||||||
|
|
||||||
|
public Insets getInsets() {
|
||||||
|
return new Insets(borderWidth, borderWidth, borderWidth, borderWidth);
|
||||||
|
} // getInsets()
|
||||||
|
} // class NestedAppletPanel
|
||||||
|
|
||||||
|
//----------member variables------------------------------------------------
|
||||||
|
|
||||||
|
private Dimension initialSize = null;
|
||||||
|
private Dimension pSize;
|
||||||
|
private Dimension mSize;
|
||||||
|
private static final int borderWidth = 3;
|
||||||
|
private Panel nestedAppletPanel;
|
||||||
|
private Panel outerAppletPanel;
|
||||||
|
private Applet applet;
|
||||||
|
private GridBagLayout layout;
|
||||||
|
|
||||||
|
} // class AppletPanel
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wait until the user indicates that the test has completed.
|
||||||
|
*/
|
||||||
|
class AppletWaiter
|
||||||
|
{
|
||||||
|
public AppletWaiter() {
|
||||||
|
// done = false;
|
||||||
|
} // AppletWaiter()
|
||||||
|
|
||||||
|
public synchronized void waitForDone() {
|
||||||
|
while (!done) {
|
||||||
|
try {
|
||||||
|
wait();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
AStatus.failed("Thread interrupted: " + e.toString()).exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // waitForDone();
|
||||||
|
|
||||||
|
public synchronized void done() {
|
||||||
|
done = true;
|
||||||
|
notify();
|
||||||
|
} // done()
|
||||||
|
|
||||||
|
private boolean done = false;
|
||||||
|
} // class AppletWaiter
|
|
@ -0,0 +1,125 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998, 2018, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.regtest.agent;
|
||||||
|
|
||||||
|
import java.io.PrintStream;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static com.sun.javatest.regtest.agent.AStatus.error;
|
||||||
|
import static com.sun.javatest.regtest.agent.AStatus.failed;
|
||||||
|
import static com.sun.javatest.regtest.agent.AStatus.passed;
|
||||||
|
|
||||||
|
public class CompileActionHelper extends ActionHelper {
|
||||||
|
|
||||||
|
public static AStatus runCompile(String testName,
|
||||||
|
Map<String, String> props,
|
||||||
|
List<String> cmdArgs,
|
||||||
|
int timeout,
|
||||||
|
OutputHandler outputHandler) {
|
||||||
|
SaveState saved = new SaveState();
|
||||||
|
|
||||||
|
Properties p = System.getProperties();
|
||||||
|
for (Map.Entry<String, String> e : props.entrySet()) {
|
||||||
|
String name = e.getKey();
|
||||||
|
String value = e.getValue();
|
||||||
|
if (name.equals("test.class.path.prefix")) {
|
||||||
|
SearchPath cp = new SearchPath(value, System.getProperty("java.class.path"));
|
||||||
|
p.put("java.class.path", cp.toString());
|
||||||
|
} else {
|
||||||
|
p.put(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.setProperties(p);
|
||||||
|
|
||||||
|
// RUN THE COMPILER
|
||||||
|
// Setup streams for the test:
|
||||||
|
// ... to catch sysout and syserr
|
||||||
|
PrintStream sysOut = outputHandler.getPrintStream(OutputHandler.OutputKind.STDOUT, false);
|
||||||
|
PrintStream sysErr = outputHandler.getPrintStream(OutputHandler.OutputKind.STDERR, true);
|
||||||
|
|
||||||
|
// ... for direct use with RegressionCompileCommand
|
||||||
|
PrintWriter out = outputHandler.getPrintWriter(OutputHandler.OutputKind.DIRECT, false);
|
||||||
|
PrintWriter err = outputHandler.getPrintWriter(OutputHandler.OutputKind.DIRECT_LOG, false);
|
||||||
|
|
||||||
|
AStatus status = error("");
|
||||||
|
try {
|
||||||
|
AStatus stat = redirectOutput(sysOut, sysErr);
|
||||||
|
if (!stat.isPassed()) {
|
||||||
|
return stat;
|
||||||
|
}
|
||||||
|
|
||||||
|
Alarm alarm = Alarm.NONE;
|
||||||
|
if (timeout > 0) {
|
||||||
|
PrintWriter alarmOut = outputHandler.getPrintWriter(OutputHandler.OutputKind.LOG, true);
|
||||||
|
alarm = Alarm.schedulePeriodicInterrupt(timeout, TimeUnit.SECONDS, alarmOut, Thread.currentThread());
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
RegressionCompileCommand jcc = new RegressionCompileCommand() {
|
||||||
|
@Override
|
||||||
|
protected AStatus getStatus(int exitCode) {
|
||||||
|
JDK_Version v = JDK_Version.forThisJVM();
|
||||||
|
return getStatusForJavacExitCode(v, exitCode);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
String[] c = cmdArgs.toArray(new String[cmdArgs.size()]);
|
||||||
|
status = jcc.run(c, err, out);
|
||||||
|
} finally {
|
||||||
|
alarm.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
out.close();
|
||||||
|
err.close();
|
||||||
|
sysOut.close();
|
||||||
|
sysErr.close();
|
||||||
|
status = saved.restore(testName, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AStatus getStatusForJavacExitCode(JDK_Version v, int exitCode) {
|
||||||
|
if (v == null || v.compareTo(JDK_Version.V1_6) < 0)
|
||||||
|
return (exitCode == 0 ? passed : failed);
|
||||||
|
|
||||||
|
// The following exit codes are standard in JDK 6 or later
|
||||||
|
switch (exitCode) {
|
||||||
|
case 0: return passed;
|
||||||
|
case 1: return failed;
|
||||||
|
case 2: return error("command line error (exit code 2)");
|
||||||
|
case 3: return error("system error (exit code 3)");
|
||||||
|
case 4: return error("compiler crashed (exit code 4)");
|
||||||
|
default: return error("unexpected exit code from javac: " + exitCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final AStatus passed = passed("Compilation successful");
|
||||||
|
private static final AStatus failed = failed("Compilation failed");
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998, 2015, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.regtest.agent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Debugging and related flags.
|
||||||
|
*/
|
||||||
|
public class Flags {
|
||||||
|
|
||||||
|
public static boolean get(String name) {
|
||||||
|
return Boolean.getBoolean("javatest.regtest." + name)
|
||||||
|
|| (System.getenv("JTREG_" + name.toUpperCase()) != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,209 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998, 2018, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.regtest.agent;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get properties for the JDK under test.
|
||||||
|
* Usage: {@code
|
||||||
|
* java GetJDKProperties [--system-properties] [--modules] <class-name>*
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
public class GetJDKProperties {
|
||||||
|
public static class ClientCodeException extends Exception {
|
||||||
|
private static final long serialVersionUID = 0;
|
||||||
|
ClientCodeException(String msg, Throwable t) {
|
||||||
|
super(msg, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String JTREG_MODULES = "jtreg.modules";
|
||||||
|
|
||||||
|
public static void main(String... args) {
|
||||||
|
try {
|
||||||
|
run(args);
|
||||||
|
} catch (ClientCodeException e) {
|
||||||
|
System.err.println(e.getMessage());
|
||||||
|
e.getCause().printStackTrace(System.err);
|
||||||
|
System.exit(1);
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Internal error: please report to jtreg-dev@openjdk.java.net");
|
||||||
|
e.printStackTrace(System.err);
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void run(String... args) throws ClientCodeException, IOException {
|
||||||
|
boolean needSystemProperties = false;
|
||||||
|
String needModulesArg = null;
|
||||||
|
Properties p = new Properties();
|
||||||
|
for (String arg: args) {
|
||||||
|
if (arg.equals("--system-properties")) {
|
||||||
|
needSystemProperties = true;
|
||||||
|
} else if (arg.startsWith("--modules=")) {
|
||||||
|
needModulesArg = arg.substring(arg.indexOf("=") + 1);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Class<Callable<Map<String, String>>> c = (Class<Callable<Map<String, String>>>) Class.forName(arg);
|
||||||
|
Callable<Map<String, String>> o = c.getDeclaredConstructor().newInstance();
|
||||||
|
p.putAll(o.call());
|
||||||
|
} catch (Throwable t) {
|
||||||
|
throw new ClientCodeException("Exception while calling user-specified class: " + arg, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needModulesArg != null && getJDKVersion() >= 9) {
|
||||||
|
String modules = null;
|
||||||
|
if (needModulesArg.equals("boot-layer")) {
|
||||||
|
modules = getModulesFromBootLayer();
|
||||||
|
} else if (needModulesArg.equals("all-system")) {
|
||||||
|
modules = getAllSystemModules();
|
||||||
|
}
|
||||||
|
if (modules != null)
|
||||||
|
p.put(JTREG_MODULES, modules);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needSystemProperties) {
|
||||||
|
p.putAll(System.getProperties());
|
||||||
|
}
|
||||||
|
|
||||||
|
p.store(System.out, "jdk properties");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getJDKVersion() {
|
||||||
|
String specVersion = System.getProperty("java.specification.version");
|
||||||
|
if (specVersion == null)
|
||||||
|
return -1;
|
||||||
|
if (specVersion.startsWith("1."))
|
||||||
|
specVersion = specVersion.substring(2);
|
||||||
|
if (specVersion.contains("."))
|
||||||
|
specVersion = specVersion.substring(0, specVersion.indexOf("."));
|
||||||
|
try {
|
||||||
|
return Integer.parseInt(specVersion);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getModulesFromBootLayer() {
|
||||||
|
try {
|
||||||
|
/*
|
||||||
|
* ModuleLayer bootLayer = ModuleLayer.boot();
|
||||||
|
* for (Module m : bootLayer.modules()) {
|
||||||
|
* if (sb.length() > ) sb.append(" ");
|
||||||
|
* sb.append(m.getName());
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
Class<?> layerClass;
|
||||||
|
try {
|
||||||
|
layerClass = Class.forName("java.lang.ModuleLayer");
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
layerClass = Class.forName("java.lang.reflect.Layer");
|
||||||
|
}
|
||||||
|
Method bootMethod = layerClass.getDeclaredMethod("boot");
|
||||||
|
Method modulesMethod = layerClass.getDeclaredMethod("modules");
|
||||||
|
|
||||||
|
Class<?> moduleClass;
|
||||||
|
try {
|
||||||
|
moduleClass = Class.forName("java.lang.Module");
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
moduleClass = Class.forName("java.lang.reflect.Module");
|
||||||
|
}
|
||||||
|
Method getNameMethod = moduleClass.getDeclaredMethod("getName");
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
Object bootLayer = bootMethod.invoke(null);
|
||||||
|
for (Object module : (Set<?>) modulesMethod.invoke(bootLayer)) {
|
||||||
|
if (sb.length() > 0)
|
||||||
|
sb.append(" ");
|
||||||
|
sb.append(getNameMethod.invoke(module));
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
return null;
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
return null;
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return null;
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
return null;
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getAllSystemModules() {
|
||||||
|
try {
|
||||||
|
/* ModuleFinder f = ModuleFinder.ofSystem();
|
||||||
|
* for (ModuleReference mr : f.findAll()) {
|
||||||
|
* ModuleDescriptor md = mr.descriptor();
|
||||||
|
* if (sb.length() > 0 )
|
||||||
|
* sb.append(" ");
|
||||||
|
* sb.append(md.name());
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
|
Class<?> moduleFinderClass = Class.forName("java.lang.module.ModuleFinder");
|
||||||
|
Method ofSystemMethod = moduleFinderClass.getDeclaredMethod("ofSystem");
|
||||||
|
Method findAllMethod = moduleFinderClass.getDeclaredMethod("findAll");
|
||||||
|
|
||||||
|
Class<?> moduleReferenceClass = Class.forName("java.lang.module.ModuleReference");
|
||||||
|
Method descriptorMethod = moduleReferenceClass.getDeclaredMethod("descriptor");
|
||||||
|
|
||||||
|
Class<?> moduleDescriptorClass = Class.forName("java.lang.module.ModuleDescriptor");
|
||||||
|
Method nameMethod = moduleDescriptorClass.getDeclaredMethod("name");
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
Object systemModuleFinder = ofSystemMethod.invoke(null);
|
||||||
|
for (Object mr : (Set<?>) findAllMethod.invoke(systemModuleFinder)) {
|
||||||
|
Object md = descriptorMethod.invoke(mr);
|
||||||
|
if (sb.length() > 0)
|
||||||
|
sb.append(" ");
|
||||||
|
sb.append(nameMethod.invoke(md));
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
return null;
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
return null;
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return null;
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
return null;
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998, 2015, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.regtest.agent;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a system property
|
||||||
|
*/
|
||||||
|
public class GetSystemProperty
|
||||||
|
{
|
||||||
|
public static void main(String[] args) {
|
||||||
|
if (args.length == 1 && args[0].equals("-all")) {
|
||||||
|
try {
|
||||||
|
System.getProperties().store(System.out, "system properties");
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println(e);
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < args.length; i++) {
|
||||||
|
String arg = args[i];
|
||||||
|
String v = System.getProperty(arg);
|
||||||
|
System.out.println(arg + "=" + (v == null ? "" : v));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2007, 2018, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sun.javatest.regtest.agent;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
public class JDK_Version implements Comparable<JDK_Version> {
|
||||||
|
private static final Map<String, JDK_Version> values
|
||||||
|
= new HashMap<String,JDK_Version>();
|
||||||
|
|
||||||
|
public static JDK_Version V1_1 = JDK_Version.forName("1.1");
|
||||||
|
public static JDK_Version V1_5 = JDK_Version.forName("1.5");
|
||||||
|
public static JDK_Version V1_6 = JDK_Version.forName("1.6");
|
||||||
|
public static JDK_Version V9 = JDK_Version.forName("9");
|
||||||
|
public static JDK_Version V10 = JDK_Version.forName("10");
|
||||||
|
|
||||||
|
public static JDK_Version forName(String name) {
|
||||||
|
if (name == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
synchronized (values) {
|
||||||
|
JDK_Version v = values.get(name);
|
||||||
|
if (v == null) {
|
||||||
|
try {
|
||||||
|
int major;
|
||||||
|
if (name.startsWith("1.")) {
|
||||||
|
major = Integer.parseInt(name.substring(2));
|
||||||
|
if (major > 10) { // align with javac: allow 1.9, 1.10
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
major = Integer.parseInt(name);
|
||||||
|
if (major < 5) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
values.put(name, v = new JDK_Version(major));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JDK_Version forThisJVM() {
|
||||||
|
return forName(System.getProperty("java.specification.version"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private JDK_Version(int major) {
|
||||||
|
this.major = major;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int major;
|
||||||
|
|
||||||
|
public String name() {
|
||||||
|
return (major < 9 ? "1." : "") + major;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object other) {
|
||||||
|
return (other instanceof JDK_Version
|
||||||
|
&& (major == ((JDK_Version) other).major));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return major;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(JDK_Version other) {
|
||||||
|
return major < other.major ? -1 : major == other.major ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "JDK " + (major < 9 ? "1." : "") + major;
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue