github.com/NeowayLabs/nash@v0.2.2-0.20200127205349-a227041ffd50/stdbin/write/write_linux_test.sh (about)

     1  # linux tests of write command
     2  
     3  import "./common_test.sh"
     4  
     5  # this test uses only the write binary
     6  setenv PATH = "./stdbin/write"
     7  
     8  # (desc (out err status))
     9  var tests = (
    10      ("standard out" ("/dev/stdout" "hello world" "" "0"))
    11      ("standard err" ("/dev/stderr" "" "hello world" "0"))
    12  )
    13  
    14  var outstr = "hello world"
    15  
    16  for test in $tests {
    17      var desc = $test[0]
    18      var tc = $test[1]
    19  
    20      print("testing %s\n", $desc)
    21  
    22      var device = $tc[0]
    23      var expectedOut = $tc[1]
    24      var expectedErr = $tc[2]
    25      var expectedSts = $tc[3]
    26  
    27      var out, err, status <= write $device $outstr
    28      assert($expectedSts, $status, "status code")
    29      assert($expectedOut, $out, "standard output")
    30      assert($expectedErr, $err, "standard error")
    31  }