turtle-build 0.5.11

Ninja-compatible build system for high-level programming languages
Documentation
Feature: Rule statement

  Scenario: Run a rule without any input
    Given a file named "build.ninja" with:
      """
      rule hello
        command = echo hello

      build foo: hello

      """
    When I successfully run `turtle`
    Then the stdout should contain exactly "hello"

  Scenario: Run a rule with hyphens and dots in its name
    Given a file named "build.ninja" with:
      """
      rule hello-world.v1
        command = echo hello

      build foo: hello-world.v1

      """
    When I successfully run `turtle`
    Then the stdout should contain exactly "hello"

  Scenario: Fail to parse a rule without a command
    Given a file named "build.ninja" with:
      """
      rule hello
        description = hello

      build foo: hello

      """
    When I run `turtle`
    Then the exit status should not be 0

  Scenario: Use the last command when it is assigned more than once
    Given a file named "build.ninja" with:
      """
      rule hello
        command = echo first
        command = echo second

      build foo: hello

      """
    When I successfully run `turtle`
    Then the stdout should contain exactly "second"

  Scenario: Run a rule with an input
    Given a file named "build.ninja" with:
      """
      rule hello
        command = echo hello

      build foo: hello bar

      """
    And a file named "bar" with ""
    When I successfully run `turtle`
    Then the exit status should be 0

  Scenario: Fail to run a rule with a missing input
    Given a file named "build.ninja" with:
      """
      rule hello
        command = echo hello

      build foo: hello bar

      """
    When I run `turtle`
    Then the exit status should not be 0

  Scenario: Fail to run rules with a shared missing input
    Given a file named "build.ninja" with:
      """
      rule cp
        command = cp $in $out

      build foo: cp baz
      build bar: cp baz

      """
    When I run `turtle`
    Then the exit status should not be 0
    And the stderr should contain "baz"

  Scenario: Fail to run a rule with an input under a regular file
    Given a file named "build.ninja" with:
      """
      rule cp
        command = cp $in $out

      build foo: cp bar/baz

      """
    And a file named "bar" with ""
    When I run `turtle`
    Then the exit status should not be 0
    And the stderr should contain "bar/baz"

  Scenario: Run a rule with an input variable
    Given a file named "build.ninja" with:
      """
      rule echo
        command = echo $in

      build foo: echo bar

      """
    And a file named "bar" with ""
    When I successfully run `turtle`
    Then the stdout should contain exactly "bar"

  Scenario: Run a rule with a newline-separated input variable
    Given a file named "build.ninja" with:
      """
      rule echo
        command = echo '$in_newline'

      build foo: echo bar baz | qux || quux

      """
    And a file named "bar" with ""
    And a file named "baz" with ""
    And a file named "qux" with ""
    And a file named "quux" with ""
    When I successfully run `turtle`
    Then the stdout should contain exactly:
      """
      bar
      baz
      """

  Scenario: Run a rule with an output variable
    Given a file named "build.ninja" with:
      """
      rule echo
        command = echo $out

      build foo: echo bar

      """
    And a file named "bar" with ""
    When I successfully run `turtle`
    Then the stdout should contain exactly "foo"

  Scenario: Run a rule with a custom variable
    Given a file named "build.ninja" with:
      """
      rule echo
        command = echo $x

      build foo: echo
        x = hello

      """
    And a file named "bar" with ""
    When I successfully run `turtle`
    Then the stdout should contain exactly "hello"

  Scenario: Run a rule with two custom variables
    Given a file named "build.ninja" with:
      """
      rule echo
        command = echo $x $y

      build foo: echo
        x = hello
        y = world

      """
    And a file named "bar" with ""
    When I successfully run `turtle`
    Then the stdout should contain exactly "hello world"

  Scenario: Run a command declared in a build statement
    Given a file named "build.ninja" with:
      """
      rule echo
        command = echo rule

      build foo: echo
        command = echo build

      """
    When I successfully run `turtle`
    Then the stdout should contain exactly "build"

  Scenario: Run a phony rule
    Given a file named "build.ninja" with:
      """
      rule touch
        command = touch $out

      build foo: touch
      build bar: phony foo

      default bar

      """
    When I successfully run `turtle`
    Then the file named "foo" should exist

  Scenario: Use a phony dependency
    Given a file named "build.ninja" with:
      """
      rule touch
        command = touch $out

      build foo: touch
      build bar: phony foo
      build baz: touch bar

      default baz

      """
    When I successfully run `turtle`
    Then the file named "foo" should exist

  Scenario: Rebuild for a phony dependency
    Given a file named "build.ninja" with:
      """
      rule hello
        command = sh -c 'echo hello && touch $out'

      build foo: phony 
      build bar: hello foo

      default bar

      """
    When I successfully run `turtle`
    And I successfully run `turtle`
    Then the stdout should contain exactly:
      """
      hello
      hello
      """