|
|
Created:
5 years, 10 months ago by mikecase (-- gone --) Modified:
5 years, 9 months ago CC:
aberent, chromium-reviews, jbudorick+watch_chromium.org, klundberg+watch_chromium.org, yfriedman+watch_chromium.org Base URL:
https://chromium.googlesource.com/chromium/src.git@master Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionAdd a custom Robolectric testrunner.
The default Robolectric testrunner has some behaviors we want to override. By
default the Robolectric testrunner will download the Robolectric runtime
dependencies from the Maven central reposoitory. In addition, Robolectric won't
run at all if the API level in the AndroidManifest isn't officially supported by
Robolectric which isn't what we want.
BUG=448030
Committed: https://crrev.com/8758634a7c0c79481469f50c9c8f1c580169adec
Cr-Commit-Position: refs/heads/master@{#321819}
Patch Set 1 #
Total comments: 6
Patch Set 2 : Rewrote class description for ChromeRobolectricTestRunner. #Patch Set 3 : Moved the robolectric java option directly into the command list. #
Total comments: 4
Patch Set 4 : Fixed jbudoricks nits. Renamed ChromeRoboTestRunner to LocalRoboTestRunner. #
Total comments: 4
Patch Set 5 : #
Total comments: 4
Patch Set 6 : Fixed nits from nyquist. #
Total comments: 2
Patch Set 7 : Rebase #Patch Set 8 : #
Total comments: 1
Messages
Total messages: 46 (16 generated)
mikecase@chromium.org changed reviewers: + jbudorick@chromium.org
Custom robolectric testrunner. Take a look when you have time. Just fyi, changing of the names in third_party/robolectric/BUILD.gn is because robolectric needs the jars to have specific names to find them. I think just renaming them here is the cleanest way to fix this.
https://codereview.chromium.org/942083003/diff/1/build/android/pylib/junit/te... File build/android/pylib/junit/test_runner.py (right): https://codereview.chromium.org/942083003/diff/1/build/android/pylib/junit/te... build/android/pylib/junit/test_runner.py:26: java_args = ('-Drobolectric.dependency.dir=%s' % Why isn't this just in the command list assignment? https://codereview.chromium.org/942083003/diff/1/testing/android/junit/java/s... File testing/android/junit/java/src/org/chromium/testing/local/ChromeRobolectricTestRunner.java (right): https://codereview.chromium.org/942083003/diff/1/testing/android/junit/java/s... testing/android/junit/java/src/org/chromium/testing/local/ChromeRobolectricTestRunner.java:19: * A Robolectric Junit4 Test Runner customized to load the "real" android jars nit: Shorten the first sentence & go into a bit more detail in subsequent sentences. https://codereview.chromium.org/942083003/diff/1/testing/android/junit/java/s... testing/android/junit/java/src/org/chromium/testing/local/ChromeRobolectricTestRunner.java:47: return config.emulateSdk() < 0 ? new SdkConfig(18) : super.pickSdkVersion(null, config); Robolectric has the android 5.0 jar up in Maven: http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.robolectric%22%20AND%2... Should we add that to third_party/robolectric/lib s.t. this can support SDK level 21?
https://codereview.chromium.org/942083003/diff/1/build/android/pylib/junit/te... File build/android/pylib/junit/test_runner.py (right): https://codereview.chromium.org/942083003/diff/1/build/android/pylib/junit/te... build/android/pylib/junit/test_runner.py:26: java_args = ('-Drobolectric.dependency.dir=%s' % On 2015/02/27 15:12:48, jbudorick wrote: > Why isn't this just in the command list assignment? This option, -Drobolectric.dependency.dir, needs to be added before the -jar option (as it is an option to the java command and not an argument for the jar). The other options added below with the command.extend([]) are all options for the jar. https://codereview.chromium.org/942083003/diff/1/testing/android/junit/java/s... File testing/android/junit/java/src/org/chromium/testing/local/ChromeRobolectricTestRunner.java (right): https://codereview.chromium.org/942083003/diff/1/testing/android/junit/java/s... testing/android/junit/java/src/org/chromium/testing/local/ChromeRobolectricTestRunner.java:19: * A Robolectric Junit4 Test Runner customized to load the "real" android jars On 2015/02/27 15:12:48, jbudorick wrote: > nit: Shorten the first sentence & go into a bit more detail in subsequent > sentences. Done. https://codereview.chromium.org/942083003/diff/1/testing/android/junit/java/s... testing/android/junit/java/src/org/chromium/testing/local/ChromeRobolectricTestRunner.java:47: return config.emulateSdk() < 0 ? new SdkConfig(18) : super.pickSdkVersion(null, config); On 2015/02/27 15:12:48, jbudorick wrote: > Robolectric has the android 5.0 jar up in Maven: > http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.robolectric%22%20AND%2... > > Should we add that to third_party/robolectric/lib s.t. this can support SDK > level 21? The robolectric prebuilt doesn't exist yet that supports SDK 21. Once that is added, we will need to add robolectric-prebuild-3.0, and android-all-5.0 to the robolectric/libs, and change the SDK level to 21.
mikecase@chromium.org changed reviewers: + nyquist@chromium.org
Adding nyquist for review of src/testing/android. Also, jbudorick please take another look when you have time.
build/android/ and third_party/robolectric/ lgtm https://codereview.chromium.org/942083003/diff/40001/testing/android/junit/ja... File testing/android/junit/java/src/org/chromium/testing/local/ChromeRobolectricTestRunner.java (right): https://codereview.chromium.org/942083003/diff/40001/testing/android/junit/ja... testing/android/junit/java/src/org/chromium/testing/local/ChromeRobolectricTestRunner.java:34: if (System.getProperty("robolectric.dependency.dir") == null) { just do if (bad thing) { throw exception } return new LocalDependencyResolver(new File(System.getProperty("robolectric.dependency.dir"))); https://codereview.chromium.org/942083003/diff/40001/testing/android/junit/ja... testing/android/junit/java/src/org/chromium/testing/local/ChromeRobolectricTestRunner.java:46: // Pulling from the manifest is dangerous as Chrome might target a version of s/Chrome/the apk/ since we can use this with ContentShell, ChromeShell, and Chrome.
https://codereview.chromium.org/942083003/diff/40001/testing/android/junit/ja... File testing/android/junit/java/src/org/chromium/testing/local/ChromeRobolectricTestRunner.java (right): https://codereview.chromium.org/942083003/diff/40001/testing/android/junit/ja... testing/android/junit/java/src/org/chromium/testing/local/ChromeRobolectricTestRunner.java:34: if (System.getProperty("robolectric.dependency.dir") == null) { On 2015/03/06 16:17:39, jbudorick wrote: > just do > > if (bad thing) { > throw exception > } > return new LocalDependencyResolver(new > File(System.getProperty("robolectric.dependency.dir"))); Done. https://codereview.chromium.org/942083003/diff/40001/testing/android/junit/ja... testing/android/junit/java/src/org/chromium/testing/local/ChromeRobolectricTestRunner.java:46: // Pulling from the manifest is dangerous as Chrome might target a version of On 2015/03/06 16:17:39, jbudorick wrote: > s/Chrome/the apk/ > > since we can use this with ContentShell, ChromeShell, and Chrome. Done. Also renamed the class from ChromeRobolectricTestRunner to LocalRobolectricTestRunner.
+aberent FYI
https://codereview.chromium.org/942083003/diff/60001/testing/android/junit/ja... File testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java (right): https://codereview.chromium.org/942083003/diff/60001/testing/android/junit/ja... testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java:33: File dependencyDir; This is unused. Remove it. https://codereview.chromium.org/942083003/diff/60001/testing/android/junit/ja... testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java:34: if (System.getProperty("robolectric.dependency.dir") == null) { You could only get robolectric.dependency.dir once: String dependencyDir = System.getProperty(...); if (dependencyDir == null) { throw exception } return new LocalDependencyResolver(new File(dependencyDir));
https://codereview.chromium.org/942083003/diff/60001/testing/android/junit/ja... File testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java (right): https://codereview.chromium.org/942083003/diff/60001/testing/android/junit/ja... testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java:33: File dependencyDir; On 2015/03/09 15:37:16, jbudorick wrote: > This is unused. Remove it. Done. https://codereview.chromium.org/942083003/diff/60001/testing/android/junit/ja... testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java:34: if (System.getProperty("robolectric.dependency.dir") == null) { On 2015/03/09 15:37:16, jbudorick wrote: > You could only get robolectric.dependency.dir once: > > String dependencyDir = System.getProperty(...); > if (dependencyDir == null) { > throw exception > } > return new LocalDependencyResolver(new File(dependencyDir)); Done.
nyquist@chromium.org changed reviewers: + cjhopman@chromium.org
cjhopman: Any thoughts on how this should be done? Could the jars be passed in directly to the classpath instead? Does GN have some magic that could possibly be replicated in GYP? https://codereview.chromium.org/942083003/diff/80001/testing/android/junit/ja... File testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java (right): https://codereview.chromium.org/942083003/diff/80001/testing/android/junit/ja... testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java:47: return config.emulateSdk() < 0 ? new SdkConfig(18) : super.pickSdkVersion(null, config); Could you extract 18 to a constant here and below? https://codereview.chromium.org/942083003/diff/80001/third_party/robolectric/... File third_party/robolectric/robolectric.gyp (right): https://codereview.chromium.org/942083003/diff/80001/third_party/robolectric/... third_party/robolectric/robolectric.gyp:9: 'target_name': 'android-all-4.3_r2-robolectric-0', Why do all these include the version now? Also, update the GN references.
https://codereview.chromium.org/942083003/diff/80001/testing/android/junit/ja... File testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java (right): https://codereview.chromium.org/942083003/diff/80001/testing/android/junit/ja... testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java:47: return config.emulateSdk() < 0 ? new SdkConfig(18) : super.pickSdkVersion(null, config); On 2015/03/09 22:10:54, nyquist wrote: > Could you extract 18 to a constant here and below? Done. https://codereview.chromium.org/942083003/diff/80001/third_party/robolectric/... File third_party/robolectric/robolectric.gyp (right): https://codereview.chromium.org/942083003/diff/80001/third_party/robolectric/... third_party/robolectric/robolectric.gyp:9: 'target_name': 'android-all-4.3_r2-robolectric-0', On 2015/03/09 22:10:54, nyquist wrote: > Why do all these include the version now? Also, update the GN references. Robolectric loads these jars at runtime and will look for these exact filenames. I updated the GN (and gyp) references to reflect the new names.
On 2015/03/09 23:40:40, mikecase wrote: > https://codereview.chromium.org/942083003/diff/80001/testing/android/junit/ja... > File > testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java > (right): > > https://codereview.chromium.org/942083003/diff/80001/testing/android/junit/ja... > testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java:47: > return config.emulateSdk() < 0 ? new SdkConfig(18) : super.pickSdkVersion(null, > config); > On 2015/03/09 22:10:54, nyquist wrote: > > Could you extract 18 to a constant here and below? > > Done. > > https://codereview.chromium.org/942083003/diff/80001/third_party/robolectric/... > File third_party/robolectric/robolectric.gyp (right): > > https://codereview.chromium.org/942083003/diff/80001/third_party/robolectric/... > third_party/robolectric/robolectric.gyp:9: 'target_name': > 'android-all-4.3_r2-robolectric-0', > On 2015/03/09 22:10:54, nyquist wrote: > > Why do all these include the version now? Also, update the GN references. > > Robolectric loads these jars at runtime and will look for these exact filenames. > I updated the GN (and gyp) references to reflect the new names. Does it work if the jars are added to the java classpath?
On 2015/03/11 23:40:00, cjhopman wrote: > On 2015/03/09 23:40:40, mikecase wrote: > > > https://codereview.chromium.org/942083003/diff/80001/testing/android/junit/ja... > > File > > > testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java > > (right): > > > > > https://codereview.chromium.org/942083003/diff/80001/testing/android/junit/ja... > > > testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java:47: > > return config.emulateSdk() < 0 ? new SdkConfig(18) : > super.pickSdkVersion(null, > > config); > > On 2015/03/09 22:10:54, nyquist wrote: > > > Could you extract 18 to a constant here and below? > > > > Done. > > > > > https://codereview.chromium.org/942083003/diff/80001/third_party/robolectric/... > > File third_party/robolectric/robolectric.gyp (right): > > > > > https://codereview.chromium.org/942083003/diff/80001/third_party/robolectric/... > > third_party/robolectric/robolectric.gyp:9: 'target_name': > > 'android-all-4.3_r2-robolectric-0', > > On 2015/03/09 22:10:54, nyquist wrote: > > > Why do all these include the version now? Also, update the GN references. > > > > Robolectric loads these jars at runtime and will look for these exact > filenames. > > I updated the GN (and gyp) references to reflect the new names. > > Does it work if the jars are added to the java classpath? That is, instead of needing the DependencyResolver and passing the paths into it.
konstantin.zaikin@gmail.com changed reviewers: + konstantin.zaikin@gmail.com
https://codereview.chromium.org/942083003/diff/80002/build/android/pylib/juni... File build/android/pylib/junit/test_runner.py (right): https://codereview.chromium.org/942083003/diff/80002/build/android/pylib/juni... build/android/pylib/junit/test_runner.py:28: os.path.join(constants.GetOutDirectory(), 'lib.java'), You can calculate os.path.join(constants.GetOutDirectory(), 'lib.java') just once
On 2015/03/11 23:40:34, cjhopman wrote: > On 2015/03/11 23:40:00, cjhopman wrote: > > On 2015/03/09 23:40:40, mikecase wrote: > > > > > > https://codereview.chromium.org/942083003/diff/80001/testing/android/junit/ja... > > > File > > > > > > testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java > > > (right): > > > > > > > > > https://codereview.chromium.org/942083003/diff/80001/testing/android/junit/ja... > > > > > > testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java:47: > > > return config.emulateSdk() < 0 ? new SdkConfig(18) : > > super.pickSdkVersion(null, > > > config); > > > On 2015/03/09 22:10:54, nyquist wrote: > > > > Could you extract 18 to a constant here and below? > > > > > > Done. > > > > > > > > > https://codereview.chromium.org/942083003/diff/80001/third_party/robolectric/... > > > File third_party/robolectric/robolectric.gyp (right): > > > > > > > > > https://codereview.chromium.org/942083003/diff/80001/third_party/robolectric/... > > > third_party/robolectric/robolectric.gyp:9: 'target_name': > > > 'android-all-4.3_r2-robolectric-0', > > > On 2015/03/09 22:10:54, nyquist wrote: > > > > Why do all these include the version now? Also, update the GN references. > > > > > > Robolectric loads these jars at runtime and will look for these exact > > filenames. > > > I updated the GN (and gyp) references to reflect the new names. > > > > Does it work if the jars are added to the java classpath? > > That is, instead of needing the DependencyResolver and passing the paths into > it. I looked into adding the jars to the classpath and was not able to get it working. The problem is that Robolectric expects you to pass it the directory containing the dependency jars and references the file paths of specific jars in a lot of places. Pretty sure you would have to rewrite a lot of Robolectric code just so we could do this. There is no supported way to pass the dependency jars in through the classpath.
lgtm
nyquist please take another look at this when you have time. I have an lgtm from jbudorick for build/android/pylib and an lgtm from cjhopman on the build files and just need your approval on the testing/android/junit parts. Thanks. https://codereview.chromium.org/942083003/diff/80002/build/android/pylib/juni... File build/android/pylib/junit/test_runner.py (right): https://codereview.chromium.org/942083003/diff/80002/build/android/pylib/juni... build/android/pylib/junit/test_runner.py:28: os.path.join(constants.GetOutDirectory(), 'lib.java'), On 2015/03/12 10:44:34, kzaikin wrote: > You can calculate os.path.join(constants.GetOutDirectory(), 'lib.java') just > once Since we only calculate that path twice, I think its cleaner as is than storing that path in a local variable.
lgtm
The CQ bit was checked by mikecase@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from jbudorick@chromium.org Link to the patchset: https://codereview.chromium.org/942083003/#ps80002 (title: "Fixed nits from nyquist.")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/942083003/80002
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: android_arm64_dbg_recipe on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/android_arm64_d...)
The CQ bit was checked by mikecase@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/942083003/80002
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: android_arm64_dbg_recipe on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/android_arm64_d...)
The CQ bit was checked by mikecase@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/942083003/80002
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: android_arm64_dbg_recipe on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/android_arm64_d...)
The CQ bit was checked by mikecase@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from nyquist@chromium.org, cjhopman@chromium.org, jbudorick@chromium.org Link to the patchset: https://codereview.chromium.org/942083003/#ps110001 (title: "Rebase")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/942083003/110001
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: android_arm64_dbg_recipe on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/android_arm64_d...)
https://codereview.chromium.org/942083003/diff/130001/testing/android/junit/j... File testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java (right): https://codereview.chromium.org/942083003/diff/130001/testing/android/junit/j... testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java:34: protected final DependencyResolver getJarResolver() { You don't really have to override this method If you specify robolectric.offline=True env variable, then RobolectricTestRunner would look for robolectric.dependency.dir variable and return LocalDependencyResolver itself.
The CQ bit was checked by mikecase@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from nyquist@chromium.org, cjhopman@chromium.org, jbudorick@chromium.org Link to the patchset: https://codereview.chromium.org/942083003/#ps130001 (title: " ")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/942083003/130001
Message was sent while issue was closed.
Committed patchset #8 (id:130001)
Message was sent while issue was closed.
Patchset 8 (id:??) landed as https://crrev.com/8758634a7c0c79481469f50c9c8f1c580169adec Cr-Commit-Position: refs/heads/master@{#321819} |