Test coverage for retract_layer_change
This commit is contained in:
parent
7041ebdd22
commit
c4bfe64fb8
1 changed files with 134 additions and 108 deletions
|
@ -1,4 +1,4 @@
|
||||||
use Test::More tests => 16;
|
use Test::More tests => 17;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
@ -10,10 +10,11 @@ BEGIN {
|
||||||
use Slic3r;
|
use Slic3r;
|
||||||
use Slic3r::Test qw(_eq);
|
use Slic3r::Test qw(_eq);
|
||||||
|
|
||||||
my $config = Slic3r::Config->new_from_defaults;
|
{
|
||||||
my $duplicate = 1;
|
my $config = Slic3r::Config->new_from_defaults;
|
||||||
|
my $duplicate = 1;
|
||||||
|
|
||||||
my $test = sub {
|
my $test = sub {
|
||||||
my ($conf) = @_;
|
my ($conf) = @_;
|
||||||
$conf ||= $config;
|
$conf ||= $config;
|
||||||
|
|
||||||
|
@ -89,16 +90,16 @@ my $test = sub {
|
||||||
});
|
});
|
||||||
|
|
||||||
1;
|
1;
|
||||||
};
|
};
|
||||||
|
|
||||||
$config->set('first_layer_height', $config->layer_height);
|
$config->set('first_layer_height', $config->layer_height);
|
||||||
$config->set('first_layer_speed', '100%');
|
$config->set('first_layer_speed', '100%');
|
||||||
$config->set('start_gcode', ''); # to avoid dealing with the nozzle lift in start G-code
|
$config->set('start_gcode', ''); # to avoid dealing with the nozzle lift in start G-code
|
||||||
$config->set('retract_length', [1.5]);
|
$config->set('retract_length', [1.5]);
|
||||||
$config->set('retract_before_travel', [3]);
|
$config->set('retract_before_travel', [3]);
|
||||||
$config->set('only_retract_when_crossing_perimeters', 0);
|
$config->set('only_retract_when_crossing_perimeters', 0);
|
||||||
|
|
||||||
my $retract_tests = sub {
|
my $retract_tests = sub {
|
||||||
my ($descr) = @_;
|
my ($descr) = @_;
|
||||||
|
|
||||||
ok $test->(), "retraction$descr";
|
ok $test->(), "retraction$descr";
|
||||||
|
@ -112,21 +113,46 @@ my $retract_tests = sub {
|
||||||
|
|
||||||
$conf->set('retract_lift', [1]);
|
$conf->set('retract_lift', [1]);
|
||||||
ok $test->($conf), "lift$descr";
|
ok $test->($conf), "lift$descr";
|
||||||
};
|
};
|
||||||
|
|
||||||
$retract_tests->('');
|
$retract_tests->('');
|
||||||
|
|
||||||
$duplicate = 2;
|
$duplicate = 2;
|
||||||
$retract_tests->(' (duplicate)');
|
$retract_tests->(' (duplicate)');
|
||||||
|
|
||||||
$config->set('g0', 1);
|
$config->set('g0', 1);
|
||||||
$retract_tests->(' (G0 and duplicate)');
|
$retract_tests->(' (G0 and duplicate)');
|
||||||
|
|
||||||
$duplicate = 1;
|
$duplicate = 1;
|
||||||
$config->set('g0', 0);
|
$config->set('g0', 0);
|
||||||
$config->set('infill_extruder', 2);
|
$config->set('infill_extruder', 2);
|
||||||
$config->set('skirts', 4);
|
$config->set('skirts', 4);
|
||||||
$config->set('skirt_height', 3);
|
$config->set('skirt_height', 3);
|
||||||
$retract_tests->(' (dual extruder with multiple skirt layers)');
|
$retract_tests->(' (dual extruder with multiple skirt layers)');
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
my $config = Slic3r::Config->new_from_defaults;
|
||||||
|
$config->set('retract_layer_change', [0]);
|
||||||
|
|
||||||
|
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
|
||||||
|
my $retracted = 0;
|
||||||
|
my $layer_changes_with_retraction = 0;
|
||||||
|
Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
|
||||||
|
my ($self, $cmd, $args, $info) = @_;
|
||||||
|
|
||||||
|
if ($info->{retracting}) {
|
||||||
|
$retracted = 1;
|
||||||
|
} elsif ($info->{extruding} && $retracted) {
|
||||||
|
$retracted = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($info->{dist_Z} && $retracted) {
|
||||||
|
$layer_changes_with_retraction++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
is $layer_changes_with_retraction, 0, 'no retraction on layer change';
|
||||||
|
}
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
|
Loading…
Reference in a new issue