RFR: 8258525: Some existing tests should use /nodynamiccopyright/ instead of the standard header

Jonathan Gibbons jjg at openjdk.java.net
Thu Dec 17 05:06:15 UTC 2020


On Wed, 16 Dec 2020 21:19:25 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:

>> Hi all,
>> 
>> This is the background of this patch. According to the comments[1] written by Jonathan Gibbons during the review of JDK-8231622[2], I want to solve previous tests that used the bad style. I wrote a python script[3] to find the bad style tests. But it is not precise and complete.
>> 
>> [1] https://mail.openjdk.java.net/pipermail/compiler-dev/2020-December/015542.html
>> [2] https://github.com/openjdk/jdk/pull/1626
>> [3] https://mail.openjdk.java.net/pipermail/compiler-dev/2020-December/015619.html
>> 
>> Currently, I write another python script that can accurately check all the bad style tests. The procedure of this script is shown below.
>> 1.  Add a blank line at the head of the java source files(exclude the files contain `/nodynamiccopyright/`) in directory `test/langtools/tools/javac`. This step simulates the changes of the length in the legal header.
>> 2. Run the test by using the command `make test CONF=linux-x86_64-server-release JOBS=4 TEST=test/langtools/tools/javac`. This step checks whether the tests can be comfortable to the changes of the length in legal header. If a test failed, it means the test style is bad and need to be revised.
>> 3. Delete the blank line at the head of the java source files(exclude the files contain `/nodynamiccopyright/`) in directory `test/langtools/tools/javac`. This step recovers the modified files.
>> 
>> If all the tests are in good style,  all the tests in step 2 will passed. I use this script to test the branch `master` locally. 129 tests failed. I fixed them. Currently, I use this script to test the branch `test-copyright-clean` of this patch locally. All the tests passed.
>> 
>> I think this patch solves all the bad style tests if my script has no bugs and no new bad style tests were integrated to branch `master` recently.
>> 
>> The code of the new python script is shown below. You maybe need to revise the options `CONF=linux-x86_64-server-release` and `JOBS=4` when testing locally.
>> 
>> #!/usr/bin/python
>> import os
>> 
>> 
>> def runTests(find_dir):
>>     os.system('make test CONF=linux-x86_64-server-release JOBS=4 TEST=' + find_dir)
>>     return
>> 
>> 
>> def addBlankLinePerFile(full_path):
>>     search_file = open(full_path, 'r+')
>>     content = search_file.read()
>>     if content.find("/nodynamiccopyright/") < 0 and full_path.endswith(".java"):
>>         search_file.seek(0)
>>         search_file.write("\n")
>>         search_file.write(content)
>>     search_file.close()
>> 
>> 
>> def deleteBlankLinePerFile(full_path):
>>     search_file = open(full_path, 'r')
>>     old_content = search_file.readlines()
>>     search_file.close()
>>     search_file = open(full_path, 'w')
>>     if ''.join(old_content).find("/nodynamiccopyright/") < 0 and full_path.endswith(".java"):
>>         new_content = ''.join(old_content[1:])
>>         search_file.write(new_content)
>>     else:
>>         search_file.write(''.join(old_content))
>>     search_file.close()
>> 
>> 
>> def addBlankLine(find_dir):
>>     for dir_path, dir_names, file_names in os.walk(find_dir):
>>         for file_name in file_names:
>>             full_path = os.path.join(dir_path, file_name)
>>             addBlankLinePerFile(full_path)
>> 
>> 
>> def deleteBlankLine(find_dir):
>>     for dir_path, dir_names, file_names in os.walk(find_dir):
>>         for file_name in file_names:
>>             full_path = os.path.join(dir_path, file_name)
>>             deleteBlankLinePerFile(full_path)
>> 
>> 
>> if __name__ == "__main__":
>>     findDir = "test/langtools/tools/javac"
>>     addBlankLine(findDir)
>>     runTests(findDir)
>>     deleteBlankLine(findDir)
>> 
>> 
>> Thank you for taking the time to review.
>> And could I ask your help to create a new issue in the bug tracker? Thanks again.
>
> Filed JBS issue: https://bugs.openjdk.java.net/browse/JDK-8258525

I'm ready to approve this change, once the issue has been set correctly

> test/langtools/tools/javac/warnings/MaxWarnsRecompile.java line 2:
> 
>> 1: /*
>> 2:  * Copyright (c) 2019, Google LLC. All rights reserved.
> 
> Another Google copyright

Verified OK to change

> test/langtools/tools/javac/lambda/methodReference/MethodRefStuck.java line 2:
> 
>> 1: /*
>> 2:  * Copyright (c) 2018, Google LLC. All rights reserved.
> 
> Since this file is copyright Google, this file and related files should not be modified without additional checking.

Verified OK to change

-------------

PR: https://git.openjdk.java.net/jdk/pull/1732


More information about the compiler-dev mailing list