Re: NetBeans tests and character encoding

2020-06-25 Thread Tim Boudreau
>
>
> 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'd try setting file.encoding in the setup() method.  Or if you want to get
fancy, put an instance of FileEncodingQueryImplementation that always
returns UTF-8 in MockServices in setup.  Or ensure an implementation of
FileEncodingQueryImplementation is in the DataObject's lookup if you're
supplying the DataLoader for it and can instantiate the DataObject subclass
you want for it.

The behavior in general is correct - if nothing exists to specify an
alternate encoding for a file (such as a project), assume the default
system encoding.  Something just needs to handle the special case of
running tests on a machine whose default encoding is *not* UTF-8 - to the
test, it's just a file with no encoding information associated with, so it
defaults to the best available option, which is the system encoding.
Trying to do something special globally for the case of tests would likely
just break tests that test encoding handling.

-Tim



>
> > 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
>
>

-- 
http://timboudreau.com


Re: NetBeans tests and character encoding

2020-06-24 Thread Tomáš Procházka
I used MockLookup with FileEncodingQueryImpl and it fixed loading of 
test documents.

Thanks for advice.

Tom

On 24.6.2020 9:07, Svata Dedic wrote:

Hi,

the IDE respects file.encoding property as the ultimate default, but 
usually(!) a file resides in a Project which can decide on the 
encoding (see e.g. 
org.netbeans.modules.maven.queries.MavenFileEncodingQueryImpl) or the 
DataObject (= file type) may have its own mechanism to detect encoding 
(xml, html).


For testing purposes, I'd suggest to place a FileEncodingQueryImpl 
into MockLookup in the tests, as here:

org.openide.text.DataEditorSupportEncodingTest

You could (I think) also hardcode the encoding for qa-functional/unit 
tests as

test-{unit,qa-functional}-sys-prop.file.encoding=UTF-8

in the module's (?) project.properties

IMHO, the mock lookup approach is "more polite" ;)

-Svata

Dne 23. 06. 20 v 20:29 Tomáš Procházka napsal(a):

Hi,

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?

Regards,

Tom




-
To unsubscribe, e-mail: dev-unsubscr...@netbeans.apache.org
For additional commands, e-mail: dev-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists





Re: NetBeans tests and character encoding

2020-06-24 Thread Svata Dedic

Hi,

the IDE respects file.encoding property as the ultimate default, but 
usually(!) a file resides in a Project which can decide on the encoding 
(see e.g. org.netbeans.modules.maven.queries.MavenFileEncodingQueryImpl) 
or the DataObject (= file type) may have its own mechanism to detect 
encoding (xml, html).


For testing purposes, I'd suggest to place a FileEncodingQueryImpl into 
MockLookup in the tests, as here:

org.openide.text.DataEditorSupportEncodingTest

You could (I think) also hardcode the encoding for qa-functional/unit 
tests as

test-{unit,qa-functional}-sys-prop.file.encoding=UTF-8

in the module's (?) project.properties

IMHO, the mock lookup approach is "more polite" ;)

-Svata

Dne 23. 06. 20 v 20:29 Tomáš Procházka napsal(a):

Hi,

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?

Regards,

Tom


-
To unsubscribe, e-mail: dev-unsubscr...@netbeans.apache.org
For additional commands, e-mail: dev-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists







-
To unsubscribe, e-mail: dev-unsubscr...@netbeans.apache.org
For additional commands, e-mail: dev-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists





Re: NetBeans tests and character encoding

2020-06-23 Thread Tomáš Procházka

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



Re: NetBeans tests and character encoding

2020-06-23 Thread Matthias Bläsing
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 assume that in the past the unittests were developed on linux
machines and were run on the linux based CI infrastructure.

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


-
To unsubscribe, e-mail: dev-unsubscr...@netbeans.apache.org
For additional commands, e-mail: dev-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists





NetBeans tests and character encoding

2020-06-23 Thread Tomáš Procházka

Hi,

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?

Regards,

Tom


-
To unsubscribe, e-mail: dev-unsubscr...@netbeans.apache.org
For additional commands, e-mail: dev-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists