On 23. 06. 20 22:36, Matthias Bläsing wrote:
Hi,

Am Dienstag, den 23.06.2020, 20:29 +0200 schrieb Tomáš Procházka:
some tests fail on Windows when test file contains accented
characters.

All files in NetBeans repository have UTF-8 encoding, but my Windows 7
machine uses Windows-1252 encoding. Test files are then not read with
correct encoding and test fails.

For example file
https://github.com/apache/netbeans/blob/master/php/php.latte/test/unit/data/testfiles/indent/testIssue241118_01.latte

I found that default encoding for java can be changed with parameter
"-Dfile.encoding=UTF-8".

Is there any way how to force NetBeans build to use UTF-8 encoding?

the right way to fix this would be to fix CslTestBase:

https://github.com/apache/netbeans/blob/master/ide/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java#L362

Converting bytes to string without specifying the charset is a no-no
and will almost always break in very subtle ways.

I already fixed it here https://github.com/apache/netbeans/pull/2208/files#diff-d19608df0c6ad9fd6a8d39e74970a1f6

Golden files are read correctly and it fixed code completion test with ellipsis in file: https://github.com/apache/netbeans/blob/master/php/php.latte/test/unit/data/testfiles/completion/testCompletion_03.latte.testCompletion_03.completion

How can I fix opening file in https://github.com/apache/netbeans/blob/0636a9ece532761c582ff2062c7baebef72debf6/php/php.latte/test/unit/src/org/netbeans/modules/php/latte/indent/LatteIndenterTestBase.java#L61 ?

File is opened by calling "DataObject dobj = DataObject.find(fo);" where fo is instance of FileObject. I don't know how to read input as UTF-8.

Opened file has wrong encoding, result of test is compared to (now correct) expected file content and test fails.

I assume that in the past the unittests were developed on linux
machines and were run on the linux based CI infrastructure.
Yes, I fixed different errors in tests on Windows caused by different directory separator.
You can try to pass the file encoding to the ant call. If you run the
unittest from the IDE, you can "rerun" (second green double arrow in
the output tab) and specifiy properties there.

HTH

Matthias

Thanks.

Tom

Reply via email to