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-tests.t] fleshed out

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

0 notes on commit c7b2b67

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