From 501f9fee97aee04308fd2f92cf5624599b09cd24 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Mon, 23 Sep 2019 07:53:24 -0400 Subject: [PATCH] yeezy taught me --- tests/args.bats | 9 ++++++--- tests/basics.bats | 28 +++++++++++++++------------- tests/cache.bats | 11 +++++++---- tests/confirm.bats | 4 +++- tests/env.bats | 8 +++++--- tests/python.bats | 4 +++- 6 files changed, 39 insertions(+), 25 deletions(-) diff --git a/tests/args.bats b/tests/args.bats index 5d550db..17afd92 100755 --- a/tests/args.bats +++ b/tests/args.bats @@ -1,15 +1,18 @@ +#!/usr/bin/env bats +export BAKEFILE=args.Bakefile + @test "arguments don't work (set -u)" { - run bake -b args.Bakefile argv + run bake argv [ "${status}" -eq 1 ] } @test "arguments do work [argv]" { - run bake --silent -b args.Bakefile argv 1 2 KEY=VALUE 3 + run bake --silent argv 1 2 KEY=VALUE 3 [[ "${lines[0]}" == *"1 2 3"* ]] } @test "arguments do work [environ]" { - run bake --silent -b args.Bakefile argv 1 2 KEY=VALUE 3 + run bake --silent argv 1 2 KEY=VALUE 3 [[ "${lines[1]}" == *"VALUE"* ]] } diff --git a/tests/basics.bats b/tests/basics.bats index 7c1293f..321c739 100755 --- a/tests/basics.bats +++ b/tests/basics.bats @@ -1,58 +1,60 @@ #!/usr/bin/env bats +export BAKEFILE=basics.Bakefile + @test "bake --h" { - run bake -b basics.Bakefile --help + run bake --help [ "${lines[0]}" = "Usage: [OPTIONS] [TASK] [ARGUMENTS]..." ] } @test "bake --help" { - run bake -b basics.Bakefile --help + run bake --help [ "${lines[0]}" = "Usage: [OPTIONS] [TASK] [ARGUMENTS]..." ] } @test "bake --json" { - run bake -b basics.Bakefile --json + run bake --json [ "${#lines[@]}" -eq 23 ] } @test "bake --json --levels 0" { - run bake -b basics.Bakefile --json --levels 0 + run bake --json --levels 0 [ "${#lines[@]}" -eq 3 ] } @test "bake --levels 0" { - run bake -b basics.Bakefile --levels 0 + run bake --levels 0 [ "${lines[0]}" = "" ] } @test "bake --levels 1" { - run bake -b basics.Bakefile --levels 1 + run bake --levels 1 [ "${#lines[@]}" -eq 4 ] } @test "bake --levels 2" { - run bake -b basics.Bakefile --levels 3 + run bake --levels 3 [ "${#lines[@]}" -eq 10 ] } @test "bake --levels 3" { - run bake -b basics.Bakefile --levels 3 + run bake --levels 3 [ "${#lines[@]}" -eq 10 ] } @test "bake --levels 4" { - run bake -b basics.Bakefile --levels 4 + run bake --levels 4 [ "${#lines[@]}" -eq 10 ] } @test "bake fails on 'exit 1'" { - run bake -b basics.Bakefile fail + run bake fail [ "${status}" -eq 1 ] } @test "bake fails on sub–task 'exit 1'" { - run bake -b basics.Bakefile deps/fail + run bake deps/fail [ "${status}" -eq 1 ] } @@ -62,11 +64,11 @@ } @test "bake runs sub-tasks" { - run bake -b basics.Bakefile echo/dep + run bake echo/dep [ "${status}" -eq 0 ] } @test "bake --no-deps" { - run bake -b basics.Bakefile deps/fail --no-deps + run bake deps/fail --no-deps [ "${status}" -eq 0 ] } diff --git a/tests/cache.bats b/tests/cache.bats index 9413421..dd1e1bc 100755 --- a/tests/cache.bats +++ b/tests/cache.bats @@ -1,19 +1,22 @@ +#!/usr/bin/env bats + +export BAKEFILE=cache.Bakefile @test "skips clear" { - bake -b cache.Bakefile --clear-skips + bake --clear-skips } @test "cache runs" { - run bake -b cache.Bakefile task + run bake task [[ $output != *Skipping* ]] } @test "cache skips" { - run bake -b cache.Bakefile task + run bake task [[ $output == *Skipping* ]] } @test "skip skips" { - run bake -b cache.Bakefile --no-deps task + run bake --no-deps task [[ $output != *Skipping* ]] } diff --git a/tests/confirm.bats b/tests/confirm.bats index 7728e38..dbe4d32 100755 --- a/tests/confirm.bats +++ b/tests/confirm.bats @@ -1,3 +1,5 @@ +#!/usr/bin/env bats +export BAKEFILE=confirm.Bakefile source ./_common.sh @test "confirm works" { @@ -5,7 +7,7 @@ source ./_common.sh } @test "confirm --yes works" { - bake -b confirm.Bakefile secure --yes + bake secure --yes } @test "confirm:secure works" { diff --git a/tests/env.bats b/tests/env.bats index 70d8329..86f1a8d 100755 --- a/tests/env.bats +++ b/tests/env.bats @@ -1,19 +1,21 @@ +#!/usr/bin/env bats +export BAKEFILE=env.Bakefile export HELLO=WORLD @test "env cache clear" { - bake -b env.Bakefile --clear-envs env + bake --clear-envs env } @test "removal of environment untrusted variables" { - run bake -b env.Bakefile env + run bake env [[ "${output}" != *HELLO=WORLD* ]] } @test "allowance of environment untrusted variables" { run bake --allow HELLO - run bake -b env.Bakefile env + run bake env [[ "${output}" == *"WORLD"* ]] } diff --git a/tests/python.bats b/tests/python.bats index ea1576e..8e36da9 100755 --- a/tests/python.bats +++ b/tests/python.bats @@ -1,4 +1,6 @@ +#!/usr/bin/env bats +export BAKEFILE=python.Bakefile @test "python" { - run bake --silent -b python.Bakefile python + run bake --silent python [[ "${lines[0]}" == "not bash" ]] }