Skip to content

TestUnicodeInvariants: add tests for TestCodeInvariants #247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 12, 2022

Conversation

srl295
Copy link
Member

@srl295 srl295 commented May 11, 2022

adds tests for these classes

  • TestUnicodeInvariants
  • TestCodeInvariants

#186

@srl295 srl295 requested a review from markusicu May 11, 2022 18:07
@srl295 srl295 self-assigned this May 11, 2022
@srl295 srl295 force-pushed the srl295/issue186c branch from 7ec984b to 0774db9 Compare May 11, 2022 18:19
@srl295 srl295 marked this pull request as ready for review May 11, 2022 18:20
@srl295
Copy link
Member Author

srl295 commented May 11, 2022

  • fix path issue
java.io.FileNotFoundException: /home/runner/work/unicodetools/unicodetools/unicodetools/nullorg/unicode/text/UCD/UnicodeInvariantTest.txt (No such file or directory)
[2784](https://github.com/unicode-org/unicodetools/runs/6393672630?check_suite_focus=true#step:8:2784)

also @markusicu in the best case there are still 3 failures. Make it a warning for now?

@markusicu
Copy link
Member

markusicu commented May 11, 2022

  • fix path issue

The file is there, and the test runs fine in my workspace. Is the test run missing a variable definition for the UNICODETOOLS_REPO_DIR ?

https://github.com/unicode-org/unicodetools/blob/main/unicodetools/src/main/resources/org/unicode/text/UCD/UnicodeInvariantTest.txt

also @markusicu in the best case there are still 3 failures. Make it a warning for now?

That's what we get for not running it every time...

I just ran it locally and got one test failure. I will send an email.

\p{lb=EB} = \p{Emoji_Modifier_Base}
**** START Test Failure 1 ****
## Expected empty, got: 2	[\U0001FAF7\U0001FAF8]
## In	\p{Emoji_Modifier_Base}
## But Not In	\p{lb=EB} 
1FAF7..1FAF8   #  [2] (�..�)  LEFTWARDS PUSHING HAND..RIGHTWARDS PUSHING HAND
**** END Test Failure 1 ****

@markusicu
Copy link
Member

also @markusicu in the best case there are still 3 failures. Make it a warning for now?

That's what we get for not running it every time...

I just ran it locally and got one test failure. I will send an email.

TestUnicodeInvariants runs cleanly after PR #249. Please rebase.

@srl295
Copy link
Member Author

srl295 commented May 11, 2022

  • fix path issue

The file is there, and the test runs fine in my workspace.

mine also. will investigate

srl295 added 2 commits May 11, 2022 17:46
…deInvariants

- did not move code into the test subdir..yet
- add a test for SRC_UCD_DIR not containing nulls
- fix a misnamed "outputFile" that was really an input file

#186
@srl295 srl295 force-pushed the srl295/issue186c branch from 0774db9 to a0d2657 Compare May 11, 2022 22:58
- read data from classpath on null.

#186
@srl295
Copy link
Member Author

srl295 commented May 11, 2022

@markusicu couldn't sort it out. Changed to use classpath loader.

public static void testInvariants(String outputFile, boolean doRange) throws IOException {
/**
* Fetch a reader for our input data.
* @param inputFile if null, read DEFAULT_FILE from classpath
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would it be null? Line 80 calls testInvariants() with DEFAULT_FILE, or with a String from a command-line argument, if there is one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pass null from TestTestUnicodeInvariants to mean default

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about passing TestUnicodeInvariants.DEFAULT_FILE from the TestTest... code?


import org.junit.jupiter.api.Test;

public class TestTestCodeInvariants {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two TestTest... classes seem awkward.
I see in the PR description "Does not refactor code into the test area, yet" -- is that the next step for this PR? Moving the regular files into the test path and changing them directly, to JUnit tests, replacing these files?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markusicu it's because there are other functions in the original class. Is it called from elsewhere, is it run directly with a parameter? If I remove the original class from src/main/java then it can't be called as easily.

If this looks right I can merge this and then reduce the test classes in a future PR.

@srl295
Copy link
Member Author

srl295 commented May 12, 2022

@markusicu I've removed TestTestCodeInvariants

But, TestUnicodeInvariants can be called with options to give it a different input file, to output HTML, to skip ranges, etc. So I will leave that in the main/java subtree unless i hear otherwise.

@srl295 srl295 requested a review from markusicu May 12, 2022 16:50
- move TestCodeInvariants into the test/ subtree
@srl295 srl295 force-pushed the srl295/issue186c branch from 87f2eda to 32199e9 Compare May 12, 2022 16:58
Copy link
Member

@markusicu markusicu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But, TestUnicodeInvariants can be called with options to give it a different input file, to output HTML, to skip ranges, etc. So I will leave that in the main/java subtree unless i hear otherwise.

Hm. I don't like the TestTest... name, but I see your point. The alternative could be to strip the one Test from the old class where it is and use the old name on the new test-package class. But that's less friendly to file history forensics, and the class-with-main() is still kind of a test. So... ok.

But I have some other comments.

@@ -41,12 +44,24 @@ public static void main(String[] args) {
testGcbInDecompositions(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the showAllNfds parameter from this function and change its code as if it had been false (or replace showAllNfds with VERBOSE). It seems unnecessary to do verbose printing for thousands of decompositions that pass the test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

public static void testInvariants(String outputFile, boolean doRange) throws IOException {
/**
* Fetch a reader for our input data.
* @param inputFile if null, read DEFAULT_FILE from classpath
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about passing TestUnicodeInvariants.DEFAULT_FILE from the TestTest... code?

*/
private static BufferedReader getInputReader(String inputFile) throws IOException {
if (inputFile != null) {
return FileUtilities.openUTF8Reader(Settings.SRC_UCD_DIR, inputFile);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI This should work in the build bots. For example, https://github.com/unicode-org/unicodetools/blob/main/.github/workflows/build-jsp.yml#L52 does set -DUNICODETOOLS_REPO_DIR=$(pwd), and Settings.SRC_UCD_DIR is relative to that. We read all source data files relative to that path.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should but does not

- remove dead code and functions such as main()
- an earlier iteration did not call the GCB tests properly from JUnit

#186
@srl295 srl295 requested a review from markusicu May 12, 2022 19:26
Copy link
Member

@markusicu markusicu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok except for one more thing...

- an earlier iteration still did not call the GCB tests properly from JUnit

#186
Copy link
Member

@markusicu markusicu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm tnx -- please remember to squash-and-merge as usual

@srl295 srl295 merged commit a4f7ab1 into main May 12, 2022
@srl295 srl295 deleted the srl295/issue186c branch May 12, 2022 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants