Skip to content

Commit 3150067

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

File tree

1 file changed

+49
-28
lines changed

1 file changed

+49
-28
lines changed

src/test/Test.FAKECore/FSIHelperSpecs.cs

+49-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;
@@ -40,10 +40,13 @@ static string RunExplicit(string scriptFilePath, string arguments, bool useCache
4040
Console.WriteLine(x.Message);
4141
}
4242
var messages = result.Item2.Where(x => !x.IsError).Select(x => x.Message);
43-
return sbOut.ToString();
43+
var resultText = sbOut.ToString().Replace("\n", "").Replace("\r", "");
44+
Console.WriteLine(resultText);
45+
return resultText;
4446
}
4547

46-
static string Run(string script, string arguments, bool useCache) {
48+
static string Run(string script, string arguments, bool useCache)
49+
{
4750
var scriptFilePath = Path.GetTempFileName() + ".fsx";
4851
string result;
4952
try
@@ -55,12 +58,14 @@ static string Run(string script, string arguments, bool useCache) {
5558
{
5659
File.Delete(scriptFilePath);
5760
}
58-
61+
5962
return result;
6063
}
6164

6265
static string nl = System.Environment.NewLine;
63-
static Tuple<string, string> sc(string path, string contents) {
66+
67+
static Tuple<string, string> sc(string path, string contents)
68+
{
6469
return new Tuple<string, string>(path.Replace("\\", "/"), contents);
6570
}
6671

@@ -73,32 +78,44 @@ static Tuple<string, string> sc(string path, string contents) {
7378
try
7479
{
7580
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";
81+
var scriptHash =
82+
FSIHelper.getScriptHash(new Tuple<string, string>[] { sc(scriptFilePath, "printf \"foobar\"") });
83+
84+
var cacheFilePath = Path.Combine(".", ".fake", scriptFileName + "_" + scriptHash + ".dll");
7885

7986
File.Exists(cacheFilePath).ShouldEqual(false);
8087

81-
RunExplicit(scriptFilePath, arguments, false).ShouldEqual("foobar");
88+
RunExplicit(scriptFilePath, arguments, false)
89+
.ShouldEqual("foobar");
90+
8291
File.Exists(cacheFilePath).ShouldEqual(false);
8392

84-
RunExplicit(scriptFilePath, arguments, true).ShouldEqual(
85-
"Cache doesnt exist" + nl + "foobar" + nl + "Saved cache" + nl);
93+
RunExplicit(scriptFilePath, arguments, true)
94+
.ShouldEqual(
95+
("Cache doesnt exist" + nl + "foobar" + nl + "Saved cache" + nl)
96+
.Replace("\n", "").Replace("\r", ""));
97+
8698
File.Exists(cacheFilePath).ShouldEqual(true);
8799

88-
RunExplicit(scriptFilePath, arguments, true).ShouldEqual("Using cache" + nl + "foobar");
100+
RunExplicit(scriptFilePath, arguments, true)
101+
.ShouldEqual(
102+
("Using cache" + nl + "foobar")
103+
.Replace("\n", "").Replace("\r", ""));
89104

90105
File.WriteAllText(scriptFilePath, "printf \"foobarbaz\"");
91106

92107
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);
108+
RunExplicit(scriptFilePath, arguments, true)
109+
.ShouldEqual(
110+
("Cache is invalid, recompiling" + nl + "foobarbaz" + nl + "Saved cache" + nl)
111+
.Replace("\n", "").Replace("\r", ""));
96112

113+
File.Exists("./.fake/" + scriptFileName + "_" + changedScriptHash + ".dll").ShouldEqual(true);
97114
}
98115
finally
99116
{
100-
if (File.Exists(scriptFilePath)) File.Delete(scriptFilePath);
101-
//if (Directory.Exists("./.fake")) Directory.Delete("./.fake");
117+
if (File.Exists(scriptFilePath))
118+
File.Delete(scriptFilePath);
102119
}
103120
};
104121

@@ -109,19 +126,23 @@ static Tuple<string, string> sc(string path, string contents) {
109126
var loadedPath = Path.GetTempFileName() + ".fsx";
110127
try
111128
{
112-
var mainScript = "printf \"main\"\n#load \"" + loadedPath.ToString().Replace("\\", "/") + "\"";
129+
var mainScript =
130+
"printf \"main\"\n#load \"" +
131+
loadedPath.ToString().Replace("\\", "/") + "\"";
113132
var loadedScript = "printf \"loaded;\"";
114-
File.WriteAllText(mainPath, mainScript);
115-
File.WriteAllText(loadedPath, loadedScript);
133+
File.WriteAllText(mainPath, mainScript.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\r", nl));
134+
File.WriteAllText(loadedPath, loadedScript.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\r", nl));
116135

117-
RunExplicit(mainPath, "", false).ShouldEqual("loaded;main");
136+
RunExplicit(mainPath, "", false)
137+
.ShouldEqual("loaded;main");
118138
}
119139
finally
120140
{
121-
File.Delete(mainPath);
122-
File.Delete(loadedPath);
141+
if (File.Exists(mainPath))
142+
File.Delete(mainPath);
143+
if (File.Exists(loadedPath))
144+
File.Delete(loadedPath);
123145
}
124-
125146
};
126147

127148
It should_change_hash_when_loaded_file_changes =
@@ -150,16 +171,17 @@ static Tuple<string, string> sc(string path, string contents) {
150171
var hash = FSIHelper.getScriptHash(scriptContents);
151172

152173
File.WriteAllText(lastPath, "printfn \"foobarbaz\"");
153-
174+
154175
scriptContents = FSIHelper.getAllScripts(mainPath);
155176
var newHash = FSIHelper.getScriptHash(scriptContents);
156177
hash.ShouldNotEqual(newHash);
157178
};
179+
158180
It should_get_included_assemblies =
159181
() =>
160182
{
161-
var script =
162-
"#r \"justname\"\n" +
183+
var script =
184+
"#r \"justname\"\n" +
163185
"#r \"./relative/path\"\n" +
164186
"#r \"C:/absolute/path\"";
165187

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

0 commit comments

Comments
 (0)