Skip to content

Commit ce20956

Browse files
committed
try to fix line breaks
1 parent 36b4718 commit ce20956

File tree

1 file changed

+52
-28
lines changed

1 file changed

+52
-28
lines changed

src/test/Test.FAKECore/FSIHelperSpecs.cs

+52-28
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Test.FAKECore
1010
{
1111
public class when_running_script
1212
{
13-
13+
1414
static string RunExplicit(string scriptFilePath, string arguments, bool useCache)
1515
{
1616
var stdOut = Console.Out;
@@ -19,8 +19,10 @@ static string RunExplicit(string scriptFilePath, string arguments, bool useCache
1919
var outStream = new StringWriter(sbOut);
2020
Console.SetOut(outStream);
2121
Tuple<bool, Microsoft.FSharp.Collections.FSharpList<ProcessHelper.ConsoleMessage>> result;
22+
2223
try
2324
{
25+
2426
result = FSIHelper.executeBuildScriptWithArgsAndReturnMessages(scriptFilePath, new string[] { }, useCache, false);
2527
}
2628
finally
@@ -40,10 +42,14 @@ static string RunExplicit(string scriptFilePath, string arguments, bool useCache
4042
Console.WriteLine(x.Message);
4143
}
4244
var messages = result.Item2.Where(x => !x.IsError).Select(x => x.Message);
43-
return sbOut.ToString();
45+
return
46+
sbOut.ToString()
47+
.Replace("Running Buildscript: " + scriptFilePath, "")
48+
.Replace("\n", "").Replace("\r", "");
4449
}
4550

46-
static string Run(string script, string arguments, bool useCache) {
51+
static string Run(string script, string arguments, bool useCache)
52+
{
4753
var scriptFilePath = Path.GetTempFileName() + ".fsx";
4854
string result;
4955
try
@@ -55,12 +61,14 @@ static string Run(string script, string arguments, bool useCache) {
5561
{
5662
File.Delete(scriptFilePath);
5763
}
58-
64+
5965
return result;
6066
}
6167

6268
static string nl = System.Environment.NewLine;
63-
static Tuple<string, string> sc(string path, string contents) {
69+
70+
static Tuple<string, string> sc(string path, string contents)
71+
{
6472
return new Tuple<string, string>(path.Replace("\\", "/"), contents);
6573
}
6674

@@ -73,32 +81,44 @@ static Tuple<string, string> sc(string path, string contents) {
7381
try
7482
{
7583
File.WriteAllText(scriptFilePath, "printf \"foobar\"");
76-
var scriptHash = FSIHelper.getScriptHash(new Tuple<string,string>[] { sc(scriptFilePath, "printf \"foobar\"") });
77-
var cacheFilePath = "./.fake/" + scriptFileName + "_" + scriptHash + ".dll";
84+
var scriptHash =
85+
FSIHelper.getScriptHash(new Tuple<string, string>[] { sc(scriptFilePath, "printf \"foobar\"") });
86+
87+
var cacheFilePath = Path.Combine(".", ".fake", scriptFileName + "_" + scriptHash + ".dll");
7888

7989
File.Exists(cacheFilePath).ShouldEqual(false);
8090

81-
RunExplicit(scriptFilePath, arguments, false).ShouldEqual("foobar");
91+
RunExplicit(scriptFilePath, arguments, false)
92+
.ShouldEqual("foobar");
93+
8294
File.Exists(cacheFilePath).ShouldEqual(false);
8395

84-
RunExplicit(scriptFilePath, arguments, true).ShouldEqual(
85-
"Cache doesnt exist" + nl + "foobar" + nl + "Saved cache" + nl);
96+
RunExplicit(scriptFilePath, arguments, true)
97+
.ShouldEqual(
98+
("Cache doesnt exist" + nl + "foobar" + nl + "Saved cache" + nl)
99+
.Replace("\n", "").Replace("\r", ""));
100+
86101
File.Exists(cacheFilePath).ShouldEqual(true);
87102

88-
RunExplicit(scriptFilePath, arguments, true).ShouldEqual("Using cache" + nl + "foobar");
103+
RunExplicit(scriptFilePath, arguments, true)
104+
.ShouldEqual(
105+
("Using cache" + nl + "foobar")
106+
.Replace("\n", "").Replace("\r", ""));
89107

90108
File.WriteAllText(scriptFilePath, "printf \"foobarbaz\"");
91109

92110
var changedScriptHash = FSIHelper.getScriptHash(new Tuple<string, string>[] { sc(scriptFilePath, "printf \"foobarbaz\"") });
93-
RunExplicit(scriptFilePath, arguments, true).ShouldEqual("Cache is invalid, recompiling" + nl + "foobarbaz" + nl + "Saved cache" + nl);
94-
//File.Exists(cacheFilePath).ShouldEqual(false);
95-
File.Exists("./.fake/" + scriptFileName + "_" + changedScriptHash + ".dll").ShouldEqual(true);
111+
RunExplicit(scriptFilePath, arguments, true)
112+
.ShouldEqual(
113+
("Cache is invalid, recompiling" + nl + "foobarbaz" + nl + "Saved cache" + nl)
114+
.Replace("\n", "").Replace("\r", ""));
96115

116+
File.Exists("./.fake/" + scriptFileName + "_" + changedScriptHash + ".dll").ShouldEqual(true);
97117
}
98118
finally
99119
{
100-
if (File.Exists(scriptFilePath)) File.Delete(scriptFilePath);
101-
//if (Directory.Exists("./.fake")) Directory.Delete("./.fake");
120+
if (File.Exists(scriptFilePath))
121+
File.Delete(scriptFilePath);
102122
}
103123
};
104124

@@ -109,19 +129,23 @@ static Tuple<string, string> sc(string path, string contents) {
109129
var loadedPath = Path.GetTempFileName() + ".fsx";
110130
try
111131
{
112-
var mainScript = "printf \"main\"\n#load \"" + loadedPath.ToString().Replace("\\", "/") + "\"";
132+
var mainScript =
133+
"printf \"main\"\n#load \"" +
134+
loadedPath.ToString().Replace("\\", "/") + "\"";
113135
var loadedScript = "printf \"loaded;\"";
114-
File.WriteAllText(mainPath, mainScript);
115-
File.WriteAllText(loadedPath, loadedScript);
136+
File.WriteAllText(mainPath, mainScript.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\r", nl));
137+
File.WriteAllText(loadedPath, loadedScript.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\r", nl));
116138

117-
RunExplicit(mainPath, "", false).ShouldEqual("loaded;main");
139+
RunExplicit(mainPath, "", false)
140+
.ShouldEqual("loaded;main");
118141
}
119142
finally
120143
{
121-
File.Delete(mainPath);
122-
File.Delete(loadedPath);
144+
if (File.Exists(mainPath))
145+
File.Delete(mainPath);
146+
if (File.Exists(loadedPath))
147+
File.Delete(loadedPath);
123148
}
124-
125149
};
126150

127151
It should_change_hash_when_loaded_file_changes =
@@ -150,16 +174,17 @@ static Tuple<string, string> sc(string path, string contents) {
150174
var hash = FSIHelper.getScriptHash(scriptContents);
151175

152176
File.WriteAllText(lastPath, "printfn \"foobarbaz\"");
153-
177+
154178
scriptContents = FSIHelper.getAllScripts(mainPath);
155179
var newHash = FSIHelper.getScriptHash(scriptContents);
156180
hash.ShouldNotEqual(newHash);
157181
};
182+
158183
It should_get_included_assemblies =
159184
() =>
160185
{
161-
var script =
162-
"#r \"justname\"\n" +
186+
var script =
187+
"#r \"justname\"\n" +
163188
"#r \"./relative/path\"\n" +
164189
"#r \"C:/absolute/path\"";
165190

@@ -168,5 +193,4 @@ static Tuple<string, string> sc(string path, string contents) {
168193
included.ShouldEqual(new string[] { "justname", "./relative/path", "C:/absolute/path" });
169194
};
170195
}
171-
172-
}
196+
}

0 commit comments

Comments
 (0)