Skip to content

Commit 4b3bcda

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

File tree

1 file changed

+47
-28
lines changed

1 file changed

+47
-28
lines changed

src/test/Test.FAKECore/FSIHelperSpecs.cs

+47-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,11 @@ 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+
return sbOut.ToString().Replace("\n", "").Replace("\r", "");
4444
}
4545

46-
static string Run(string script, string arguments, bool useCache) {
46+
static string Run(string script, string arguments, bool useCache)
47+
{
4748
var scriptFilePath = Path.GetTempFileName() + ".fsx";
4849
string result;
4950
try
@@ -55,12 +56,14 @@ static string Run(string script, string arguments, bool useCache) {
5556
{
5657
File.Delete(scriptFilePath);
5758
}
58-
59+
5960
return result;
6061
}
6162

6263
static string nl = System.Environment.NewLine;
63-
static Tuple<string, string> sc(string path, string contents) {
64+
65+
static Tuple<string, string> sc(string path, string contents)
66+
{
6467
return new Tuple<string, string>(path.Replace("\\", "/"), contents);
6568
}
6669

@@ -73,32 +76,44 @@ static Tuple<string, string> sc(string path, string contents) {
7376
try
7477
{
7578
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";
79+
var scriptHash =
80+
FSIHelper.getScriptHash(new Tuple<string, string>[] { sc(scriptFilePath, "printf \"foobar\"") });
81+
82+
var cacheFilePath = Path.Combine(".", ".fake", scriptFileName + "_" + scriptHash + ".dll");
7883

7984
File.Exists(cacheFilePath).ShouldEqual(false);
8085

81-
RunExplicit(scriptFilePath, arguments, false).ShouldEqual("foobar");
86+
RunExplicit(scriptFilePath, arguments, false)
87+
.ShouldEqual("foobar");
88+
8289
File.Exists(cacheFilePath).ShouldEqual(false);
8390

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

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

90103
File.WriteAllText(scriptFilePath, "printf \"foobarbaz\"");
91104

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

111+
File.Exists("./.fake/" + scriptFileName + "_" + changedScriptHash + ".dll").ShouldEqual(true);
97112
}
98113
finally
99114
{
100-
if (File.Exists(scriptFilePath)) File.Delete(scriptFilePath);
101-
//if (Directory.Exists("./.fake")) Directory.Delete("./.fake");
115+
if (File.Exists(scriptFilePath))
116+
File.Delete(scriptFilePath);
102117
}
103118
};
104119

@@ -109,19 +124,23 @@ static Tuple<string, string> sc(string path, string contents) {
109124
var loadedPath = Path.GetTempFileName() + ".fsx";
110125
try
111126
{
112-
var mainScript = "printf \"main\"\n#load \"" + loadedPath.ToString().Replace("\\", "/") + "\"";
127+
var mainScript =
128+
"printf \"main\"\n#load \"" +
129+
loadedPath.ToString().Replace("\\", "/") + "\"";
113130
var loadedScript = "printf \"loaded;\"";
114-
File.WriteAllText(mainPath, mainScript);
115-
File.WriteAllText(loadedPath, loadedScript);
131+
File.WriteAllText(mainPath, mainScript.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\r", nl));
132+
File.WriteAllText(loadedPath, loadedScript.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\r", nl));
116133

117-
RunExplicit(mainPath, "", false).ShouldEqual("loaded;main");
134+
RunExplicit(mainPath, "", false)
135+
.ShouldEqual("loaded;main");
118136
}
119137
finally
120138
{
121-
File.Delete(mainPath);
122-
File.Delete(loadedPath);
139+
if (File.Exists(mainPath))
140+
File.Delete(mainPath);
141+
if (File.Exists(loadedPath))
142+
File.Delete(loadedPath);
123143
}
124-
125144
};
126145

127146
It should_change_hash_when_loaded_file_changes =
@@ -150,16 +169,17 @@ static Tuple<string, string> sc(string path, string contents) {
150169
var hash = FSIHelper.getScriptHash(scriptContents);
151170

152171
File.WriteAllText(lastPath, "printfn \"foobarbaz\"");
153-
172+
154173
scriptContents = FSIHelper.getAllScripts(mainPath);
155174
var newHash = FSIHelper.getScriptHash(scriptContents);
156175
hash.ShouldNotEqual(newHash);
157176
};
177+
158178
It should_get_included_assemblies =
159179
() =>
160180
{
161-
var script =
162-
"#r \"justname\"\n" +
181+
var script =
182+
"#r \"justname\"\n" +
163183
"#r \"./relative/path\"\n" +
164184
"#r \"C:/absolute/path\"";
165185

@@ -168,5 +188,4 @@ static Tuple<string, string> sc(string path, string contents) {
168188
included.ShouldEqual(new string[] { "justname", "./relative/path", "C:/absolute/path" });
169189
};
170190
}
171-
172-
}
191+
}

0 commit comments

Comments
 (0)