Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[t/subcommands/install-with-force] fleshed out

40 tests run, 39 out of which fail.
  • Loading branch information...
commit 649a7102c53347c4a54edc7d8f030efe62fcae32 1 parent c7b2b67
Carl Mäsak authored June 13, 2010
4  lib/App/Pls.pm
... ...
@@ -1,7 +1,7 @@
1 1
 use v6;
2 2
 
3 3
 enum State <gone fetched built tested installed>;
4  
-enum Result <success failure>;
  4
+enum Result <failure success forced-success>;
5 5
 
6 6
 role App::Pls::ProjectsState {
7 7
 }
@@ -42,7 +42,7 @@ class App::Pls::Core {
42 42
         return;
43 43
     }
44 44
 
45  
-    method install(*@projects) {
  45
+    method install(*@projects, Bool :$force) {
46 46
         return;
47 47
     }
48 48
 }
150  t/subcommands/install-with-force.t
... ...
@@ -1,22 +1,152 @@
1 1
 use v6;
2 2
 use Test;
3 3
 
4  
-# [T] Force install an untested project; testing fails. Install anyway.
  4
+use App::Pls;
5 5
 
6  
-# [T] Force install an unbuilt project; build fails. Fail.
  6
+my %projects =
  7
+    uninstalled     => { :state<tested> },
  8
+    "won't-install" => { :state<tested> },
  9
+    untested        => { :state<built> },
  10
+    "won't-test"    => { :state<built> },
  11
+    unbuilt         => { :state<fetched> },
  12
+    "won't-build"   => { :state<fetched> },
  13
+    "won't-test-2"  => { :state<fetched> },
  14
+    unfetched       => {},
  15
+    "won't-fetch"   => {},
  16
+    "won't-build-2" => {},
  17
+    "won't-test-3"  => {},
  18
+    "has-deps"      => { :state<fetched>, :deps<A B> },
  19
+    A               => { :state<installed> },
  20
+    B               => { :state<built>, :deps<C D> },
  21
+    C               => {},
  22
+    D               => { :state<built> },
  23
+    "circ-deps"     => { :state<tested>, :deps<E> },
  24
+    E               => { :state<tested>, :deps<circ-deps> },
  25
+    "dirdep-fails"  => { :state<tested>, :deps<won't-install> }, #'
  26
+    "indir-fails"   => { :state<tested>, :deps<F> },
  27
+    F               => { :state<tested>, :deps<won't-install G H> }, #'
  28
+    G               => { :state<tested> },
  29
+    H               => { :state<tested> },
  30
+;
7 31
 
8  
-# [T] Force install an unbuilt project; testing fails. Install anyway.
  32
+my @actions;
9 33
 
10  
-# [T] Force install an unfetched project; fetch fails. Fail.
  34
+class Mock::Fetcher does App::Pls::Fetcher {
  35
+}
11 36
 
12  
-# [T] Force install an unfetched project; build fails. Fail.
  37
+class Mock::Builder does App::Pls::Builder {
  38
+}
13 39
 
14  
-# [T] Force install an unfetched project; testing fails. Install anyway.
  40
+class Mock::Tester does App::Pls::Tester {
  41
+}
15 42
 
16  
-# [T] Force install a project with dependencies: Install dependencies too.
  43
+class Mock::Installer does App::Pls::Installer {
  44
+}
17 45
 
18  
-# [T] Force install a project with circular dependencies: Fail.
  46
+my $core = App::Pls::Core.new(
  47
+    :projects(App::Pls::ProjectsState::Hash.new(%projects)),
  48
+    :fetcher(Mock::Fetcher.new()),
  49
+    :builder(Mock::Builder.new()),
  50
+    :tester(Mock::Tester.new()),
  51
+    :installer(Mock::Installer.new()),
  52
+);
19 53
 
20  
-# [T] Froce install a project whose direct dependency fails: Install anyway.
  54
+plan 40;
21 55
 
22  
-# [T] Force install a project whose indirect dependency fails: Install anyway.
  56
+given $core {
  57
+    # [T] Force install an untested project; testing fails. Install anyway.
  58
+    @actions = ();
  59
+    is .install(<won't-test>, :force), forced-success, #'
  60
+        "Testing fails, install anyway";
  61
+    is ~@actions, "install[won't-test]", "Tested, installed";
  62
+    is .state-of("won't test"), installed, "State after: 'installed'";
  63
+
  64
+    # [T] Force install an unbuilt project; build fails. Fail.
  65
+    @actions = ();
  66
+    is .install(<won't-build>, :force), failure, #'
  67
+        "Build fails, won't install";
  68
+    is ~@actions, "build[won't-build]", "Didn't try to install";
  69
+    is .state-of("won't-build"), fetched, "State after: unchanged";
  70
+
  71
+    # [T] Force install an unbuilt project; testing fails. Install anyway.
  72
+    @actions = ();
  73
+    is .install(<won't-test-2>, :force), forced-success, #'
  74
+        "Testing fails, install anyway";
  75
+    is ~@actions, "build[won't-test-2] test[won't-test-2] "
  76
+                  ~ "install[won't-test-2]",
  77
+        "Built, tested and installed";
  78
+    is .state-of("won't-test-2"), installed, "State after: 'installed'";
  79
+
  80
+    # [T] Force install an unfetched project; fetch fails. Fail.
  81
+    @actions = ();
  82
+    is .install(<won't-fetch>, :force), failure, #'
  83
+        "Fetching fails, won't install";
  84
+    is ~@actions, "fetch[won't-fetch]", "Tried to fetch, not build etc";
  85
+    is .state-of("won't-fetch"), gone, "State after: unchanged";
  86
+
  87
+    # [T] Force install an unfetched project; build fails. Fail.
  88
+    @actions = ();
  89
+    is .install(<won't-build-2>, :force), failure, #'
  90
+        "Build fails, won't install";
  91
+    is ~@actions, "fetch[won't-build-2] build[won't-build-2]",
  92
+        "Tried to fetch and build, not test etc";
  93
+    is .state-of("won't-build-2"), fetched, "State after: 'fetched'";
  94
+
  95
+    # [T] Force install an unfetched project; testing fails. Install anyway.
  96
+    @actions = ();
  97
+    is .install(<won't-test-3>, :force), forced-success, #'
  98
+        "Test fails, install anyway";
  99
+    is ~@actions, "fetch[won't-test-3] build[won't-test-3] test[won't-test-3] "
  100
+                  ~ "install[won't-test-3]",
  101
+        "Fetch, build, test and install";
  102
+    is .state-of("won't-test-3"), built, "State after: 'built'";
  103
+
  104
+    # [T] Force install a project with dependencies: Install dependencies too.
  105
+    @actions = ();
  106
+    is .install(<has-deps>, :force), success,
  107
+        "Install a project with dependencies";
  108
+    is ~@actions, 'fetch[C] build[C] build[has-deps] '
  109
+                  ~ 'test[C] test[D] test[B] test[has-deps] '
  110
+                  ~ 'install[C] install[D] install[B] install[has-deps]',
  111
+        "fetch, build, test and install (all postorder and by need)";
  112
+    is .state-of("has-deps"), installed,
  113
+        "State after of has-deps: 'installed'";
  114
+    for <A B C D> -> $dep {
  115
+        is .state-of($dep), installed, "State after of $dep: 'installed'";
  116
+    }
  117
+
  118
+    # [T] Force install a project with circular dependencies: Fail.
  119
+    @actions = ();
  120
+    is .install(<circ-deps>, :force), failure,
  121
+        "Circular dependency install: fail";
  122
+    is ~@actions, '', "Nothing was done";
  123
+    is .state-of("circ-deps"), tested, "State after of circ-deps: unchanged";
  124
+    is .state-of("E"), tested, "State after of E: unchanged";
  125
+
  126
+    # [T] Froce install a project whose direct dependency fails:
  127
+    #     Install anyway.
  128
+    @actions = ();
  129
+    is .install(<dirdep-fails>, :force), forced-success,
  130
+        "Direct dependency fails but project itself succeds: succeed";
  131
+    is ~@actions, "install[won't-install] install[dirdep-fails]",
  132
+        "Install proceeds even after failure";
  133
+    is .state-of("won't-install"), tested,
  134
+        "State after of won't-install: unchanged";
  135
+    is .state-of("dirdep-fails"), installed,
  136
+        "State after of dirdep-fails: 'installed'";
  137
+
  138
+    # [T] Force install a project whose indirect dependency fails:
  139
+    #     Install anyway.
  140
+    @actions = ();
  141
+    is .install(<indir-fails>, :force), forced-success,
  142
+        "Indirect dependency fails but project itself succeeds: succeed";
  143
+    is ~@actions, "install[won't-install] install[G] install[H] install[F] "
  144
+                  ~ "install[indir-fails]",
  145
+        "Installation of all projects are made, though the first fails";
  146
+    is .state-of("won't-install"), tested, "State after: unchanged";
  147
+    for <F G H> -> $dep {
  148
+        is .state-of($dep), installed, "State after of $dep: 'installed'";
  149
+    }
  150
+    is .state-of("indir-fails"), installed,
  151
+        "State after of indir-fails: 'installed'";
  152
+}

0 notes on commit 649a710

Please sign in to comment.
Something went wrong with that request. Please try again.