From 70319b54db0bf466004d7b7b4d2580985df250ca Mon Sep 17 00:00:00 2001 From: Kare Morstol Date: Fri, 16 Oct 2015 03:52:47 +0200 Subject: [PATCH] Update test scripts for SwiftShell 2.0. Finally. --- .../Scripts/callswiftscriptfromswift.swift | 2 +- .../Scripts/readandwritefiles.swift | 22 +++++++++---------- SwiftShellTests/Scripts/stream_out.swift | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/SwiftShellTests/Scripts/callswiftscriptfromswift.swift b/SwiftShellTests/Scripts/callswiftscriptfromswift.swift index 4381539..fec0ff5 100755 --- a/SwiftShellTests/Scripts/callswiftscriptfromswift.swift +++ b/SwiftShellTests/Scripts/callswiftscriptfromswift.swift @@ -2,4 +2,4 @@ import SwiftShell -run("cat onetwothree.txt") |> run("./print_linenumbers.swift") |>> standardoutput +try! run("cat","onetwothree.txt").runAndPrint("./print_linenumbers.swift") diff --git a/SwiftShellTests/Scripts/readandwritefiles.swift b/SwiftShellTests/Scripts/readandwritefiles.swift index 03a8982..15fe154 100755 --- a/SwiftShellTests/Scripts/readandwritefiles.swift +++ b/SwiftShellTests/Scripts/readandwritefiles.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'." ) } diff --git a/SwiftShellTests/Scripts/stream_out.swift b/SwiftShellTests/Scripts/stream_out.swift index 73f6493..a2563c8 100755 --- a/SwiftShellTests/Scripts/stream_out.swift +++ b/SwiftShellTests/Scripts/stream_out.swift @@ -2,4 +2,4 @@ import SwiftShell -run("echo this is streamed") |> run("wc -w") |>> standardoutput + try! run("echo","this is streamed").runAndPrint("wc", "-w")