Berdir found that most of Views time was spent installing the 40+ default views for each method.

This introduces a $testViews property, similar to $modules, which specifies the testing Views that must be available for that class.

This is a work-in-progress

CommentFileSizeAuthor
#5 vdc-1856272-5.patch134.1 KBtim.plunkett
#2 vdc-1847588-8.patch136.72 KBtim.plunkett
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Grayside’s picture

Shouldn't this be generic across configurables? What makes Views super unique?

tim.plunkett’s picture

Status: Active » Needs review
FileSize
136.72 KB

I had to start somewhere. Also, there are 70 testing views and 6 other testing config entities.

I meant to post this last night, whoops.

And yes, too much of this is hardcoded, but as I said, WIP.

tim.plunkett’s picture

+++ b/core/modules/views/lib/Drupal/views/Tests/Comment/ArgumentUserUIDTest.phpundefined
@@ -20,8 +27,12 @@ public static function getInfo() {
-  function testCommentUserUIDTest() {
...
+  protected function testCommentUserUIDTest() {

Grr, I thought I left out the unrelated changes like this. I'll remove them once I see what the bot does.

Status: Needs review » Needs work

The last submitted patch, vdc-1847588-8.patch, failed testing.

tim.plunkett’s picture

FileSize
134.1 KB

Okay, here it is.

tim.plunkett’s picture

Status: Needs work » Needs review
tim.plunkett’s picture

8.x branch tests are taking around 55-66 minutes depending on the bot, the last run on bot #958 being 66 minutes.

This running on #659 took 44 minutes, I'm going to retest to confirm.

xjm’s picture

Issue tags: +Testing system, +VDC
tim.plunkett’s picture

Assigned: tim.plunkett » Unassigned

Okay, the 9XX bots have always been slower, so this is a more accurate comparison with the 66 minute 8.x run:
Bot #983, 49 minutes.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterDateTest.phpundefined
@@ -42,13 +49,21 @@ function setUp() {
+  protected function testDateFilter() {
+    $this->_testOffset();
+    $this->_testBetween();
+    $this->_testUiValidation();
+  }

< 3

+++ b/core/modules/views/lib/Drupal/views/Tests/Language/LanguageTestBase.phpundefined
@@ -7,25 +7,18 @@
+abstract class LanguageTestBase extends ViewUnitTestBase {

yeah!

+++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/ArgumentDefaultTest.phpundefined
@@ -112,16 +110,18 @@ function testArgumentDefaultNoOptions() {
+    $options = $view->display_handler->getOption('arguments');
+    $options['null']['default_argument_options']['argument'] = $random;
+    $view->display_handler->overrideOption('arguments', $options);

@@ -137,13 +137,4 @@ function testArgumentDefaultFixed() {
-    $view = $this->createViewFromConfig('test_argument_default_fixed');
-    $view->displayHandlers['default']->display['display_options']['arguments']['null']['default_argument_options']['argument'] = $this->random;

This makes it's also way easier to read.

+++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/PagerTest.phpundefined
@@ -133,48 +140,35 @@ public function testNoLimit() {
+    for ($i = 0; $i < 23; $i++) {

There is some conspiracy going on.

+++ b/core/modules/views/lib/Drupal/views/Tests/UI/StorageTest.phpundefined
@@ -26,9 +33,10 @@ public static function getInfo() {
+    $view_name = 'test_view';
...
-    $path = "admin/structure/views/nojs/edit-details/{$view->storage->get('name')}";
+    $path = "admin/structure/views/nojs/edit-details/$view_name";

You seemed to have changed every instance of it, so cool!

+++ b/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.phpundefined
@@ -148,27 +147,18 @@ public function testDisplays() {
-    // Manipulate the display variable to test a previous bug.
-    $view = $this->getView();
-    $view->preview();
...
-    $view->destroy();
-    $this->assertViewDestroy($view);

It's a good question whether testing for previous bugs should be part of the tests or not, but personally i would vote for yes, as it doesn't cost us much.

+++ b/core/modules/views/lib/Drupal/views/Tests/ViewTestData.phpundefined
@@ -18,6 +20,50 @@
+      $target_storage = drupal_container()->get('config.storage');

I had some similar code before (using the container in the test enviroment) and wasn't sure whether $this->container/drupal_container() is the right one to use, but for sure just the second one works without issues.

+++ b/core/modules/views/lib/Drupal/views/Tests/ViewTestData.phpundefined
@@ -18,6 +20,50 @@
+        foreach ($source_storage->listAll() as $config_name) {

Should we use the 'views.view' prefix here already? Technically it doesn't change but it might make it easier to get the code.

tim.plunkett’s picture

Status: Reviewed & tested by the community » Needs review

I forgot about $this->container, I was just copying code out of config.inc

Also, I tried to not make it too Views specific, see comment #1

I'm not comfortable with RTBC yet until heyrocker or alexpott looks at this.

gdd’s picture

This seems OK to me, especially in the context of test optimization. It would be nice if we could figure out a way to actually use config_sync_get_changes() to generate the list, but it doesn't really make sense given what we're trying to do. There was one minor little thing in the code I wondered about.

+++ b/core/modules/views/lib/Drupal/views/Tests/ViewTestData.phpundefined
@@ -18,6 +20,50 @@
+    $views = array();
+    while ($class) {
+      if (property_exists($class, 'testViews')) {
+        $views = array_merge($views, $class::$testViews);
+      }
+      $class = get_parent_class($class);
+    }

Not sure I get the point of the array_merge() here since you hardcode $views to be an empty array above? Seems like you could just as easily do $views = $class::$textViews.

tim.plunkett’s picture

That trick is borrowed from WebTestBase::setUp() for enabling modules.

The idea is that both a specific test view and its base class can specify views to use. We're not using that here yet, because I didn't look try to deduce any patterns like that.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

If heyrocker was okay with the config import part, then I'm not worried now and I'm restoring to RTBC from #10.

xjm’s picture

Haven't reviewed this myself, but just wanted to note that I added the underscore-prefixed method names to #1856630: [Change notice] [META] Rename Views methods to core standards, in case those raise any committer eyebrows.

catch’s picture

Status: Reviewed & tested by the community » Active

Looks good to me. Committed/pushed to 8.x. Does this need a change notice for Views contrib test writers?

xjm’s picture

Change notifications have not been written for much larger API changes than this. I did try to introduce the idea, but...
http://drupal.org/list-changes/views

catch’s picture

I guess we could file the change notice issues against views module in contrib..

xjm’s picture

is the 7.x to 8.x change notice for Views just going to be "HAHAHAHAHAHAHAHAHA"?

-webchick

xjm’s picture

Status: Active » Fixed

So, I talked about this in IRC with berdir, webchick, etc. in IRC. Let's called this fixed, because we're changing how we do something that's new to D8 Views tests anyway. However, in general, we probably should come up with some change notifications for Views API changes, and henceforth let's set the issue back to active, tag for change notification, but not mark it critical, since it's a contrib API change rather than a core one. We can always decide we don't need a change notification for something.

Automatically closed -- issue fixed for 2 weeks with no activity.