Skip to content

Commit

Permalink
Improvements to SUT
Browse files Browse the repository at this point in the history
  • Loading branch information
Luc45 committed Mar 27, 2024
1 parent 837a662 commit 67c8bbc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Binary file modified qit
Binary file not shown.
20 changes: 10 additions & 10 deletions src/src/Commands/CustomTests/RunE2ECommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ protected function configure() {

// Extension slug/ID.
$this->addArgument(
'path',
'test-path',
InputArgument::OPTIONAL,
'Path to your E2E tests (Optional, if not set, it will try to download your custom tests that you have previously uploaded to QIT)'
);

// If testing a development build, set this.
$this->addOption(
'zip',
'sut',
null,
InputOption::VALUE_OPTIONAL,
'If testing a development build, set this to the path of the zip file.',
'Path to the development build of the extension you are testing. Accepts a WordPress plugin or theme directory, or a WordPress plugin or theme zip file.',
null
);

Expand Down Expand Up @@ -214,23 +214,23 @@ protected function execute( InputInterface $input, OutputInterface $output ): in
}

// Local ZIP build for the SUT.
$zip = $input->getOption( 'zip' );
$sut_override = $input->getOption( 'sut' );

if ( ! empty( $zip ) ) {
if ( ! empty( $sut_override ) ) {
if ( empty( $woo_extension ) ) {
$this->output->writeln( '<error>Cannot set the "zip" option without setting the "woo_extension" argument.</error>' );
$this->output->writeln( '<error>Cannot set the "sut" option without setting the "woo_extension" argument.</error>' );

return Command::INVALID;
}

putenv( sprintf( 'QIT_SUT_ZIP=%s', $zip ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_putenv
putenv( sprintf( 'QIT_SUT_OVERRIDE=%s', $sut_override ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_putenv
}

// Test Path, if local.
$path = $input->getArgument( 'path' );
$test_path = $input->getArgument( 'test-path' );

if ( ! empty( $path ) && file_exists( $path ) && ! empty( $woo_extension ) ) {
putenv( sprintf( 'QIT_CUSTOM_TESTS_PATH=%s|%s', $woo_extension, $path ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_putenv
if ( ! empty( $test_path ) && file_exists( $test_path ) && ! empty( $woo_extension ) ) {
putenv( sprintf( 'QIT_CUSTOM_TESTS_PATH=%s|%s', $woo_extension, $test_path ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_putenv
}

$compatibility = $other_options['compatibility'];
Expand Down
8 changes: 4 additions & 4 deletions src/src/Environment/ExtensionDownload/ExtensionDownloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function download( EnvInfo $env_info, string $cache_dir, array $plugins =
// Set it as read-only to prevent dev messing up their local copy inadvertently (default behavior).

// Inform the user about the read-only mapping.
$this->output->writeln( "Notice: Mapping '{$e->type}s/{$e->extension_identifier}' as read-only to protect your local copy." );
$this->output->writeln( "Info: Mapping '{$e->type}s/{$e->extension_identifier}' as read-only to protect your local copy." );

// Add a read-only volume bind.
$env_info->volumes[ "/var/www/html/wp-content/{$e->type}s/{$e->extension_identifier}:ro" ] = $e->path;
Expand Down Expand Up @@ -126,13 +126,13 @@ public function categorize_extensions( array $plugins, array $themes ): array {
}

if ( getenv( 'QIT_SUT' ) === $ext->extension_identifier ) {
if ( getenv( 'QIT_SUT_ZIP' ) ) {
if ( getenv( 'QIT_SUT_OVERRIDE' ) ) {
static $printed = false;
if ( ! $printed ) {
$this->output->writeln( sprintf( 'Using local development build for %s.', $ext->extension_identifier ) );
$this->output->writeln( sprintf( 'Using local build for %s.', $ext->extension_identifier ) );
$printed = true;
}
$ext->path = getenv( 'QIT_SUT_ZIP' );
$ext->path = getenv( 'QIT_SUT_OVERRIDE' );
}
}

Expand Down

0 comments on commit 67c8bbc

Please sign in to comment.