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

Accept an empty value for --version-override option to say "don't check C headers" #213

Merged
merged 1 commit into from
Jan 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion features/pecl/install-extensions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,34 @@ Feature: download and install PECL extensions
| apc | APC |
| apcu | apcu |
| mongo | mongo |
| memcache | memcache |

Scenario Outline: Does NOT install extensions from PECL repository having wrong version in source code
Given I run "pickle install <extension>-<version> --dry-run"
Then it should fail
And the output should contain:
"""
Version mismatch - '4.0.5.2' != '8.0' in source vs. XML
"""

Examples:
| extension | version |
| memcache | 8.0 |

Scenario Outline: Install extensions from PECL repository having wrong version in source code
Given I run "pickle install <extension>-<version> --dry-run --version-override"
Then it should pass
And the output should contain:
"""
- Installing <extension> (<version>)
"""
And the output should contain:
"""
Package name | <pretty>
"""

Examples:
| extension | version | pretty |
| memcache | 8.0 | memcache |

Scenario Outline: Install extensions from PECL repository with version constraint
Given I run "pickle install <extension>@<version> --dry-run"
Expand Down
3 changes: 3 additions & 0 deletions src/Base/Abstracts/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ public function getUniqueNameForFs()
is forced to implement it on its own. But so far ... */
public function updateVersion($version = null)
{
if ($version === '') {
return;
}
/* Be sure package root is set before! */
if ($version === null) {
$version = new Header\Version($this);
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/InfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected function configure()
'version-override',
null,
InputOption::VALUE_OPTIONAL,
'Override detected version'
'Override detected version (no value - or empty value - to use the version from package.xml)'
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/InstallerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected function configure()
'version-override',
null,
InputOption::VALUE_OPTIONAL,
'Override detected version'
'Override detected version (no value - or empty value - to use the version from package.xml)'
);

if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
Expand Down
9 changes: 8 additions & 1 deletion src/Console/Helper/PackageHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,14 @@ public function convey(InputInterface $input, OutputInterface $output, $path, $t
$io = new ConsoleIO($input, $output, ($helperSet ? $helperSet : new HelperSet()));

$no_convert = $input->hasOption('no-convert') ? $input->getOption('no-convert') : false;
$versionOverride = $input->hasOption('version-override') ? $input->getOption('version-override') : null;
if ($input->hasOption('version-override')) {
$versionOverride = $input->getOption('version-override');
if ($versionOverride === null && $input->hasParameterOption('--version-override', true)) {
$versionOverride = '';
}
} else {
$versionOverride = null;
}

return (new Convey($path, $io))->deliver($target, $no_convert, $versionOverride);
}
Expand Down
8 changes: 5 additions & 3 deletions src/Package/PHP/Util/PackageXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ public function dump($fname = null)
$this->jsonPath = $fname;
}

$version = $this->versionOverride ?? new Header\Version($this->package);
if ($version != $this->package->getPrettyVersion()) {
throw new \Exception("Version mismatch - '".$version."' != '".$this->package->getVersion().'. in source vs JSON');
if ($this->versionOverride !== '') {
$version = $this->versionOverride ?? (string) new Header\Version($this->package);
if ($version !== $this->package->getPrettyVersion()) {
throw new \Exception("Version mismatch - '".$version."' != '".$this->package->getVersion().'. in source vs JSON');
}
}

$dumper = new Dumper();
Expand Down
10 changes: 6 additions & 4 deletions src/Package/PHP/Util/XML/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function load($path, $versionOverride = null)

$package = [
'name' => (string) $xml->name,
'version' => $versionOverride ?? (string) $xml->version->release,
'version' => (string) $versionOverride === '' ? (string) $xml->version->release : $versionOverride,
'stability' => (string) $xml->stability->release,
'description' => (string) $xml->summary,
];
Expand Down Expand Up @@ -136,9 +136,11 @@ public function load($path, $versionOverride = null)
}
$ret_pkg->setRootDir(dirname($path));

$src_ver = $versionOverride ?? new Header\Version($ret_pkg);
if ($src_ver != $ret_pkg->getPrettyVersion()) {
throw new \Exception("Version mismatch - '".$src_ver."' != '".$ret_pkg->getPrettyVersion()."' in source vs. XML");
if ($versionOverride !== '') {
$src_ver = $versionOverride ?? (string) new Header\Version($ret_pkg);
if ($src_ver !== $ret_pkg->getPrettyVersion()) {
throw new \Exception("Version mismatch - '".$src_ver."' != '".$ret_pkg->getPrettyVersion()."' in source vs. XML");
}
}
$ret_pkg->setType('extension');

Expand Down