github.com/tooploox/oya@v0.0.21-0.20230524103240-1cda1861aad6/features/autoscope.feature (about)

     1  Feature: Autoscope
     2  
     3  Background:
     4     Given I'm in project dir
     5  
     6  Scenario: Render uses the scope of the imported Oyafile by default
     7    Given file ./Oyafile containing
     8      """
     9      Project: project
    10  
    11      Require:
    12        github.com/test/foo: v0.0.1
    13  
    14      Import:
    15        foo: github.com/test/foo
    16  
    17      Values:
    18        fruit: apple
    19      """
    20    And file ./.oya/packs/github.com/test/foo@v0.0.1/Oyafile containing
    21      """
    22      Values:
    23        fruit: orange
    24  
    25      render: |
    26        set -e
    27        oya render ./templates/file.txt
    28      """
    29    And file ./templates/file.txt containing
    30      """
    31      <%= fruit %>
    32      """
    33    When I run "oya run foo.render"
    34    Then the command succeeds
    35    And file ./file.txt contains
    36    """
    37    orange
    38    """
    39  
    40  Scenario: Render uses the scope of the imported Oyafile even with nested imports
    41    Given file ./Oyafile containing
    42      """
    43      Project: project
    44  
    45      Require:
    46        github.com/test/foo: v0.0.1
    47  
    48      Import:
    49        foo: github.com/test/foo
    50  
    51      Values:
    52        fruit: apple
    53      """
    54    And file ./.oya/packs/github.com/test/foo@v0.0.1/Oyafile containing
    55      """
    56      Project: pack-foo
    57  
    58      Require:
    59        github.com/test/bar: v0.0.1
    60  
    61      Import:
    62        bar: github.com/test/bar
    63  
    64      Values:
    65        fruit: orange
    66      """
    67    And file ./.oya/packs/github.com/test/bar@v0.0.1/Oyafile containing
    68      """
    69      Project: pack-bar
    70  
    71      Values:
    72        fruit: pear
    73  
    74      render: |
    75        set -e
    76        oya render ./templates/file.txt
    77      """
    78    And file ./templates/file.txt containing
    79      """
    80      <%= fruit %>
    81      """
    82    When I run "oya run foo.bar.render"
    83    Then the command succeeds
    84    And file ./file.txt contains
    85    """
    86    pear
    87    """
    88  
    89  
    90  Scenario: Render can optionally use the scope of the importing Oyafile
    91    Given file ./Oyafile containing
    92      """
    93      Project: project
    94  
    95      Require:
    96        github.com/test/foo: v0.0.1
    97  
    98      Import:
    99        foo: github.com/test/foo
   100  
   101      Values:
   102        fruit: apple
   103      """
   104    And file ./.oya/packs/github.com/test/foo@v0.0.1/Oyafile containing
   105      """
   106      Values:
   107        fruit: orange
   108  
   109      render: |
   110        set -e
   111        oya render --auto-scope=false ./templates/file.txt
   112      """
   113    And file ./templates/file.txt containing
   114      """
   115      <%= fruit %>
   116      """
   117    When I run "oya run foo.render"
   118    Then the command succeeds
   119    And file ./file.txt contains
   120    """
   121    apple
   122    """
   123  
   124  Scenario: Tasks use the scope of the imported Oyafile to render values
   125    Given file ./Oyafile containing
   126      """
   127      Project: project
   128  
   129      Require:
   130        github.com/test/foo: v0.0.1
   131  
   132      Import:
   133        foo: github.com/test/foo
   134  
   135      Values:
   136        fruit: apple
   137      """
   138    And file ./.oya/packs/github.com/test/foo@v0.0.1/Oyafile containing
   139      """
   140      Values:
   141        fruit: orange
   142  
   143      bar:
   144         echo ${Oya[fruit]}
   145      """
   146    When I run "oya run foo.bar"
   147    Then the command succeeds
   148    And the command outputs
   149    """
   150    orange
   151  
   152    """
   153  
   154  Scenario: Tasks use the scope of the imported Oyafile to run other tasks
   155    Given file ./Oyafile containing
   156      """
   157      Project: project
   158  
   159      Require:
   160        github.com/test/foo: v0.0.1
   161  
   162      Import:
   163        foo: github.com/test/foo
   164  
   165      foo: |
   166        oya run foo.foo
   167      """
   168    And file ./.oya/packs/github.com/test/foo@v0.0.1/Oyafile containing
   169      """
   170      Project: pack-foo
   171  
   172      Require:
   173        github.com/test/bar: v0.0.1
   174  
   175      Import:
   176        bar: github.com/test/bar
   177  
   178      foo: |
   179        oya run bar.foo
   180      """
   181    And file ./.oya/packs/github.com/test/bar@v0.0.1/Oyafile containing
   182      """
   183      Project: pack-bar
   184  
   185      foo: |
   186        oya run bar
   187  
   188      bar: |
   189        echo "Success"
   190      """
   191    When I run "oya run foo"
   192    Then the command succeeds
   193    And the command outputs
   194    """
   195    Success
   196  
   197    """
   198  
   199  Scenario: Render called via nested oya runs uses the nested import's scope
   200    Given file ./Oyafile containing
   201      """
   202      Project: project
   203  
   204      Require:
   205        github.com/test/foo: v0.0.1
   206  
   207      Import:
   208        foo: github.com/test/foo
   209  
   210      Values:
   211        fruit: apple
   212  
   213      foo: |
   214        oya run foo.foo
   215      """
   216    And file ./.oya/packs/github.com/test/foo@v0.0.1/Oyafile containing
   217      """
   218      Project: pack-foo
   219  
   220      Require:
   221        github.com/test/bar: v0.0.1
   222  
   223      Import:
   224        bar: github.com/test/bar
   225  
   226      Values:
   227        fruit: orange
   228  
   229      foo: |
   230        oya run bar.foo
   231      """
   232    And file ./.oya/packs/github.com/test/bar@v0.0.1/Oyafile containing
   233      """
   234      Project: pack-bar
   235  
   236      Values:
   237        fruit: peach
   238  
   239      foo: |
   240        oya run bar
   241  
   242      bar: |
   243        set -e
   244        oya render ./templates/file.txt
   245      """
   246    And file ./templates/file.txt containing
   247      """
   248      <%= fruit %>
   249      """
   250    When I run "oya run foo"
   251    Then the command succeeds
   252    And file ./file.txt contains
   253    """
   254    peach
   255    """
   256  
   257  # BUG(bilus): Scenario: Tasks can optionally use the importing Oyafile scope to render values
   258  # BUG(bilus): Scenario: Tasks can optionally use the importing Oyafile scope to run other tasks