Skip to content

Commit

Permalink
Merge pull request #699 from phel-lang/feat/change-default-config-dirs
Browse files Browse the repository at this point in the history
Change default config dirs
  • Loading branch information
Chemaclass committed May 24, 2024
2 parents 813aafa + 70ab412 commit 188e097
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.

## Unreleased

* Change `PhelConfig` default src and tests directories (#699)
* Fix `PhelBuildConfig` when using `trim` (#698)
* Fix `setMainPhpPath()` without directory or more than one (#697)
* Rename `PhelOutConfig` to `PhelBuildConfig` (#687)
Expand Down
6 changes: 3 additions & 3 deletions src/php/Config/PhelConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ final class PhelConfig implements JsonSerializable
public const FORMAT_DIRS = 'format-dirs';

/** @var list<string> */
private array $srcDirs = ['src/phel'];
private array $srcDirs = ['src'];

/** @var list<string> */
private array $testDirs = ['tests/phel'];
private array $testDirs = ['tests'];

private string $vendorDir = 'vendor';

Expand All @@ -43,7 +43,7 @@ final class PhelConfig implements JsonSerializable
private PhelBuildConfig $buildConfig;

/** @var list<string> */
private array $ignoreWhenBuilding = ['src/phel/local.phel'];
private array $ignoreWhenBuilding = ['ignore-when-building.phel'];

/** @var list<string> */
private array $noCacheWhenBuilding = [];
Expand Down
2 changes: 1 addition & 1 deletion src/php/Config/PhelExportConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class PhelExportConfig implements JsonSerializable
public const TARGET_DIRECTORY = 'target-directory';

/** @var list<string> */
private array $fromDirectories = ['src/phel'];
private array $fromDirectories = ['src'];

private string $namespacePrefix = 'PhelGenerated';

Expand Down
33 changes: 31 additions & 2 deletions tests/php/Unit/Compiler/Config/PhelConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,36 @@

final class PhelConfigTest extends TestCase
{
public function test_json_serialize(): void
public function test_default_json_serialize(): void
{
$config = new PhelConfig();

$expected = [
PhelConfig::SRC_DIRS => ['src'],
PhelConfig::TEST_DIRS => ['tests'],
PhelConfig::VENDOR_DIR => 'vendor',
PhelConfig::ERROR_LOG_FILE => 'data/error.log',
PhelConfig::BUILD_CONFIG => [
PhelBuildConfig::MAIN_PHEL_NAMESPACE => '',
PhelBuildConfig::DEST_DIR => 'out',
PhelBuildConfig::MAIN_PHP_FILENAME => 'index.php',
PhelBuildConfig::MAIN_PHP_PATH => 'out/index.php',
],
PhelConfig::EXPORT_CONFIG => [
PhelExportConfig::TARGET_DIRECTORY => 'src/PhelGenerated',
PhelExportConfig::FROM_DIRECTORIES => ['src'],
PhelExportConfig::NAMESPACE_PREFIX => 'PhelGenerated',
],
PhelConfig::IGNORE_WHEN_BUILDING => ['ignore-when-building.phel'],
PhelConfig::NO_CACHE_WHEN_BUILDING => [],
PhelConfig::KEEP_GENERATED_TEMP_FILES => false,
PhelConfig::FORMAT_DIRS => ['src', 'tests'],
];

self::assertSame($expected, $config->jsonSerialize());
}

public function test_custom_json_serialize(): void
{
$config = (new PhelConfig())
->setSrcDirs(['some/directory'])
Expand All @@ -20,7 +49,7 @@ public function test_json_serialize(): void
->setErrorLogFile('error-log.file')
->setBuildConfig((new PhelBuildConfig())
->setMainPhpPath('out/custom-index.php')
->setMainPhelNamespace('test-ns/boot'), )
->setMainPhelNamespace('test-ns/boot'))
->setExportConfig((new PhelExportConfig())
->setFromDirectories(['some/other/dir'])
->setNamespacePrefix('Generated')
Expand Down

0 comments on commit 188e097

Please sign in to comment.