Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[App::Pls] implemented 'install'

All t/subcommands/install-*.t tests pass. Which means that all tests now pass.
  • Loading branch information...
commit 0358c5ba39a822f93da16904773f8ef96be20b92 1 parent 07dcc69
@masak authored
View
43 lib/App/Pls.pm
@@ -58,6 +58,7 @@ role App::Pls::Tester {
}
role App::Pls::Installer {
+ method install($project) { !!! }
}
class App::Pls::Core {
@@ -65,6 +66,7 @@ class App::Pls::Core {
has App::Pls::Fetcher $!fetcher;
has App::Pls::Builder $!builder;
has App::Pls::Tester $!tester;
+ has App::Pls::Installer $!installer;
method state-of($project) {
return $!projects.state-of($project);
@@ -162,6 +164,45 @@ class App::Pls::Core {
}
method install(*@projects, Bool :$force, Bool :$skip-test) {
- return;
+ my $*needed-force = False;
+ for @projects -> $project {
+ my %*seen-projects;
+ return failure
+ if self!fetch-helper($project) == failure;
+ return failure
+ if self!build-helper($project) == failure;
+ unless $skip-test {
+ if self!test-helper($project) == failure {
+ return failure
+ unless $force;
+ $*needed-force = True;
+ }
+ }
+ # RAKUDO: an unspecified $force should be False, is Any
+ return failure
+ if self!install-helper($project, :force(?$force)) == failure;
+ }
+ return $*needed-force ?? forced-success !! success;
+ }
+
+ method !install-helper($project, Bool :$force --> Result) {
+ for $!projects.deps-of($project) -> $dep {
+ # RAKUDO: an unspecified $force should be False, is Any
+ if self!install-helper($dep, :force(?$force)) == failure {
+ return failure
+ unless $force;
+ $*needed-force = True;
+ }
+ }
+ if $!projects.reached-state($project, 'installed') {
+ return success;
+ }
+ elsif $!installer.install($project) == success {
+ $!projects.set-state-of($project, 'installed');
+ return success;
+ }
+ else {
+ return failure;
+ }
}
}
View
30 t/subcommands/install-skip-tests.t
@@ -32,15 +32,39 @@ my %projects =
my @actions;
class Mock::Fetcher does App::Pls::Fetcher {
+ method fetch($project) {
+ push @actions, "fetch[$project]";
+ return failure
+ if $project eq "won't-fetch";
+ return success;
+ }
}
class Mock::Builder does App::Pls::Builder {
+ method build($project) {
+ push @actions, "build[$project]";
+ return failure
+ if $project ~~ /^ won\'t\-build/;
+ return success;
+ }
}
class Mock::Tester does App::Pls::Tester {
+ method test($project) {
+ push @actions, "test[$project]";
+ return failure
+ if $project ~~ /^ won\'t\-test/;
+ return success;
+ }
}
class Mock::Installer does App::Pls::Installer {
+ method install($project) {
+ push @actions, "install[$project]";
+ return failure
+ if $project eq "won't-install";
+ return success;
+ }
}
my $core = App::Pls::Core.new(
@@ -63,7 +87,7 @@ given $core {
is .install(<won't-test>, :skip-test), success, #'
"Tests are never run, go directly to install";
is ~@actions, "install[won't-test]", "Tests skipped, installed";
- is .state-of("won't test"), 'installed', "State after: 'installed'";
+ is .state-of("won't-test"), 'installed', "State after: 'installed'";
# [T] Install-ST an unbuilt project: Build, don't test, install.
@actions = ();
@@ -119,8 +143,8 @@ given $core {
is .install(<circ-deps>, :skip-test), failure,
"Circular dependency install: fail";
is ~@actions, '', "Nothing was done";
- is .state-of("circ-deps"), 'tested', "State after of circ-deps: unchanged";
- is .state-of("E"), 'tested', "State after of E: unchanged";
+ is .state-of("circ-deps"), 'built', "State after of circ-deps: unchanged";
+ is .state-of("E"), 'built', "State after of E: unchanged";
# [T] Install-ST a project whose direct dependency fails: Fail.
@actions = ();
View
29 t/subcommands/install-with-force.t
@@ -18,6 +18,7 @@ my %projects =
"circ-deps" => { :state<tested>, :deps<E> },
E => { :state<tested>, :deps<circ-deps> },
"dirdep-fails" => { :state<tested>, :deps<won't-install> }, #'
+ "won't-install" => { :state<tested> },
"indir-fails" => { :state<tested>, :deps<F> },
F => { :state<tested>, :deps<won't-install G H> }, #'
G => { :state<tested> },
@@ -27,15 +28,39 @@ my %projects =
my @actions;
class Mock::Fetcher does App::Pls::Fetcher {
+ method fetch($project) {
+ push @actions, "fetch[$project]";
+ return failure
+ if $project eq "won't-fetch";
+ return success;
+ }
}
class Mock::Builder does App::Pls::Builder {
+ method build($project) {
+ push @actions, "build[$project]";
+ return failure
+ if $project ~~ /^ won\'t\-build/;
+ return success;
+ }
}
class Mock::Tester does App::Pls::Tester {
+ method test($project) {
+ push @actions, "test[$project]";
+ return failure
+ if $project ~~ /^ won\'t\-test/;
+ return success;
+ }
}
class Mock::Installer does App::Pls::Installer {
+ method install($project) {
+ push @actions, "install[$project]";
+ return failure
+ if $project eq "won't-install";
+ return success;
+ }
}
my $core = App::Pls::Core.new(
@@ -54,7 +79,7 @@ given $core {
is .install(<won't-test>, :force), forced-success, #'
"Testing fails, install anyway";
is ~@actions, "test[won't-test] install[won't-test]", "Tested, installed";
- is .state-of("won't test"), 'installed', "State after: 'installed'";
+ is .state-of("won't-test"), 'installed', "State after: 'installed'";
# [T] Force install an unbuilt project; build fails. Fail.
@actions = ();
@@ -94,7 +119,7 @@ given $core {
is ~@actions, "fetch[won't-test-3] build[won't-test-3] test[won't-test-3] "
~ "install[won't-test-3]",
"Fetch, build, test and install";
- is .state-of("won't-test-3"), 'built', "State after: 'built'";
+ is .state-of("won't-test-3"), 'installed', "State after: 'installed'";
# [T] Force install a project with dependencies: Install dependencies too.
@actions = ();
View
28 t/subcommands/install-with-test.t
@@ -29,15 +29,39 @@ my %projects =
my @actions;
class Mock::Fetcher does App::Pls::Fetcher {
+ method fetch($project) {
+ push @actions, "fetch[$project]";
+ return failure
+ if $project eq "won't-fetch";
+ return success;
+ }
}
class Mock::Builder does App::Pls::Builder {
+ method build($project) {
+ push @actions, "build[$project]";
+ return failure
+ if $project ~~ /^ won\'t\-build/;
+ return success;
+ }
}
class Mock::Tester does App::Pls::Tester {
+ method test($project) {
+ push @actions, "test[$project]";
+ return failure
+ if $project ~~ /^ won\'t\-test/;
+ return success;
+ }
}
class Mock::Installer does App::Pls::Installer {
+ method install($project) {
+ push @actions, "install[$project]";
+ return failure
+ if $project eq "won't-install";
+ return success;
+ }
}
my $core = App::Pls::Core.new(
@@ -72,7 +96,7 @@ given $core {
@actions = ();
is .install(<won't-test>), failure, "Testing fails, won't install"; #"
is ~@actions, "test[won't-test]", "Tested, didn't install";
- is .state-of("won't test"), 'built', "State after: unchanged";
+ is .state-of("won't-test"), 'built', "State after: unchanged";
# [T] Install an unbuilt project: Build, test, install.
@actions = ();
@@ -98,7 +122,7 @@ given $core {
@actions = ();
is .install(<unfetched>), success, "Fetch, build, test, install";
is ~@actions,
- 'fetch[unfetched] build[unfetched] test[unfetched] install[unfected]',
+ 'fetch[unfetched] build[unfetched] test[unfetched] install[unfetched]',
"Correct order";
is .state-of("unfetched"), 'installed', "State after: 'installed'";
Please sign in to comment.
Something went wrong with that request. Please try again.