Skip to content
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

[Android] Fix PatternSyntaxException #1370

Merged
merged 9 commits into from
May 26, 2018
Merged

[Android] Fix PatternSyntaxException #1370

merged 9 commits into from
May 26, 2018

Conversation

mpkorstanje
Copy link
Contributor

@mpkorstanje mpkorstanje commented May 23, 2018

Summary

Android can't parse \\{.?} see: https://issuetracker.google.com/issues/80198022

Resulting in

    --------- beginning of crash
05-23 23:16:19.256 5159-5159/? E/AndroidRuntime: FATAL EXCEPTION: main
   Process: cucumber.cukeulator, PID: 5159
   java.lang.ExceptionInInitializerError
       at cucumber.runtime.java.JavaBackend.<init>(JavaBackend.java:74)
       at cucumber.runtime.android.CucumberExecutor.createBackends(CucumberExecutor.java:181)
       at cucumber.runtime.android.CucumberExecutor.<init>(CucumberExecutor.java:102)
       at cucumber.api.android.CucumberInstrumentationCore.create(CucumberInstrumentationCore.java:70)
       at cucumber.cukeulator.test.CucumberRunner.onCreate(CucumberRunner.java:33)
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5782)
       at android.app.ActivityThread.-wrap1(Unknown Source:0)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
       at android.os.Handler.dispatchMessage(Handler.java:105)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6541)
       at java.lang.reflect.Method.invoke(Native Method)
       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
    Caused by: java.util.regex.PatternSyntaxException: Syntax error in regexp pattern near index 6
   \{.*?}
         ^
       at java.util.regex.Pattern.compileImpl(Native Method)
       at java.util.regex.Pattern.compile(Pattern.java:1340)
       at java.util.regex.Pattern.<init>(Pattern.java:1324)
       at java.util.regex.Pattern.compile(Pattern.java:946)
       at cucumber.runtime.snippets.SnippetGenerator.<clinit>(SnippetGenerator.java:22)
           ... 14 more

This however is ignored by the android maven plugin:

[INFO] --- android-maven-plugin:4.4.3:internal-integration-test (default-internal-integration-test) @ cukelator-test ---
[INFO] android.devicesThreads parameter not set, using a thread for each attached device
[INFO] android.devices parameter set to [test]
[INFO] emulator-5554_test_unknown_sdk_phone_armv7 :   Running instrumentation tests in cucumber.example.android.cukeulator.test
[INFO] emulator-5554_test_unknown_sdk_phone_armv7 :     Run started: cucumber.example.android.cukeulator.test, 0 tests:
[INFO] emulator-5554_test_unknown_sdk_phone_armv7 :     Run failed: Unable to find instrumentation target package: cucumber.example.android.cukeulator
[INFO] emulator-5554_test_unknown_sdk_phone_armv7 :     Run ended: 0 ms
[INFO]   Tests run: 0,  Failures: 0,  Errors: 0,  Ignored: 0
[INFO] emulator-5554_test_unknown_sdk_phone_armv7 :   Report file written to /home/travis/build/cucumber/cucumber-jvm/examples/android/cukeulator-test/target/surefire-reports/TEST-emulator-5554_test_unknown_sdk_phone_armv7.xml

Which is a problem because it effectively means there is no CI on android.

@coveralls
Copy link

coveralls commented May 23, 2018

Coverage Status

Coverage remained the same at 80.543% when pulling d3f45fa on fix-android into 400dbdf on master.

@mpkorstanje
Copy link
Contributor Author

mpkorstanje commented May 24, 2018

I've spend too much of my spare time on this now. As much as I'd love to dig into this further I do have other things that need to be done at the moment..

If anybody wants to pick up where I left off you can build cucumber-expressions/java from https://github.com/cucumber/cucumber/tree/fix-android-cucumber-expressions and run the example project in https://github.com/cucumber/cucumber-jvm/tree/fix-android The errors show up in Logcat. So if more regexes pop up they should be easy to locate and fix.

@mpkorstanje mpkorstanje merged commit 5d4e181 into master May 26, 2018
@mpkorstanje mpkorstanje changed the title [Android] Fix regex parsing failure [Android] Fix PatternSyntaxException May 26, 2018
@mpkorstanje mpkorstanje deleted the fix-android branch May 26, 2018 00:43
mpkorstanje added a commit that referenced this pull request May 26, 2018
@lock
Copy link

lock bot commented May 26, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators May 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants