Skip to content

Commit

Permalink
[t/subcommands/*.t] decided to go with strings
Browse files Browse the repository at this point in the history
Had an enum there before, but it wasn't worth the trouble. Strings are so
much easier to work with, and we can get more mileage out of a subtype of
strings right now than from an enum.
  • Loading branch information
Carl Masak committed Jun 13, 2010
1 parent 11d92fa commit 22f24b5
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 93 deletions.
34 changes: 18 additions & 16 deletions t/subcommands/build.t
Expand Up @@ -38,60 +38,62 @@ plan 31;

given $core {
# [T] Build a project: Succeed.
is .state-of('fetched'), fetched, "State before: 'fetched'";
is .state-of('fetched'), 'fetched', "State before: 'fetched'";
is .build(<fetched>), success, "Building project succeeded";
is .state-of('fetched'), built, "State after: 'built'";
is .state-of('fetched'), 'built', "State after: 'built'";

# [T] Build an unfetched project: Fetch, build.
@actions = ();
is .state-of('unfetched'), gone, "State before: 'gone'";
is .state-of('unfetched'), 'gone', "State before: 'gone'";
is .build(<unfetched>), success, "Building unfetched project succeeded";
is ~@actions, 'fetch[unfeched] build[unfetched]',
"Fetched the project before building it";
is .state-of('unfetched'), built, "State after of unfetched: 'built'";
is .state-of('unfetched'), 'built', "State after of unfetched: 'built'";

# [T] Build an unfetched project; fetch fails. Fail.
@actions = ();
is .build(<won't-fetch>), failure, "Won't build if fetch fails"; # "
is ~@actions, "fetch[won't-fetch]", "Didn't try building";
is .state-of("won't-fetch"), gone, "State after of won't-fetch: unchanged";
is .state-of("won't-fetch"), 'gone',
"State after of won't-fetch: unchanged";

# [T] Build a project; a build error occurs: Fail.
@actions = ();
is .build(<won't-build>), failure, "Won't build if build fails"; # "
is ~@actions, "fetch[won't-build] build[won't build]", "Tried building";
is .state-of("won't-build"), gone, "State after of won't-build: unchanged";
is .state-of("won't-build"), 'gone',
"State after of won't-build: unchanged";

# [T] Build a project with dependencies: Build dependencies first.
@actions = ();
is .build(<has-deps>), success, "Building project with deps succeeds";
is .build(<has-deps>), 'success', "Building project with deps succeeds";
is ~@actions, "fetch[C] build[A] build[C] build[D] build[has-deps]",
"Fetch before build, build with postorder traversal";
is .state-of('has-deps'), built, "State after of has-deps: built";
is .state-of('has-deps'), 'built', "State after of has-deps: built";
for <A B C D> -> $dep {
is .state-of($dep), built, "State after of $dep: built";
is .state-of($dep), 'built', "State after of $dep: built";
}

# [T] Build a project with circular dependencies: Fail.
@actions = ();
is .build(<circ-deps>), failure, "Building project with circ deps fails";
is ~@actions, "", "Didn't even try to build anything";
is .state-of('circ-deps'), fetched, "State after of circ-deps: unchanged";
is .state-of('E'), fetched;
is .state-of('circ-deps'), 'fetched', "State after of circ-deps: unchanged";
is .state-of('E'), 'fetched';

# [T] Build a project whose direct dependency fails: Fail.
is .build(<dirdep-fails>), failure, "Fail when direct dep fails to build";
is .state-of('dirdep-fails'), fetched,
is .state-of('dirdep-fails'), 'fetched',
"State after of dirdep-fails: unchanged";
is .state-of('will-fail'), fetched,
is .state-of('will-fail'), 'fetched',
"State after of will-fail: unchanged";

# [T] Build a project whose indirect dependency fails: Fail.
is .build(<indir-fails>), failure, "Fail when indirect dep fails to build";
is .state-of('indir-fails'), fetched,
is .state-of('indir-fails'), 'fetched',
"State after of indir-fails: unchanged";
is .state-of('dirdep-fails'), fetched,
is .state-of('dirdep-fails'), 'fetched',
"State after of dirdep-fails: unchanged";
is .state-of('will-fail'), fetched,
is .state-of('will-fail'), 'fetched',
"State after of will-fail: unchanged";
}
24 changes: 12 additions & 12 deletions t/subcommands/fetch.t
Expand Up @@ -30,36 +30,36 @@ plan 24;

given $core {
# [T] Fetch a project: Succeed.
is .state-of('will-succeed'), gone, "State is now 'gone'";
is .state-of('will-succeed'), 'gone', "State is now 'gone'";
is .fetch(<will-succeed>), success, "Fetch a project: Succeed";
is .state-of('will-succeed'), fetched, "State after: 'fetched'";
is .state-of('will-succeed'), 'fetched', "State after: 'fetched'";

# [T] Fetch a project; an unexpected error occurs: Fail.
is .fetch(<will-fail>), failure, "Fetch a project: Fail";
is .state-of('will-fail'), gone, "State after: 'gone'";
is .state-of('will-fail'), 'gone', "State after: 'gone'";

# [T] Fetch a project with dependencies: Fetch dependencies too.
for <A B C D> -> $dep {
is .state-of($dep), gone, "State before of $dep: 'gone'";
is .state-of($dep), 'gone', "State before of $dep: 'gone'";
}
is .fetch(<has-deps>), success, "Fetch project's dependencies, too";
for <A B C D> -> $dep {
is .state-of($dep), fetched, "State after of $dep: 'fetched'";
is .state-of($dep), 'fetched', "State after of $dep: 'fetched'";
}

# [T] Fetch a project with circular dependencies: Fail.
is .fetch(<circ-deps>), failure, "Fetch a project with circ deps: fail";
is .state-of('circ-deps'), gone, "State after of circ-deps: 'gone'";
is .state-of('E'), gone, "State after of E: 'gone'";
is .state-of('circ-deps'), 'gone', "State after of circ-deps: 'gone'";
is .state-of('E'), 'gone', "State after of E: 'gone'";

# [T] Fetch a project whose direct dependency fails: Fail.
is .fetch(<dirdep-fails>), failure, "Fail on direct dependency failure";
is .state-of('dirdep-fails'), gone, "State after of dirdep-fails: 'gone'";
is .state-of('will-fail'), gone, "State after of will-fail: 'gone'";
is .state-of('dirdep-fails'), 'gone', "State after of dirdep-fails: 'gone'";
is .state-of('will-fail'), 'gone', "State after of will-fail: 'gone'";

# [T] Fetch a project whose indirect dependency fails: Fail.
is .fetch(<indir-fails>), failure, "Fail on indirect dependency failure";
is .state-of('indir-fails'), gone, "State after of indir-fails: 'gone'";
is .state-of('dirdep-fails'), gone, "State after of dirdep-fails: 'gone'";
is .state-of('will-fail'), gone, "State after of will-fail: 'gone'";
is .state-of('indir-fails'), 'gone', "State after of indir-fails: 'gone'";
is .state-of('dirdep-fails'), 'gone', "State after of dirdep-fails: 'gone'";
is .state-of('will-fail'), 'gone', "State after of will-fail: 'gone'";
}
30 changes: 15 additions & 15 deletions t/subcommands/install-skip-tests.t
Expand Up @@ -63,43 +63,43 @@ 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 = ();
is .install(<unbuilt>, :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'";
is .state-of("unbuilt"), 'installed', "State after: 'installed'";

# [T] Install-ST an unbuilt project; build fails. Fail.
@actions = ();
is .install(<won't-build>, :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";
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(<unfetched>, :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'";
is .state-of("unfetched"), 'installed', "State after: 'installed'";

# [T] Install-ST an unfetched project; fetch fails. Fail.
@actions = ();
is .install(<won't-fetch>, :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";
is .state-of("won't-fetch"), 'gone', "State after: unchanged";

# [T] Install-ST an unfetched project; build fails. Fail.
@actions = ();
is .install(<won't-build-2>, :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'";
is .state-of("won't-build-2"), 'fetched', "State after: 'fetched'";

# [T] Install-ST a project with dependencies: Install-ST dependencies too.
@actions = ();
Expand All @@ -108,29 +108,29 @@ given $core {
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,
is .state-of("has-deps"), 'installed',
"State after of has-deps: 'installed'";
for <A B C D> -> $dep {
is .state-of($dep), installed, "State after of $dep: 'installed'";
is .state-of($dep), 'installed', "State after of $dep: 'installed'";
}

# [T] Install-ST a project with circular dependencies: Fail.
@actions = ();
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"), '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(<dirdep-fails>, :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,
is .state-of("won't-install"), 'built',
"State after of won't-install: unchanged";
is .state-of("dirdep-fails"), built,
is .state-of("dirdep-fails"), 'built',
"State after of dirdep-fails: unchanged";

# [T] Install-ST a project whose indirect dependency fails: Fail.
Expand All @@ -139,10 +139,10 @@ given $core {
"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";
is .state-of("won't-install"), 'built', "State after: unchanged";
for <F G H> -> $dep {
is .state-of($dep), built, "State after of $dep: unchanged";
is .state-of($dep), 'built', "State after of $dep: unchanged";
}
is .state-of("indir-fails"), built,
is .state-of("indir-fails"), 'built',
"State after of indir-fails: unchanged";
}
30 changes: 15 additions & 15 deletions t/subcommands/install-with-force.t
Expand Up @@ -54,14 +54,14 @@ 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 = ();
is .install(<won't-build>, :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";
is .state-of("won't-build"), 'fetched', "State after: unchanged";

# [T] Force install an unbuilt project; testing fails. Install anyway.
@actions = ();
Expand All @@ -70,22 +70,22 @@ given $core {
is ~@actions, "build[won't-test-2] test[won't-test-2] "
~ "install[won't-test-2]",
"Built, tested and installed";
is .state-of("won't-test-2"), installed, "State after: 'installed'";
is .state-of("won't-test-2"), 'installed', "State after: 'installed'";

# [T] Force install an unfetched project; fetch fails. Fail.
@actions = ();
is .install(<won't-fetch>, :force), 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";
is .state-of("won't-fetch"), 'gone', "State after: unchanged";

# [T] Force install an unfetched project; build fails. Fail.
@actions = ();
is .install(<won't-build-2>, :force), 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'";
is .state-of("won't-build-2"), 'fetched', "State after: 'fetched'";

# [T] Force install an unfetched project; testing fails. Install anyway.
@actions = ();
Expand All @@ -94,7 +94,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"), 'built', "State after: 'built'";

# [T] Force install a project with dependencies: Install dependencies too.
@actions = ();
Expand All @@ -104,19 +104,19 @@ given $core {
~ 'test[C] test[D] test[B] test[has-deps] '
~ 'install[C] install[D] install[B] install[has-deps]',
"fetch, build, test and install (all postorder and by need)";
is .state-of("has-deps"), installed,
is .state-of("has-deps"), 'installed',
"State after of has-deps: 'installed'";
for <A B C D> -> $dep {
is .state-of($dep), installed, "State after of $dep: 'installed'";
is .state-of($dep), 'installed', "State after of $dep: 'installed'";
}

# [T] Force install a project with circular dependencies: Fail.
@actions = ();
is .install(<circ-deps>, :force), 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"), 'tested', "State after of circ-deps: unchanged";
is .state-of("E"), 'tested', "State after of E: unchanged";

# [T] Froce install a project whose direct dependency fails:
# Install anyway.
Expand All @@ -125,9 +125,9 @@ given $core {
"Direct dependency fails but project itself succeds: succeed";
is ~@actions, "install[won't-install] install[dirdep-fails]",
"Install proceeds even after failure";
is .state-of("won't-install"), tested,
is .state-of("won't-install"), 'tested',
"State after of won't-install: unchanged";
is .state-of("dirdep-fails"), installed,
is .state-of("dirdep-fails"), 'installed',
"State after of dirdep-fails: 'installed'";

# [T] Force install a project whose indirect dependency fails:
Expand All @@ -138,10 +138,10 @@ given $core {
is ~@actions, "install[won't-install] install[G] install[H] install[F] "
~ "install[indir-fails]",
"Installation of all projects are made, though the first fails";
is .state-of("won't-install"), tested, "State after: unchanged";
is .state-of("won't-install"), 'tested', "State after: unchanged";
for <F G H> -> $dep {
is .state-of($dep), installed, "State after of $dep: 'installed'";
is .state-of($dep), 'installed', "State after of $dep: 'installed'";
}
is .state-of("indir-fails"), installed,
is .state-of("indir-fails"), 'installed',
"State after of indir-fails: 'installed'";
}

0 comments on commit 22f24b5

Please sign in to comment.