From 11d92fa95fc1c4bcd8cf91d6834258b072655ef9 Mon Sep 17 00:00:00 2001 From: Carl Masak Date: Sun, 13 Jun 2010 03:34:38 +0200 Subject: [PATCH] [t/subcommands/install-skip-tests.t] fleshed out 41 tests run, 40 of which fail. --- lib/App/Pls.pm | 2 +- t/subcommands/install-skip-tests.t | 146 ++++++++++++++++++++++++++--- 2 files changed, 136 insertions(+), 12 deletions(-) diff --git a/lib/App/Pls.pm b/lib/App/Pls.pm index 6c784c4..ff6c5b0 100644 --- a/lib/App/Pls.pm +++ b/lib/App/Pls.pm @@ -42,7 +42,7 @@ class App::Pls::Core { return; } - method install(*@projects, Bool :$force) { + method install(*@projects, Bool :$force, Bool :$skip-test) { return; } } diff --git a/t/subcommands/install-skip-tests.t b/t/subcommands/install-skip-tests.t index f8c673a..1f52de8 100644 --- a/t/subcommands/install-skip-tests.t +++ b/t/subcommands/install-skip-tests.t @@ -1,24 +1,148 @@ use v6; use Test; -# [T] Install-ST a tested project: Succeed. +use App::Pls; -# [T] Install-ST an untested project: Don't test, install. +my %projects = + uninstalled => { :state }, + "won't-install" => { :state }, + untested => { :state }, + "won't-test" => { :state }, + unbuilt => { :state }, + "won't-build" => { :state }, + "won't-test-2" => { :state }, + unfetched => {}, + "won't-fetch" => {}, + "won't-build-2" => {}, + "won't-test-3" => {}, + "has-deps" => { :state, :deps }, + A => { :state }, + B => { :state, :deps }, + C => {}, + D => { :state }, + "circ-deps" => { :state, :deps }, + E => { :state, :deps }, + "dirdep-fails" => { :state, :deps }, #' + "indir-fails" => { :state, :deps }, + F => { :state, :deps }, #' + G => { :state }, + H => { :state }, +; -# [T] Install-ST an unbuilt project: Build, don't test, install. +my @actions; -# [T] Install-ST an unbuilt project; build fails. Fail. +class Mock::Fetcher does App::Pls::Fetcher { +} -# [T] Install-ST an unfetched project: Fetch, build, don't test, install. +class Mock::Builder does App::Pls::Builder { +} -# [T] Install-ST an unfetched project; fetch fails. Fail. +class Mock::Tester does App::Pls::Tester { +} -# [T] Install-ST an unfetched project; build fails. Fail. +class Mock::Installer does App::Pls::Installer { +} -# [T] Install-ST a project with dependencies: Install-ST dependencies too. +my $core = App::Pls::Core.new( + :projects(App::Pls::ProjectsState::Hash.new(%projects)), + :fetcher(Mock::Fetcher.new()), + :builder(Mock::Builder.new()), + :tester(Mock::Tester.new()), + :installer(Mock::Installer.new()), +); -# [T] Install-ST a project with circular dependencies: Fail. +plan 41; -# [T] Install-ST a project whose direct dependency fails: Fail. +given $core { + # [T] Install-ST a tested project: Succeed. + is .install(, :skip-test), success, + "Install-skip-test on an already tested project"; -# [T] Install-ST a project whose indirect dependency fails: Fail. + # [T] Install-ST an untested project: Don't test, install. + @actions = (); + is .install(, :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'"; + + # [T] Install-ST an unbuilt project: Build, don't test, install. + @actions = (); + is .install(, :skip-test), success, "Build, skip test, install"; + is ~@actions, 'build[unbuilt] install[unbuilt]', "Didn't run the tests"; + is .state-of("unbuilt"), installed, "State after: 'installed'"; + + # [T] Install-ST an unbuilt project; build fails. Fail. + @actions = (); + is .install(, :force), failure, #' + "Build fails, won't install"; + is ~@actions, "build[won't-build]", "Didn't try to install"; + is .state-of("won't-build"), fetched, "State after: unchanged"; + + # [T] Install-ST an unfetched project: Fetch, build, don't test, install. + @actions = (); + is .install(, :skip-test), success, + "Fetch, build, skip test, install"; + is ~@actions, 'fetch[unfetched] build[unfetched] install[unfetched]', + "Didn't run the tests"; + is .state-of("unfetched"), installed, "State after: 'installed'"; + + # [T] Install-ST an unfetched project; fetch fails. Fail. + @actions = (); + is .install(, :skip-test), failure, #' + "Fetching fails, won't install"; + is ~@actions, "fetch[won't-fetch]", "Tried to fetch, not build etc"; + is .state-of("won't-fetch"), gone, "State after: unchanged"; + + # [T] Install-ST an unfetched project; build fails. Fail. + @actions = (); + is .install(, :skip-test), failure, #' + "Build fails, won't install"; + is ~@actions, "fetch[won't-build-2] build[won't-build-2]", + "Tried to fetch and build, not test etc"; + is .state-of("won't-build-2"), fetched, "State after: 'fetched'"; + + # [T] Install-ST a project with dependencies: Install-ST dependencies too. + @actions = (); + is .install(, :skip-test), success, + "Install a project with dependencies"; + is ~@actions, 'fetch[C] build[C] build[has-deps] ' + ~ 'install[C] install[D] install[B] install[has-deps]', + "fetch, build and install (all postorder and by need). no test."; + is .state-of("has-deps"), installed, + "State after of has-deps: 'installed'"; + for -> $dep { + is .state-of($dep), installed, "State after of $dep: 'installed'"; + } + + # [T] Install-ST a project with circular dependencies: Fail. + @actions = (); + is .install(, :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"; + + # [T] Install-ST a project whose direct dependency fails: Fail. + @actions = (); + is .install(, :skip-test), failure, + "Direct dependency fails: fail"; + is ~@actions, "install[won't-install]", + "Install fails on first project, doesn't proceed"; + is .state-of("won't-install"), built, + "State after of won't-install: unchanged"; + is .state-of("dirdep-fails"), built, + "State after of dirdep-fails: unchanged"; + + # [T] Install-ST a project whose indirect dependency fails: Fail. + @actions = (); + is .install(, :skip-test), failure, + "Indirect dependency fails: fail"; + is ~@actions, "install[won't-install]", + "Installation fails on first project, doesn't proceed"; + is .state-of("won't-install"), built, "State after: unchanged"; + for -> $dep { + is .state-of($dep), built, "State after of $dep: unchanged"; + } + is .state-of("indir-fails"), built, + "State after of indir-fails: unchanged"; +}