Skip to content

Add infection task#405

Merged
Landerstraeten merged 7 commits intophpro:masterfrom
Landerstraeten:infection-task
Nov 17, 2017
Merged

Add infection task#405
Landerstraeten merged 7 commits intophpro:masterfrom
Landerstraeten:infection-task

Conversation

@Landerstraeten
Copy link
Contributor

@Landerstraeten Landerstraeten commented Sep 11, 2017

Q A
Branch master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Documented? yes
Fixed tickets #392

New Task Checklist:

  • Is the README.md file updated?
  • Are the dependencies added to the composer.json suggestions?
  • Is the doc/tasks.md file updated?
  • Are the task parameters documented?
  • Is the task registered in the tasks.yml file?
  • Does the task contains phpspec tests?
  • Is the configuration having logical allowed types?
  • Does the task run in the correct context?
  • Is the run() method readable?
  • Is the run() method using the configuration correctly?
  • Are all CI services returning green?

Copy link
Contributor

@veewee veewee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Landerstraeten,

Thanks for the PR. I've added some small remarks and there are some new task checkboxes that need to be solved.

I haven't used infection myself, so it's hard for me to tell if everything works as it should.

@@ -0,0 +1,79 @@
# Infection

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we suggest to load infection/infection trough composer locally / globally ?
In other task documentation, this is added to the top + in the composer.json file under suggestions.

Since the documentation of infection is suggesting global installation, we might only add it in the task documentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to load it locally. I already updated the documentation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the composer require command to the documentation as well? e.g. https://github.com/phpro/grumphp/blob/master/doc/tasks/phpunit.md


$resolver->addAllowedTypes('threads', ['null', 'int']);
$resolver->addAllowedTypes('test_framework', ['null', 'string']);
$resolver->addAllowedTypes('only_covered', ['null', 'bool']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's a bool, doesn't it make more sense to set the default to false and only support bool?

$resolver->addAllowedTypes('configuration', ['null', 'string']);
$resolver->addAllowedTypes('min_msi', ['null', 'integer']);
$resolver->addAllowedTypes('min_covered_msi', ['null', 'integer']);
$resolver->addAllowedTypes('mutators', ['null', 'string']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An array might be better here to make the configuration easier to read.
We can always implode the array to a comma separated string

$arguments->addOptionalArgument('--threads=%s', $config['threads']);
$arguments->addOptionalArgument('--test-framework=%s', $config['test_framework']);
$arguments->addOptionalArgument('--only-covered', $config['only_covered']);
$arguments->addOptionalArgument('--configuration=%s', $config['configuration']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option is not documented: https://infection.github.io/guide/command-line-options.html
Does it work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation updated

@veewee veewee added this to the Version 0.12.1 milestone Sep 29, 2017
@pierredup
Copy link
Contributor

Mutation testing can be a very time consuming and resource intensive task, especially if it runs the entire test suite on every commit. Ideally I think this should filter to only mutate files that have changed (using the filter option) and test-framework-options needs to be set with the respective values for the test framework to only run test files that have changed.

return TaskResult::createSkipped($this, $context);
}

$arguments = $this->processBuilder->createArgumentsForCommand('infection');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Infection requires xdebug or phpdbg to be installed, so I think this task should be skipped if at least one of those extensions is not installed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think grumphp is responsible to check that. If you don't have xdebug or phpdbg enabled, your tests will not run anyway.

$arguments->addOptionalArgument('--min-covered-msi=%s', $config['min_covered_msi']);
$arguments->addOptionalCommaSeparatedArgument('--mutators=%s', $config['mutators']);

$process = $this->processBuilder->buildProcess($arguments);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interaction should be disabled (with the -n flag)

@Landerstraeten Landerstraeten merged commit 88b6b83 into phpro:master Nov 17, 2017
@Landerstraeten Landerstraeten deleted the infection-task branch November 17, 2017 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants