Update test scripts for SwiftShell 2.0.
Finally.
This commit is contained in:
@@ -2,4 +2,4 @@
|
||||
|
||||
import SwiftShell
|
||||
|
||||
run("cat onetwothree.txt") |> run("./print_linenumbers.swift") |>> standardoutput
|
||||
try! run("cat","onetwothree.txt").runAndPrint("./print_linenumbers.swift")
|
||||
|
||||
@@ -2,31 +2,31 @@
|
||||
|
||||
import SwiftShell
|
||||
|
||||
let filepath = tempdirectory / "newfile.txt"
|
||||
let filepath = main.tempdirectory + "/newfile.txt"
|
||||
|
||||
// File doesn't exist. Create it.
|
||||
let file1 = open(forWriting: filepath )
|
||||
let file1 = try! open(forWriting: filepath)
|
||||
file1.writeln("line 1")
|
||||
file1.closeStream()
|
||||
file1.close()
|
||||
|
||||
// File does exist. Append it.
|
||||
let file2 = open(forWriting: filepath)
|
||||
let file2 = try! open(forWriting: filepath)
|
||||
file2.writeln("line 2")
|
||||
file2.closeStream()
|
||||
file2.close()
|
||||
|
||||
// Test file.
|
||||
let file3 = open(filepath)
|
||||
let file3 = try! open(filepath)
|
||||
if file3.read() != "line 1\nline 2\n" {
|
||||
printErrorAndExit( "newfile.txt should contain 'line 1\\n line 2\\n'." )
|
||||
exit(errormessage: "newfile.txt should contain 'line 1\\n line 2\\n'." )
|
||||
}
|
||||
|
||||
// File exists. Overwrite it.
|
||||
let file4 = open(forWriting: filepath, overwrite: true)
|
||||
let file4 = try! open(forWriting: filepath, overwrite: true)
|
||||
file4.write("file now contains only this")
|
||||
file4.closeStream()
|
||||
file4.close()
|
||||
|
||||
// Test file.
|
||||
let file5 = open(filepath)
|
||||
let file5 = try! open(filepath)
|
||||
if file5.read() != "file now contains only this" {
|
||||
printErrorAndExit( "newfile.txt should contain 'file now contains only this'." )
|
||||
exit(errormessage: "newfile.txt should contain 'file now contains only this'." )
|
||||
}
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
import SwiftShell
|
||||
|
||||
run("echo this is streamed") |> run("wc -w") |>> standardoutput
|
||||
try! run("echo","this is streamed").runAndPrint("wc", "-w")
|
||||
|
||||
Reference in New Issue
Block a user