github.com/tooploox/oya@v0.0.21-0.20230524103240-1cda1861aad6/features/run.feature (about) 1 Feature: Running tasks 2 3 Background: 4 Given I'm in project dir 5 6 Scenario: Successfully run task 7 Given file ./Oyafile containing 8 """ 9 Project: project 10 all: | 11 foo=4 12 if [ $foo -ge 3 ]; then 13 touch OK 14 fi 15 echo "Done" 16 """ 17 When I run "oya run all" 18 Then the command succeeds 19 And the command outputs 20 """ 21 Done 22 23 """ 24 And file ./OK exists 25 26 Scenario: Failing task's exit code propagates 27 Given file ./Oyafile containing 28 """ 29 Project: project 30 all: | 31 rm does_not_exist 32 """ 33 When I run "oya run all" 34 Then the command fails 35 And the command exit code is 1 36 37 Scenario: Exit code doesn't propagate from sub-expressions 38 Given file ./Oyafile containing 39 """ 40 Project: project 41 all: | 42 rm does_not_exist || echo "fail" 43 """ 44 When I run "oya run all" 45 Then the command succeeds 46 And the command outputs text matching 47 """ 48 rm:.*does_not_exist.*No such file or directory 49 fail 50 51 """ 52 53 Scenario: Last exit code is propagated 54 Given file ./Oyafile containing 55 """ 56 Project: project 57 all: | 58 rm does_not_exist 59 echo "fail" 60 """ 61 When I run "oya run all" 62 Then the command succeeds 63 And the command outputs text matching 64 """ 65 rm:.*does_not_exist.*No such file or directory 66 fail 67 68 """ 69 70 Scenario: Nested Oyafiles are not processed recursively by default 71 Given file ./Oyafile containing 72 """ 73 Project: project 74 all: | 75 touch Root 76 echo "Root" 77 """ 78 And file ./project1/Oyafile containing 79 """ 80 all: | 81 touch Project1 82 echo "Project1" 83 """ 84 And file ./project2/Oyafile containing 85 """ 86 all: | 87 touch Project2 88 echo "Project2" 89 """ 90 When I run "oya run all" 91 Then the command succeeds 92 And the command outputs 93 """ 94 Root 95 96 """ 97 And file ./Root exists 98 And file ./project1/Project1 does not exist 99 And file ./project2/Project2 does not exist 100 101 Scenario: Nested Oyafiles can be processed recursively 102 Given file ./Oyafile containing 103 """ 104 Project: project 105 all: | 106 touch Root 107 echo "Root" 108 """ 109 And file ./project1/Oyafile containing 110 """ 111 all: | 112 touch Project1 113 echo "Project1" 114 """ 115 And file ./project2/Oyafile containing 116 """ 117 all: | 118 touch Project2 119 echo "Project2" 120 """ 121 When I run "oya run --recurse all" 122 Then the command succeeds 123 And the command outputs 124 """ 125 Root 126 Project1 127 Project2 128 129 """ 130 And file ./Root exists 131 And file ./project1/Project1 exists 132 And file ./project2/Project2 exists 133 134 Scenario: No Oyafile 135 Given file ./NotOyafile containing 136 """ 137 Project: project 138 """ 139 When I run "oya run all" 140 Then the command fails with error matching 141 """ 142 .*no Oyafile project in.* 143 """ 144 145 Scenario: Missing task 146 Given file ./Oyafile containing 147 """ 148 Project: project 149 """ 150 When I run "oya run all" 151 Then the command fails with error 152 """ 153 missing task "all" 154 """ 155 156 Scenario: Script template 157 Given file ./Oyafile containing 158 """ 159 Project: project 160 Values: 161 value: some value 162 all: | 163 foo="${Oya[value]}" 164 echo $foo 165 """ 166 When I run "oya run all" 167 Then the command succeeds 168 And the command outputs 169 """ 170 some value 171 172 """ 173 174 Scenario: Ignore projects inside current project 175 Given file ./Oyafile containing 176 """ 177 Project: main 178 all: echo "main" 179 """ 180 And file ./foo/Oyafile containing 181 """ 182 Project: foo 183 all: echo "foo" 184 """ 185 When I run "oya run all" 186 Then the command succeeds 187 And the command outputs 188 """ 189 main 190 191 """ 192 193 Scenario: Ignore errors in projects inside current project 194 Given file ./Oyafile containing 195 """ 196 Project: main 197 all: echo "main" 198 """ 199 And file ./foo/Oyafile containing 200 """ 201 Project: foo 202 Import: 203 xxx: does not exist 204 all: echo "foo" 205 """ 206 When I run "oya run all" 207 Then the command succeeds 208 And the command outputs 209 """ 210 main 211 212 """ 213 214 @bug 215 Scenario: Running recursively 216 Given file ./Oyafile containing 217 """ 218 Project: project 219 all: | 220 touch Root 221 echo "Root" 222 """ 223 And file ./project1/Oyafile containing 224 """ 225 all: | 226 touch Project1 227 echo "Project1" 228 """ 229 And file ./project2/Oyafile containing 230 """ 231 all: | 232 touch Project2 233 echo "Project2" 234 """ 235 And I'm in the ./project1 dir 236 When I run "oya run --recurse all" 237 Then the command succeeds 238 And the command outputs 239 """ 240 Project1 241 242 """ 243 And file ./Root does not exist 244 And file ./project1/Project1 exists 245 And file ./project2/Project2 does not exist 246 247 Scenario: Running recursively 248 Given file ./Oyafile containing 249 """ 250 Project: project 251 all: | 252 touch Root 253 echo "Root" 254 """ 255 And file ./project1/Oyafile containing 256 """ 257 all: | 258 touch Project1 259 echo "Project1" 260 """ 261 And file ./project2/Oyafile containing 262 """ 263 all: | 264 touch Project2 265 echo "Project2" 266 """ 267 And I'm in the ./project1 dir 268 When I run "oya run --recurse all" 269 Then the command succeeds 270 And the command outputs 271 """ 272 Project1 273 274 """ 275 And file ./Root does not exist 276 And file ./project1/Project1 exists 277 And file ./project2/Project2 does not exist 278 279 Scenario: Running in a subdirectory 280 Given file ./Oyafile containing 281 """ 282 Project: project 283 all: | 284 echo "Root" 285 """ 286 And file ./project1/Oyafile containing 287 """ 288 all: | 289 echo "Project1" 290 """ 291 And I'm in the ./project1 dir 292 When I run "oya run all" 293 Then the command succeeds 294 And the command outputs 295 """ 296 Project1 297 298 """ 299 300 Scenario: Allow empty Require, Import: Values 301 Given file ./Oyafile containing 302 """ 303 Project: project 304 305 Require: 306 Import: 307 Values: 308 309 foo: | 310 echo "hello from foo" 311 """ 312 When I run "oya run foo" 313 Then the command succeeds 314 And the command outputs 315 """ 316 hello from foo 317 318 """ 319 320 Scenario: Task exits with non-zero code 321 Given file ./Oyafile containing 322 """ 323 Project: project 324 325 test: | 326 exit 27 327 """ 328 When I run "oya run test" 329 Then the command fails 330 And the command outputs text matching 331 """ 332 Error: exit status 27 333 334 at line 1, column 1 335 336 > 1\\| exit 27 337 338 """ 339 And the command exit code is 27 340 341 Scenario: Command in task exits with non-zero code 342 Given file ./Oyafile containing 343 """ 344 Project: project 345 346 test: | 347 bash -c 'exit 27' 348 echo "hello after exit 27" 349 """ 350 When I run "oya run test" 351 Then the command succeeds 352 And the command outputs 353 """ 354 hello after exit 27 355 356 """ 357 And the command exit code is 0 358 359 360 Scenario: Command in task exits with non-zero code when set -e is in effect 361 Given file ./Oyafile containing 362 """ 363 Project: project 364 365 test: | 366 set -e 367 bash -c 'exit 27' 368 echo "hello after exit 27" 369 """ 370 When I run "oya run test" 371 Then the command fails 372 And the command outputs text matching 373 """ 374 Error: exit status 27 375 376 at line 2, column 1 377 378 1\\| set -e 379 > 2\\| bash -c 'exit 27' 380 """ 381 And the command exit code is 27 382 383 # https://github.com/mvdan/sh/issues/404 384 Scenario: set -e behaves correctly in conditionals etc. 385 Given file ./Oyafile containing 386 """ 387 Project: project 388 389 test: | 390 set -e 391 aa=uu 392 if test "$aa" == ""; then 393 exit 1 394 fi 395 echo "hello after if" 396 """ 397 When I run "oya run test" 398 Then the command succeeds 399 And the command outputs text matching 400 """ 401 hello after if 402 403 """