-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Conversation
also @markusicu in the best case there are still 3 failures. Make it a warning for now? |
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 ?
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. |
mine also. will investigate |
…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
- read data from classpath on null. #186
@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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
@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. |
- move TestCodeInvariants into the test/ subtree
There was a problem hiding this 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.
unicodetools/src/test/java/org/unicode/text/UCD/TestCodeInvariants.java
Outdated
Show resolved
Hide resolved
unicodetools/src/test/java/org/unicode/text/UCD/TestCodeInvariants.java
Outdated
Show resolved
Hide resolved
@@ -41,12 +44,24 @@ public static void main(String[] args) { | |||
testGcbInDecompositions(true); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
unicodetools/src/main/java/org/unicode/text/UCD/TestUnicodeInvariants.java
Outdated
Show resolved
Hide resolved
*/ | ||
private static BufferedReader getInputReader(String inputFile) throws IOException { | ||
if (inputFile != null) { | ||
return FileUtilities.openUTF8Reader(Settings.SRC_UCD_DIR, inputFile); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this 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
There was a problem hiding this 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
adds tests for these classes
#186