1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602
|
(use-modules (ice-9 receive))
(load-from-path "env.scm")
(define cwd (getcwd))
(define *testdir* (build-filename (getcwd) "shell-tmp"))
;;; Setup/teardown directories/files needed by tests.
(define (test-setup)
(mkdir *testdir*)
(chdir *testdir*))
(define (test-teardown)
(chdir cwd)
(system* "rm" "-rf" *testdir*))
(define (shell-values args . shell-input)
(let* ((stdout-pipe (pipe))
(stdout-pipe-inport (car stdout-pipe))
(stdout-pipe-outport (cdr stdout-pipe))
(stderr-pipe (pipe))
(stderr-pipe-inport (car stderr-pipe))
(stderr-pipe-outport (cdr stderr-pipe))
(stdin-pipe (pipe))
(stdin-pipe-inport (car stdin-pipe))
(stdin-pipe-outport (cdr stdin-pipe))
(command (cons lepton-cli (cons "shell" args))))
(format (current-error-port)
"Test: ~A\nInput: ~A\n "
(string-join command)
(string-join shell-input "\n "'suffix))
(for-each (lambda (x) (display x stdin-pipe-outport)) shell-input)
(close-port stdin-pipe-outport)
(let ((exit-status
(status:exit-val
(with-output-to-port stdout-pipe-outport
(lambda ()
(with-error-to-port stderr-pipe-outport
(lambda ()
(with-input-from-port stdin-pipe-inport
(lambda ()
(apply system* command))))))))))
(close-port stdout-pipe-outport)
(close-port stderr-pipe-outport)
(let ((out-string (get-string-all stdout-pipe-inport))
(err-string (get-string-all stderr-pipe-inport)))
;; I don't want to close input ports since the pipes
;; should be garbage collected after use.
(format (current-error-port)
"Status: ~A\nStdout:\n~A\n\nStderr:\n~A\n\n"
exit-status
out-string
err-string)
(values exit-status out-string err-string)))))
;;; Launch 'lepton-cli shell' without arguments. The command
;;; takes a 'display' command from its <stdin>, executes it, and
;;; exits. We test that <stdout> contains the displayed string,
;;; and the command exits with success, i.e. its exit status is
;;; zero.
(test-begin "lepton-cli shell")
(let* ((scheme-code "(display \"LEPTON SHELL\") (exit)"))
(receive (<status> <stdout> <stderr>)
(shell-values '() scheme-code)
(test-eq EXIT_SUCCESS <status>)
(test-assert (string-contains <stdout> "LEPTON SHELL"))))
(test-end "lepton-cli shell")
;;; Test that directory specified by the -L option is added to
;;; Guile %load-path.
(test-begin "lepton-cli shell -L")
(receive (<status> <stdout> <stderr>)
(shell-values '("-L" "SOMEDIR")
"(display (car %load-path)) (exit)")
(test-eq EXIT_SUCCESS <status>)
(test-assert (string-contains <stdout> "SOMEDIR")))
(test-group-with-cleanup "group: lepton-cli shell -L"
(test-setup)
(let* ((moduledir (build-filename *testdir* "lepton"))
(loadfile (build-filename moduledir "filename")))
(mkdir moduledir)
(string->file "(define-module (lepton filename))
(define-public (myproc) (exit 7))"
loadfile)
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell"
"-L" *testdir*
"-c" "(use-modules (lepton filename)) (myproc)")
(test-eq 7 <status>)
(test-equal "" <stdout>)))
;; Clean up.
(test-teardown))
(test-end "lepton-cli shell -L")
(test-begin "lepton-cli shell -h")
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-h")
(test-eq EXIT_SUCCESS <status>)
(test-assert (string-contains <stdout> "Usage:"))
(test-assert (string-contains <stdout> "Shell for interactive processing of Lepton EDA data using Scheme.")))
(test-end "lepton-cli shell -h")
(test-begin "lepton-cli shell --help")
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "--help")
(test-eq EXIT_SUCCESS <status>)
(test-assert (string-contains <stdout> "Usage:"))
(test-assert (string-contains <stdout> "Shell for interactive processing of Lepton EDA data using Scheme.")))
(test-end "lepton-cli shell --help")
(test-begin "lepton-cli shell --version")
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "--version")
(test-eq EXIT_FAILURE <status>)
(test-equal "" <stdout>)
(test-assert (string-contains <stderr> "unrecognized option"))
(test-assert (string-contains <stderr> "--help' for more information.")))
(test-end "lepton-cli shell --version")
(test-begin "lepton-cli shell -c")
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-c" "(display 'x)")
(test-eq EXIT_SUCCESS <status>))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-c" "(exit 3)")
(test-eq 3 <status>))
;;; -h and --help take priority over -c, so the value returned in
;;; two cases below is 0 (success).
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-c" "(exit 3)" "-h")
(test-eq EXIT_SUCCESS <status>))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-c" "(exit 3)" "--help")
(test-eq EXIT_SUCCESS <status>))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-c")
(test-assert EXIT_FAILURE <status>)
(test-equal "" <stdout>)
(test-assert (string-contains <stderr> "require"))
(test-assert (string-contains <stderr> "argument"))
(test-assert (string-contains <stderr> "Run `lepton-shell --help' for more information.")))
(test-end "lepton-cli shell -c")
(test-begin "lepton-cli shell -s")
(test-group-with-cleanup "group: lepton-cli shell -s"
(test-setup)
(let ((filename (string->file "(exit 4)"
(build-filename *testdir* "anyfile.scm"))))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-s" filename)
(test-eq 4 <status>)))
;; Clean up.
(test-teardown))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-s")
(test-eq EXIT_FAILURE <status>)
(test-equal "" <stdout>)
(test-assert (string-contains <stderr> "require"))
(test-assert (string-contains <stderr> "argument"))
(test-assert (string-contains <stderr> "Run `lepton-shell --help' for more information.")))
(test-end "lepton-cli shell -s")
(test-begin "lepton-cli shell -c -l -s")
(test-group-with-cleanup "group: lepton-cli shell -c -l -s"
(test-setup)
;; -c, -l, and -s are of the same priority so the first one
;; option in the command line will define the result.
(let ((l-filename (string->file "(exit 2)"
(build-filename *testdir* "l.scm")))
(s-filename (string->file "(exit 4)"
(build-filename *testdir* "s.scm"))))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-s" s-filename "-c" "(exit 3)")
(test-eq 4 <status>))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-s" s-filename "-l" l-filename)
(test-eq 4 <status>))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-l" l-filename "-c" "(exit 3)")
(test-eq 2 <status>))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-l" l-filename "-s" s-filename)
(test-eq 2 <status>))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-c" "(exit 3)" "-s" s-filename)
(test-eq 3 <status>))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-c" "(exit 3)" "-l" l-filename)
(test-eq 3 <status>)))
;; Clean up.
(test-teardown))
(test-end "lepton-cli shell -c -l -s")
(test-begin "lepton-cli shell toplevel")
(test-group-with-cleanup "group: lepton-cli shell toplevel"
(test-setup)
(let* ((scheme-code "(use-modules (lepton toplevel)) (display (%current-toplevel))")
(scheme-code-w-exit (string-append scheme-code "(exit)"))
(scheme-filename (string->file scheme-code-w-exit
(build-filename *testdir* "file.scm"))))
(receive (<status> <stdout> <stderr>)
(shell-values '() scheme-code-w-exit)
(test-assert (string-contains <stdout> "geda-toplevel")))
(receive (<status> <stdout> <stderr>)
(shell-values '("-L" "\"non-existing-dir\"") scheme-code-w-exit)
(test-assert (string-contains <stdout> "geda-toplevel")))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-l" scheme-filename)
(test-assert (string-contains <stdout> "geda-toplevel")))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-s" scheme-filename)
(test-eq EXIT_SUCCESS <status>)
(test-assert (string-contains <stdout> "geda-toplevel")))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-c" scheme-code)
(test-eq EXIT_SUCCESS <status>)
(test-assert (string-contains <stdout> "geda-toplevel"))))
;; Clean up.
(test-teardown))
(test-end "lepton-cli shell toplevel")
(test-begin "lepton-cli shell -c command")
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-c" "(write (command-line))")
(test-equal <stdout>
(format #f "(~S ~S ~S)" lepton-shell "-c" "(write (command-line))")))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-c" "(write (command-line))"
"a" "-l" "b" "--" "c" "d")
(test-equal <stdout>
(format #f "(~S ~S ~S ~S ~S ~S ~S ~S ~S)"
lepton-shell "-c" "(write (command-line))" "a" "-l" "b" "--" "c" "d")))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-L" "dir" "-c" "(write (command-line))"
"a" "-s" "b")
(test-equal <stdout>
(format #f "(~S ~S ~S ~S ~S ~S ~S ~S)"
lepton-shell "-L" "dir" "-c" "(write (command-line))" "a" "-s" "b")))
(test-end "lepton-cli shell -c command")
(test-begin "lepton-cli shell -s filename")
(test-group-with-cleanup "group: lepton-cli shell -s filename"
(test-setup)
(let ((scheme-filename (string->file "(write (command-line)) (exit 20)"
(build-filename *testdir*
"filename.scm"))))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-s" scheme-filename)
(test-equal 20 <status>)
(test-equal <stdout>
(format #f "(~S ~S ~S)" lepton-shell "-s" scheme-filename)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-s" scheme-filename
"a" "-l" "b" "--" "c" "d")
(test-equal 20 <status>)
(test-equal <stdout>
(format #f "(~S ~S ~S ~S ~S ~S ~S ~S ~S)"
lepton-shell "-s" scheme-filename "a" "-l" "b" "--" "c" "d")))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-L" "dir" "-s" scheme-filename
"a" "-s" "b")
(test-equal 20 <status>)
(test-equal <stdout>
(format #f "(~S ~S ~S ~S ~S ~S ~S ~S)"
lepton-shell "-L" "dir" "-s" scheme-filename "a" "-s" "b"))))
;; Clean up.
(test-teardown))
(test-end "lepton-cli shell -s filename")
(test-begin "lepton-cli shell -- -s filename")
(test-group-with-cleanup "lepton-cli shell -- -s filename"
(test-setup)
(let* ((contents "(write (command-line)) (exit 21)")
(scheme-filename (string->file contents
(build-filename *testdir*
"filename.scm"))))
(receive (<status> <stdout> <stderr>)
(shell-values (list "--" "-s" scheme-filename) contents)
;; '-s' after '--' is considered a filename, thus the error here.
(test-eq EXIT_FAILURE <status>)
(test-assert (string-contains <stderr> "ERROR: Could not load file"))
(test-assert (string-contains <stderr> "\"-s\"")))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "--" "shell" "-s" scheme-filename)
(test-eq EXIT_FAILURE <status>)
(test-assert (string-contains <stderr> "ERROR: You must specify a command to run.")))
;; This works differently if I use 'guile' instead of
;; 'lepton-cli'. Guile correctly interprets anything after "--"
;; as file names and, since file "-s" is missing, enters shell.
;; Cli does not, since the first argument must be command
;; (e.g. "shell") which is missing in this case, and toplevel
;; 'lepton-cli' code is interpreted which does not know the
;; command '-s'.
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "--" "-s" scheme-filename)
(test-eq EXIT_FAILURE <status>)
(test-assert (string-contains <stderr> "ERROR: You must specify a command to run."))))
;; Clean up.
(test-teardown))
(test-end "lepton-cli shell -- -s filename")
(test-begin "lepton-cli shell -c args")
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-c" "(write (command-line))" "arg1" "arg2" "arg3")
(test-equal <stdout>
(format #f "(~S ~S ~S ~S ~S ~S)"
lepton-shell "-c" "(write (command-line))" "arg1" "arg2" "arg3")))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-c" "(write (command-line))" "arg1" "arg2" "arg3" "-l" "/tmp/x")
(test-equal <stdout>
(format #f "(~S ~S ~S ~S ~S ~S ~S ~S)"
lepton-shell "-c" "(write (command-line))" "arg1" "arg2" "arg3" "-l" "/tmp/x")))
(test-end "lepton-cli shell -c args")
(test-begin "lepton-cli shell --")
(receive (<status> <stdout> <stderr>)
(shell-values '("--")
"(write (command-line))"
"(exit)")
(test-assert (string-contains <stdout> lepton-shell))
(test-assert (string-contains <stdout> "\"--\"")))
(receive (<status> <stdout> <stderr>)
(shell-values '("--" "x" "y" "z")
"(write (command-line))"
"(exit)")
;; As there is no files mentioned on command line, lepton-shell
;; exits with error.
(test-eq EXIT_FAILURE <status>)
(test-assert (string-contains <stderr> "ERROR: Could not load file"))
(test-assert (string-contains <stderr> "\"x\"")))
(test-end "lepton-cli shell --")
(test-begin "lepton-cli shell -c --help")
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-h" "-c" "(display 'anything)")
(test-eq EXIT_SUCCESS <status>)
(test-assert (string-contains <stdout> "Usage:")))
;;; Unlike guile, "lepton-cli shell" outputs help here, too,
;;; because the '-h' option has priority over other options.
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-c" "(display 'anything)" "--help")
(test-eq EXIT_SUCCESS <status>)
(test-assert (string-contains <stdout> "Usage:")))
(test-end "lepton-cli shell -c --help")
(test-begin "lepton-cli shell -c command -- a b c")
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-c" "(write (command-line))" "--" "a" "b" "c")
(test-equal <stdout>
(format #f "(~S ~S ~S ~S ~S ~S ~S)"
lepton-shell "-c" "(write (command-line))" "--" "a" "b" "c")))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-c" "(write (command-line))" "-s" "foo.scm" "--" "a" "b" "c")
(test-equal <stdout>
(format #f "(~S ~S ~S ~S ~S ~S ~S ~S ~S)"
lepton-shell "-c" "(write (command-line))" "-s" "foo.scm" "--" "a" "b" "c")))
(test-end "lepton-cli shell -c command -- a b c")
(test-begin "lepton-cli shell file arguments")
(test-group-with-cleanup "lepton-cli shell file arguments"
(test-setup)
(let ((x (build-filename *testdir* "x.scm"))
(y (build-filename *testdir* "y.scm"))
;; Directory.
(z (build-filename *testdir* "z")))
;; No x and y/z file exist.
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" x "-c" "(write (command-line)) (exit 100)")
(test-eq EXIT_FAILURE <status>)
(test-equal "" <stdout>)
(test-assert (string-contains <stderr> "ERROR: Could not load file"))
(test-assert (string-contains <stderr> x)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" x y)
(test-eq EXIT_FAILURE <status>)
(test-equal "" <stdout>)
(test-assert (string-contains <stderr> "ERROR: Could not load file"))
(test-assert (string-contains <stderr> x)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" x "-s" y)
(test-eq EXIT_FAILURE <status>)
(test-equal "" <stdout>)
(test-assert (string-contains <stderr> "ERROR: Could not load file"))
(test-assert (string-contains <stderr> x)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" x "-l" y)
(test-eq EXIT_FAILURE <status>)
(test-equal "" <stdout>)
(test-assert (string-contains <stderr> "ERROR: Could not load file"))
(test-assert (string-contains <stderr> x)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-l" y x)
(test-eq EXIT_FAILURE <status>)
(test-equal "" <stdout>)
(test-assert (string-contains <stderr> "ERROR: Could not load file"))
(test-assert (string-contains <stderr> y)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" x "-L" z)
(test-eq EXIT_FAILURE <status>)
(test-equal "" <stdout>)
(test-assert (string-contains <stderr> "ERROR: Could not load file"))
(test-assert (string-contains <stderr> x)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-L" z x)
(test-eq EXIT_FAILURE <status>)
(test-equal "" <stdout>)
(test-assert (string-contains <stderr> "ERROR: Could not load file"))
(test-assert (string-contains <stderr> x)))
;; No x file, y/z exists.
(let ((y (string->file "(write (command-line))" y)))
(mkdir z)
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" x y)
(test-eq EXIT_FAILURE <status>)
(test-equal "" <stdout>)
(test-assert (string-contains <stderr> "ERROR: Could not load file"))
(test-assert (string-contains <stderr> x)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" x "-s" y)
(test-eq EXIT_FAILURE <status>)
(test-equal "" <stdout>)
(test-assert (string-contains <stderr> "ERROR: Could not load file"))
(test-assert (string-contains <stderr> x)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" x "-l" y)
(test-eq EXIT_FAILURE <status>)
(test-equal "" <stdout>)
(test-assert (string-contains <stderr> "ERROR: Could not load file"))
(test-assert (string-contains <stderr> x)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-l" y x)
(test-eq EXIT_FAILURE <status>)
(test-equal <stdout> (format #f "(~S ~S ~S ~S)" lepton-shell "-l" y x))
(test-assert (string-contains <stderr> "ERROR: Could not load file"))
(test-assert (string-contains <stderr> x)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" x "-L" z)
(test-eq EXIT_FAILURE <status>)
(test-equal "" <stdout>)
(test-assert (string-contains <stderr> "ERROR: Could not load file"))
(test-assert (string-contains <stderr> x)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-L" z x)
(test-eq EXIT_FAILURE <status>)
(test-equal "" <stdout>)
(test-assert (string-contains <stderr> "ERROR: Could not load file"))
(test-assert (string-contains <stderr> x)))
;; Both x and y/z exist.
(let ((x (string->file "(write (command-line)) (exit 100)" x)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" x y)
(test-eq 100 <status>)
(test-equal <stdout> (format #f "(~S ~S ~S)" lepton-shell x y)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" x "-s" y)
(test-eq 100 <status>)
(test-equal <stdout> (format #f "(~S ~S ~S ~S)" lepton-shell x "-s" y)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" x "-l" y)
(test-eq 100 <status>)
(test-equal <stdout> (format #f "(~S ~S ~S ~S)" lepton-shell x "-l" y)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-l" y x)
(test-eq 100 <status>)
(test-equal <stdout>
(format #f "(~S ~S ~S ~S)(~S ~S ~S ~S)" lepton-shell "-l" y x lepton-shell "-l" y x)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" x "-L" z)
(test-eq 100 <status>)
(test-equal <stdout> (format #f "(~S ~S ~S ~S)" lepton-shell x "-L" z)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-L" z x)
(test-eq 100 <status>)
(test-equal <stdout> (format #f "(~S ~S ~S ~S)" lepton-shell "-L" z x)))
(delete-file y)
(rmdir z)
;; x exists, no y/z file.
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" x y)
(test-eq 100 <status>)
(test-equal <stdout> (format #f "(~S ~S ~S)" lepton-shell x y)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" x "-s" y)
(test-eq 100 <status>)
(test-equal <stdout> (format #f "(~S ~S ~S ~S)" lepton-shell x "-s" y)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" x "-l" y)
(test-eq 100 <status>)
(test-equal <stdout> (format #f "(~S ~S ~S ~S)" lepton-shell x "-l" y)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-l" y x)
(test-eq EXIT_FAILURE <status>)
(test-equal "" <stdout>)
(test-assert (string-contains <stderr> "ERROR: Could not load file"))
(test-assert (string-contains <stderr> y)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" x "-L" z)
(test-eq 100 <status>)
(test-equal <stdout> (format #f "(~S ~S ~S ~S)" lepton-shell x "-L" z)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" "-L" z x)
(test-eq 100 <status>)
(test-equal <stdout> (format #f "(~S ~S ~S ~S)" lepton-shell "-L" z x)))
(receive (<status> <stdout> <stderr>)
(command-values lepton-cli "shell" x "-c" "(exit 100)")
(test-eq 100 <status>)
(test-equal <stdout> (format #f "(~S ~S ~S ~S)" lepton-shell x "-c" "(exit 100)")))
)))
;; Clean up.
(test-teardown))
(test-end "lepton-cli shell file arguments")
|