Closed (fixed)
Project:
Panopoly
Version:
7.x-1.x-dev
Component:
Tests / Continuous Integration
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
27 Jun 2014 at 11:31 UTC
Updated:
23 Jul 2014 at 22:00 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dsnopekComment #2
dsnopekComment #3
cboyden commentedThis should work, but I think it will need the Drupal Extension fix in this issue: https://www.drupal.org/node/2093737. Otherwise you can't call functions like getRegion() from a subcontext.
I just confirmed that this fix is in version 1.0.2 and it does allow you to call getMainContext()->getRegion() from a subcontext.
Comment #4
cboyden commentedWorking on a patch - it's going well so far.
Comment #5
cboyden commentedTwo patches attached, one for the main panopoly and one for panopoly_test.
The only thing that is not yet working in a subcontext file is the fixStepArgument that allows you to use a previously-generated random value. So in this patch, it's still in FeatureContext.php.
Another useful thing to do would be set up FeatureContext.php so it can use parameters from the behat.yml file, if anyone adds them.
Comment #6
cboyden commentedYou have to install Behat fresh or run a composer update to get version 1.0.2 of the Drupal extension, which fixes the getRegion issue.
Comment #7
cboyden commentedThe problem with fixStepArgument is that you can't override it in a subcontext because it's defined in MinkContext, and the subcontexts do not inherit from MinkContext, only from BehatContext. There may be some OOP magic that can be done to get around this, otherwise this function has to stay in FeatureContext.php.
A similar problem will happen if you want to override any functions provided by the Drupal extension.
Comment #8
dsnopekTo #7: What if instead of providing a sub-context, we provided a full FeatureContext (extending DrupalContext) that child distributions would extend? So, they'd do something like:
It would allow us to do pretty much anything. I'm not exactly sure how to get that loaded, though... Anyway, just a random idea!
Comment #9
cboyden commentedThe thing you get with subcontexts created as *.behat.inc files is auto-loading. The FeatureContext.php can be completely bare-bones, but as long as you've got your behat.yml file set up correctly, all of the added step definitions will be loaded. So it's kind of mixing metaphors to have other step definitions for which you have to do something extra in FeatureContext.php. It does not allow a tester to drop in their own FeatureContext.php and get everything. And you have a situation where you've got mixed-up dependencies with things in panopoly_test vs. tests/behat.
So you'd have to go all one way or all another. This would mean either:
For the "included in" part, there may be something you can do with autoloading.
And, this may be another ticket, but: The .features pretty much all have dependencies on panopoly_test (for the content type), but that module will not necessarily be enabled when the tests are run. Should the scenarios enable the module before they start, then disable it at the end?
Comment #10
cboyden commentedTo fix the mixed-up dependencies, it should work to have all of the test code (config, features, step definitions) included in the panopoly_test module. The FeatureContext.php will do nothing except require and extend PanopolyContext.php.
If a child distribution wants to use Panopoly test code, it should either use Panopoly's FeatureContext straight up, and run the composer.json in the panopoly_test module, OR, put tests wherever and make sure their behat.yml includes all of the locations to look for features and step definitions, and their FeatureContext can find PanopolyContext and extend it.
Comment #11
cboyden commentedComment #12
cboyden commentedTwo patches attached, one for the main Panopoly and one for panopoly_test.
The first removes all test code and config from the main repo.
The second adds all of the test code and config to panopoly_test. It also moves assets needed for the tests (i.e. files to upload) to the module and uses generic names for them. And finally, it turns FeatureContext.php into a stub that just requires and extends PanopolyContext.php, which contains the steps that can't live in the *.behat.inc files.
Comment #13
dsnopek@cboyden: Thanks for the patches! :-)
Some quick review:
I'm about to try the tests locally to see if they're running for me in this new layout.
Comment #14
dsnopekSomething went wrong here! There is no start (ie.
/**) to the comment.This causes a PHP syntax error when I try to run locally.
Comment #15
cboyden commentedUgh, not sure how that got messed up in the patch. A new patch is attached which fixes the comment and also adds README.md to the module.
Comment #16
cboyden commentedPrevious patch to test did not remove extra step definitions.
Comment #17
cboyden commentedAnd here's an updated patch for the main repo that fixes the Travis script.
Right now the environment is building OK, but the file-upload tests are failing. Probably requires a different files path setting in behat.travis.yml.
Comment #18
dsnopekHrm. Actually, I think your patch for panopoly_test simply doesn't include the binary files! You've got references to test-sm.png and test-lg.png in the *.feature files, but the data for those files isn't included in the patch - just some metadata:
Try regenerating the panopoly_test patch using
git diff --binary --full-index- that should put the binary data in there too.Comment #19
cboyden commentedThanks for the tip - new patch attached.
Comment #20
dsnopekThanks! I just tried running this on Travis-CI:
https://travis-ci.org/dsnopek/panopoly/builds/29515611
It's getting past the uploads now!
But it's failing on submenu_widget.feature for some reason. And it hasn't finished running yet either...
Comment #21
cboyden commentedThe main menu region was not defined in the YML. Now it's added. Also updated panopoly makefile to include the latest panopoly_test patch.
Comment #22
cboyden commentedsubmenu_widget is a new test - it's not finished. Right now it only tests that you can add an existing page to the main menu. Eventually it will include a real test for the submenu. Should I back it out of this patch?
Comment #23
dsnopekAh, yeah, let's try to restrict these changes to just what's necessary to move the tests and FeatureContext. That'll make it easier to follow the history of this later. :-)
Comment #24
cboyden commentedOK. New patches attached without the submenu test.
Comment #25
cboyden commentedIncorrect filename for uploaded image in wysiwyg test - fixed in this patch.
Comment #26
dsnopekI ran the patch on #25 on Travis-CI:
https://travis-ci.org/dsnopek/panopoly/builds/29528644
It looks like you did the same here (with a single gremlin):
https://travis-ci.org/cboyden/panopoly/builds/29527240
And both are passing! So, I think this is ready to commit. :-))
Comment #27
cboyden commentedWoohoo!
The patch to the Panopoly makefile pulls in the patch for panopoly_test - once panopoly_test is committed, that reference needs to be taken out and pointed to the correct Git hash. That should be it for this issue.
Comment #29
dsnopekAh, yes, thanks for the reminder. :-)
I've committed this! Here's the Travis-CI build of final committed versions (hopefully no surprises):
https://travis-ci.org/panopoly/panopoly/builds/29538086
Thanks again - this all looks awesome!
Comment #30
dsnopekHrm! Travis-CI is hitting a weird issue with the md5 checksum not matching when it's trying to download panopoly_test -- except that it really shouldn't even be downloading panopoly_test! I've made a change that should stop it trying: #2300529: On Travis-CI, panopoly_test should be enabled AFTER completing the upgrade
The build for that is here:
https://travis-ci.org/panopoly/panopoly/builds/29548712