-
Notifications
You must be signed in to change notification settings - Fork 43
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
Arbitrary arg length #574
Arbitrary arg length #574
Conversation
@@ -61,7 +61,7 @@ class TranslateTaskTest { | |||
'-d', '/PROJECT_DIR/build/j2objcSrcGenMain', | |||
'-sourcepath', '/PROJECT_DIR/src/main/java:/PROJECT_DIR/build/classes/main', | |||
'-classpath', '/J2OBJC_HOME/lib/j2objc_annotations.jar:/J2OBJC_HOME/lib/j2objc_guava.jar:/J2OBJC_HOME/lib/j2objc_junit.jar:/J2OBJC_HOME/lib/jre_emul.jar:/J2OBJC_HOME/lib/javax.inject-1.jar:/J2OBJC_HOME/lib/jsr305-3.0.0.jar:/J2OBJC_HOME/lib/mockito-core-1.9.5.jar:/J2OBJC_HOME/lib/hamcrest-core-1.3.jar:/J2OBJC_HOME/lib/protobuf_runtime.jar:/PROJECT_DIR/build/classes', | |||
'/PROJECT_DIR/src/main/java/com/example/Main.java' | |||
'@/PROJECT_DIR/build/tmp/j2objcTranslate/inputFiles' |
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.
Do you see how this loses something in the validation? Previously, it would check for Main.java
but now that no-longer happens. Be very careful that you're not regressing the test. Please make two changes:
-
For short command lines, no temporary file should be used - so revert this test to what it was before. That preserves the existing behaviour and avoid the complexity and risk of the temporary file.
-
Add a specific test for the long command line. That'll need a normal test as usual with the
@/PROJECT_DIR/build/tmp/j2objcTranslate/inputFiles
, then an additional test that readsinputFiles
and verifies the contents.
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'll make the changes. I also have a question:
- What do you think, what should consist of a long command line? I thought having a an argument list with a length greater than 250000 is what should be called long (as noted before, for Mac OS X this is 262144). We could also tighten this number and make it around 100000.
@himamis - this should be enough feedback for you to fix this up. Thanks for working on this. Ping me when you've worked through this. There's a couple of other things for you to do:
|
@brunobowden please let me know if the changes are passable, then I'll prepare the pull request for submission. |
final File file -> | ||
// Create the files | ||
file.write("// Fake") |
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.
Take this line out.
The file never needs to be written to disk in order for the test to work. In fact, writing a large number of files will slow down the test dramatically without adding anything to the quality of the testing. An important part of unit tests is that they should avoid anything like writing or reading to a file. In this case, just passing a list of "changed files" is enough for this test to verify the translate task.
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.
Actually, I see the code that you moved here that was writing the file in another place. Can you check if it needs to write the file at all? I will test this myself also.
On Windows the test fails, if the files are not there:
Good news is that with Windows 240 files are enough, and with that the test is under 1 second on my machine. |
@@ -189,18 +187,87 @@ class TranslateTaskTest { | |||
mockProjectExec.verify() | |||
} | |||
|
|||
@Test | |||
// This test takes 8 seconds on average on a local dev computer |
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.
Remove this comment
@himamis - looks like the PR is close to complete. I see the same issue as you that it fails without any files. I put in a comment about trying it with just a main and test file. See if that works. |
proj.file('src/test/java/com/example').mkdirs() | ||
proj.file('src/test/java/com/example/Verify.java').write("// Fake") |
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.
Add comment:
// File in this folder are created by 'genNonIncrementalInputs' method
Sorry, my comment was not clear enough. Without any files, all of the translate tests fail, with just Main1 and Verify1 only the translate_MaxArgsExceeded test fails. |
Fair enough. In which case, leave it as
test On Tue, Jan 5, 2016 at 11:12 PM Bencze Balázs [email protected]
|
5854d71
to
1a14d0d
Compare
@brunobowden The commits have been squashed into a single commit. Please let me know, if there is anything else I need to do. |
@@ -252,7 +252,7 @@ class TranslateTask extends DefaultTask { | |||
project.files(getTranslateSourcepaths()), | |||
project.files(getGeneratedSourceDirs()) | |||
]) | |||
doTranslate(sourcepathDirs, srcGenMainDir, translateArgs, mainSrcFilesChanged) | |||
doTranslate(sourcepathDirs, srcGenMainDir, translateArgs, mainSrcFilesChanged, "mainSrcFilesArgsFile") |
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.
Replace "argsFile" with "argFile" to match the naming in the Java documentation. There's 13 instances of this.
Apologies I didn't catch this earlier:
http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html#commandlineargfile
Two minor nits and then we're done. Ping me once you've fixed them. I'll merge this in once all the CI builds pass. Thanks for your patience @himamis. |
current OS Update TranslateTask, so that when the command line is too large, the file arguments are written into a temporary file, and they are fed to the j2objc command Add a new test case to test if the new files are created and they contain the correct arguments Add a new test case to test the Util method maxArgs()
1a14d0d
to
e00f068
Compare
@brunobowden The |
You're welcome, thank you too. I'll merge this in once the CI builds pass. One last thing... Have you tested this to see if it makes your own build work now? The docs describe how you can test a locally built plugin for that build which was failing before: Confirming that it works would make sure that this is going to solve your problem. I wanted to avoid the situation of releasing a new plugin version and then you find it doesn't solve your problem. |
I've tested it, and I can confirm that with my project it works. |
That's great @himamis. I'll merge this in the morning and then push a new public version for your delectation. |
Thank you @brunobowden. It was fun working on this project! 😄 |
This pull request fixes issue #572 .
A long term fix has been implemented, using a temporary file.
The test have also been modified to accommodate for the changes in the command line of the TranslateTask.