| | 1604 | =head3 on_run_this_test |
| | 1605 | |
| | 1606 | $main->on_run_this_test; |
| | 1607 | |
| | 1608 | Callback method, to run the currently open test through prove. |
| | 1609 | |
| | 1610 | =cut |
| | 1611 | |
| | 1612 | sub on_run_this_test { |
| | 1613 | my $self = shift; |
| | 1614 | my $document = $self->current->document; |
| | 1615 | unless ($document) { |
| | 1616 | return $self->error( Wx::gettext("No document open") ); |
| | 1617 | } |
| | 1618 | |
| | 1619 | # TODO probably should fetch the current project name |
| | 1620 | my $filename = $document->filename; |
| | 1621 | unless ($filename) { |
| | 1622 | return $self->error( Wx::gettext("Current document has no filename") ); |
| | 1623 | } |
| | 1624 | unless ($filename =~ /\.t$/) { |
| | 1625 | return $self->error( Wx::gettext("Current document is not a .t file") ); |
| | 1626 | } |
| | 1627 | |
| | 1628 | # Find the project |
| | 1629 | my $project_dir = Padre::Util::get_project_dir($filename); |
| | 1630 | unless ($project_dir) { |
| | 1631 | return $self->error( Wx::gettext("Could not find project root") ); |
| | 1632 | } |
| | 1633 | |
| | 1634 | my $dir = Cwd::cwd; |
| | 1635 | chdir $project_dir; |
| | 1636 | $self->run_command("prove -bv $filename"); |
| | 1637 | chdir $dir; |
| | 1638 | } |
| | 1639 | |
| | 1640 | =pod |
| | 1641 | |