Skip to content
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
1 change: 1 addition & 0 deletions config/autoload/dependencies.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
'string $factorioDownloadToken' => readConfig(ModConfigKey::MAIN, ModConfigKey::OPTIONS, ModConfigKey::OPTION_TOKEN),
'string $factorioDownloadUsername' => readConfig(ModConfigKey::MAIN, ModConfigKey::OPTIONS, ModConfigKey::OPTION_USERNAME),
'string $instancesDirectory' => readConfig(ConfigKey::MAIN, ConfigKey::DIRECTORIES, ConfigKey::DIRECTORY_INSTANCES),
'string $logsDirectory' => readConfig(ConfigKey::MAIN, ConfigKey::DIRECTORIES, ConfigKey::DIRECTORY_LOGS),
'string $modsDirectory' => readConfig(ConfigKey::MAIN, ConfigKey::DIRECTORIES, ConfigKey::DIRECTORY_MODS),
'string $renderIconBinary' => readConfig(ConfigKey::MAIN, ConfigKey::RENDER_ICON_BINARY),
'string $tempDirectory' => readConfig(ConfigKey::MAIN, ConfigKey::DIRECTORIES, ConfigKey::DIRECTORY_TEMP),
Expand Down
2 changes: 1 addition & 1 deletion src/OutputProcessor/ModNameOutputProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
class ModNameOutputProcessor implements OutputProcessorInterface
{
private const REGEX_CHECKSUM = '#^\s+[0-9.]+ Checksum of (.*): \d+$#m';
private const REGEX_CHECKSUM = '#^\s*[0-9.]+ Checksum of (.*): \d+$#m';
private const MOD_NAME_DUMP = 'Dump';

public function processLine(string $outputLine, Dump $dump): void
Expand Down
7 changes: 7 additions & 0 deletions src/Service/FactorioExecutionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class FactorioExecutionService
protected ModFileService $modFileService;
protected string $factorioDirectory;
protected string $instancesDirectory;
protected string $logsDirectory;
protected string $version;

public function __construct(
Expand All @@ -39,6 +40,7 @@ public function __construct(
ModFileService $modFileService,
string $factorioDirectory,
string $instancesDirectory,
string $logsDirectory,
string $version
) {
$this->exportSerializer = $exportSerializer;
Expand All @@ -47,6 +49,7 @@ public function __construct(
$this->modFileService = $modFileService;
$this->factorioDirectory = (string) realpath($factorioDirectory);
$this->instancesDirectory = (string) realpath($instancesDirectory);
$this->logsDirectory = (string) realpath($logsDirectory);
$this->version = $version;
}

Expand Down Expand Up @@ -199,6 +202,10 @@ public function execute(string $combinationId): Dump
*/
public function cleanup(string $combinationId): self
{
$this->fileSystem->copy(
"{$this->instancesDirectory}/{$combinationId}/factorio-current.log",
"{$this->logsDirectory}/factorio_{$combinationId}.log",
);
$this->fileSystem->remove("{$this->instancesDirectory}/{$combinationId}");
return $this;
}
Expand Down
1 change: 1 addition & 0 deletions test/src/OutputProcessor/ModNameOutputProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function provideProcessLine(): array
return [
[' 69.420 Checksum of abc: 1337', ['def'], ['def', 'abc']],
[' 0.061 Loading mod base 0.18.21 (data.lua)', ['def'], ['def']],
['1103.226 Checksum of Dump: 1832971175', ['foo'], ['foo', 'Dump']],
];
}

Expand Down
11 changes: 11 additions & 0 deletions test/src/Service/FactorioExecutionServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class FactorioExecutionServiceTest extends TestCase
private ModFileService $modFileService;
private string $factorioDirectory = 'foo';
private string $instancesDirectory = 'bar';
private string $logsDirectory = 'baz';
private string $version = '1.2.3';

protected function setUp(): void
Expand All @@ -69,14 +70,17 @@ private function createInstance(array $mockedMethods = []): FactorioExecutionSer
$this->modFileService,
'src',
'test',
'test/asset',
$this->version,
])
->getMock();

$this->assertSame(realpath('src'), $this->extractProperty($instance, 'factorioDirectory'));
$this->assertSame(realpath('test'), $this->extractProperty($instance, 'instancesDirectory'));
$this->assertSame(realpath('test/asset'), $this->extractProperty($instance, 'logsDirectory'));
$this->injectProperty($instance, 'factorioDirectory', $this->factorioDirectory);
$this->injectProperty($instance, 'instancesDirectory', $this->instancesDirectory);
$this->injectProperty($instance, 'logsDirectory', $this->logsDirectory);

return $instance;
}
Expand Down Expand Up @@ -341,6 +345,13 @@ public function testCleanup(): void
{
$combinationId = 'abc';

$this->fileSystem->expects($this->once())
->method('copy')
->with(
$this->identicalTo('bar/abc/factorio-current.log'),
$this->identicalTo('baz/factorio_abc.log'),
);

$this->fileSystem->expects($this->once())
->method('remove')
->with($this->identicalTo('bar/abc'));
Expand Down