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

Force a ?flush=1 on first test run in browser #7

Open
chillu opened this issue Oct 1, 2013 · 8 comments
Open

Force a ?flush=1 on first test run in browser #7

chillu opened this issue Oct 1, 2013 · 8 comments
Labels

Comments

@chillu
Copy link
Member

chillu commented Oct 1, 2013

Otherwise tests fail in a very unfriendly fashion. And given that CLI and web don't share the same cache folders, a sake dev/build flush=1 won't fix this either. Keep performance in mind though.

@sminnee
Copy link
Member

sminnee commented Oct 1, 2013

This might also be because we're using the same folder on our buildslave to run multiple projects. Let's try fixing that first, as this seems like a little bit of a hack.

IgorNadj added a commit to IgorNadj/silverstripe-behat-extension that referenced this issue Apr 7, 2015
When you try to call getRegionObj with a string starting with a number, e.g. "60 NZ Minutes", the getRegionObj function will fail with a syntax exception, and not fall back to looking at the data-title attribute as designed.

Stack trace of the exception thrown:

|  #0 /var/www/public/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php(281): Symfony\Component\CssSelector\Exception\SyntaxErrorException::unexpectedToken('selector', Object(Symfony\Component\CssSelector\Parser\Token))
|  silverstripe#1 /var/www/public/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php(140): Symfony\Component\CssSelector\Parser\Parser->parseSimpleSelector(Object(Symfony\Component\CssSelector\Parser\TokenStream))
|  silverstripe#2 /var/www/public/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php(116): Symfony\Component\CssSelector\Parser\Parser->parserSelectorNode(Object(Symfony\Component\CssSelector\Parser\TokenStream))
|  silverstripe#3 /var/www/public/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php(51): Symfony\Component\CssSelector\Parser\Parser->parseSelectorList(Object(Symfony\Component\CssSelector\Parser\TokenStream))
|  silverstripe#4 /var/www/public/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Translator.php(299): Symfony\Component\CssSelector\Parser\Parser->parse('60 NZ Minutes')
|  silverstripe#5 /var/www/public/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Translator.php(123): Symfony\Component\CssSelector\XPath\Translator->parseSelectors('60 NZ Minutes')
|  silverstripe#6 /var/www/public/vendor/symfony/css-selector/Symfony/Component/CssSelector/CssSelector.php(65): Symfony\Component\CssSelector\XPath\Translator->cssToXPath('60 NZ Minutes', 'descendant-or-s...')
|  silverstripe#7 /var/www/public/vendor/behat/mink/src/Behat/Mink/Selector/CssSelector.php(35): Symfony\Component\CssSelector\CssSelector::toXPath('60 NZ Minutes')
|  silverstripe#8 /var/www/public/vendor/behat/mink/src/Behat/Mink/Selector/SelectorsHandler.php(111): Behat\Mink\Selector\CssSelector->translateToXPath('60 NZ Minutes')
|  silverstripe#9 /var/www/public/vendor/behat/mink/src/Behat/Mink/Element/Element.php(159): Behat\Mink\Selector\SelectorsHandler->selectorToXpath('css', '60 NZ Minutes')
|  silverstripe#10 /var/www/public/vendor/behat/mink/src/Behat/Mink/Element/Element.php(140): Behat\Mink\Element\Element->findAll('css', '60 NZ Minutes')
|  silverstripe#11 /var/www/public/vendor/silverstripe/behat-extension/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php(148): Behat\Mink\Element\Element->find('css', '60 NZ Minutes')

Thanks,
Igor
@phptek
Copy link

phptek commented Jul 26, 2017

@chillu I come across cache-dir related issues all the time, and I'm sure I've encountered scenarios where some aspect of the F/S cache isn't cleared by flush= and I need to manually blow away the cache dir entirely - so for a bootstrapped env in which behat is running, couldn't you manually recursively delete the cache dir prior to the test run or just run behat via the webserver user?

sudo -u www-data ./framework/sake dev/build flush=all

@tractorcow
Copy link

tractorcow commented Jul 26, 2017

@phptek you are right in that we don't trigger a delete on caches on flush; We could do a hard-reset of TEMP_DIR on flush, that that may be a little risky.

How about a flush request processor that iterates all cache definitions in config, and invokes clear() on them?

e.g.

---
Name: cmscache
After:
  - '#corecache'
---
SilverStripe\Core\Injector\Injector:
  Psr\SimpleCache\CacheInterface.CMSMain_SiteTreeHints:
    factory: SilverStripe\Core\Cache\CacheFactory
    constructor:
      namespace: "CMSMain_SiteTreeHints"

Could be cleared with:

class CacheFlushHandler implements Flushable {
	public function flush()
	{
		$config = Config::inst()->get(Injector::class);
		foreach ($config as $name => $definition) {
			if (strtok($name, '.') === CacheInterface::class) { 
				$cache = Injector::inst()->get($name);
				$cache->clear();
			}
		}
	}
}

@phptek
Copy link

phptek commented Jul 26, 2017

@tractorcow while that might work, and not wanting to irk the crowd, but the original problem to me sounds like something that may best be "fixed" by bootstrapping the environment first, i.e. in calling code or in build pipelines.

@dhensby
Copy link

dhensby commented Jul 27, 2017

This issue concerns running tests through the browser, which can't be done anymore...

@dhensby dhensby closed this as completed Jul 27, 2017
@tractorcow
Copy link

@dhensby I initially commented on that too, but this is behat not phpunit.

@tractorcow tractorcow reopened this Jul 27, 2017
@dhensby
Copy link

dhensby commented Jul 27, 2017

Whoops

@phptek
Copy link

phptek commented Jul 27, 2017

This issue concerns running tests through the browser, which can't be done anymore...

Whoops...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants