Skip to content

Commit 915b4f1

Browse files
authored
Merge branch 'master' into fix-160
2 parents 9d41b30 + c69be47 commit 915b4f1

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

test/NodeJS/NodeJSServiceImplementations/OutOfProcess/Http/HttpNodeJSPoolServiceIntegrationTests.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Linq;
1010
using System.Net.Http;
1111
using System.Text;
12+
using System.Text.Encodings.Web;
1213
using System.Text.RegularExpressions;
1314
using System.Threading;
1415
using System.Threading.Tasks;
@@ -93,24 +94,25 @@ public async void FileWatching_RespectsGracefulShutdownOptionWhenItsTrue()
9394
const int dummyNumProcesses = 5;
9495
Uri tempWatchDirectoryUri = CreateWatchDirectoryUri();
9596
// Create initial module
96-
string dummylongRunningTriggerPath = new Uri(tempWatchDirectoryUri, "dummyTriggerFile").AbsolutePath; // fs.watch can't deal with backslashes in paths
97+
string dummylongRunningTriggerPath = new Uri(tempWatchDirectoryUri, "dummyTriggerFile").LocalPath; // Use LocalPath instead of AbsolutePath, the latter performs URL encoding, which results in paths that are invalid for local use
9798
#if NET461
9899
File.WriteAllText(dummylongRunningTriggerPath, string.Empty); // fs.watch returns immediately if path to watch doesn't exist
99100
#else
100101
await File.WriteAllTextAsync(dummylongRunningTriggerPath, string.Empty).ConfigureAwait(false); // fs.watch returns immediately if path to watch doesn't exist
101102
#endif
103+
// JavascriptEncode.Default.Encode encodes a string so that it can be used as a string literal in Javascript
102104
string dummyInitialModule = $@"module.exports = {{
103105
getPid: (callback) => callback(null, process.pid),
104106
longRunning: (callback) => {{
105-
fs.watch('{dummylongRunningTriggerPath}',
107+
fs.watch('{JavaScriptEncoder.Default.Encode(dummylongRunningTriggerPath)}',
106108
null,
107109
() => {{
108110
callback(null, process.pid);
109111
}}
110112
);
111113
}}
112114
}}";
113-
string dummyModuleFilePath = new Uri(tempWatchDirectoryUri, "dummyModule.js").AbsolutePath;
115+
string dummyModuleFilePath = new Uri(tempWatchDirectoryUri, "dummyModule.js").LocalPath;
114116
#if NET461
115117
File.WriteAllText(dummyModuleFilePath, dummyInitialModule);
116118
#else
@@ -194,7 +196,7 @@ public async void FileWatching_RespectsGracefulShutdownOptionWhenItsFalse()
194196
getPid: (callback) => callback(null, process.pid),
195197
longRunning: (callback) => setInterval(() => { /* Do nothing */ }, 1000)
196198
}";
197-
string dummyModuleFilePath = new Uri(CreateWatchDirectoryUri(), "dummyModule.js").AbsolutePath;
199+
string dummyModuleFilePath = new Uri(CreateWatchDirectoryUri(), "dummyModule.js").LocalPath;
198200
#if NET461
199201
File.WriteAllText(dummyModuleFilePath, dummyInitialModule);
200202
#else

test/NodeJS/NodeJSServiceImplementations/OutOfProcess/Http/HttpNodeJSServiceIntegrationTests.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.Net.Http;
1111
using System.Runtime.InteropServices;
1212
using System.Text;
13+
using System.Text.Encodings.Web;
1314
using System.Text.RegularExpressions;
1415
using System.Threading;
1516
using System.Threading.Tasks;
@@ -1106,24 +1107,25 @@ public async void FileWatching_RespectsGracefulShutdownOptionWhenItsTrue()
11061107
// Arrange
11071108
Uri tempWatchDirectoryUri = CreateWatchDirectoryUri();
11081109
// Create initial module
1109-
string dummylongRunningTriggerPath = new Uri(tempWatchDirectoryUri, "dummyTriggerFile").AbsolutePath; // fs.watch can't deal with backslashes in paths
1110+
string dummylongRunningTriggerPath = new Uri(tempWatchDirectoryUri, "dummyTriggerFile").LocalPath; // Use LocalPath instead of AbsolutePath, the latter performs URL encoding, which results in paths that are invalid for local use
11101111
#if NET461
11111112
File.WriteAllText(dummylongRunningTriggerPath, string.Empty); // fs.watch returns immediately if path to watch doesn't exist
11121113
#else
11131114
await File.WriteAllTextAsync(dummylongRunningTriggerPath, string.Empty).ConfigureAwait(false); // fs.watch returns immediately if path to watch doesn't exist
11141115
#endif
1116+
// JavascriptEncode.Default.Encode encodes a string so that it can be used as a string literal in Javascript
11151117
string dummyInitialModule = $@"module.exports = {{
11161118
getPid: (callback) => callback(null, process.pid),
11171119
longRunning: (callback) => {{
1118-
fs.watch('{dummylongRunningTriggerPath}',
1120+
fs.watch('{JavaScriptEncoder.Default.Encode(dummylongRunningTriggerPath)}',
11191121
null,
11201122
() => {{
11211123
callback(null, process.pid);
11221124
}}
11231125
);
11241126
}}
11251127
}}";
1126-
string dummyModuleFilePath = new Uri(tempWatchDirectoryUri, "dummyModule.js").AbsolutePath;
1128+
string dummyModuleFilePath = new Uri(tempWatchDirectoryUri, "dummyModule.js").LocalPath;
11271129
#if NET461
11281130
File.WriteAllText(dummyModuleFilePath, dummyInitialModule);
11291131
#else
@@ -1175,7 +1177,7 @@ public async void FileWatching_RespectsGracefulShutdownOptionWhenItsFalse()
11751177
getPid: (callback) => callback(null, process.pid),
11761178
longRunning: (callback) => setInterval(() => { /* Do nothing */ }, 1000)
11771179
}";
1178-
string dummyModuleFilePath = new Uri(CreateWatchDirectoryUri(), "dummyModule.js").AbsolutePath;
1180+
string dummyModuleFilePath = new Uri(CreateWatchDirectoryUri(), "dummyModule.js").LocalPath;
11791181
#if NET461
11801182
File.WriteAllText(dummyModuleFilePath, dummyInitialModule);
11811183
#else

test/NodeJS/NodeJSServiceImplementations/OutOfProcess/OutOfProcessNodeJSServiceUnitTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ public async void TryInvokeCoreAsync_ThrowsObjectDisposedExceptionIfObjectHasBee
462462
mockTestSubject.Object.Dispose();
463463
ObjectDisposedException result = await Assert.
464464
ThrowsAsync<ObjectDisposedException>(async () => await mockTestSubject.Object.TryInvokeCoreAsync<string>(new InvocationRequest(ModuleSourceType.String, "dummyModuleSource"), CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false);
465-
Assert.Equal($"Cannot access a disposed object.\nObject name: '{nameof(OutOfProcessNodeJSService)}'.", result.Message, ignoreLineEndingDifferences: true);
465+
Assert.Contains($"{nameof(OutOfProcessNodeJSService)}", result.Message);
466466
}
467467

468468
[Fact]

0 commit comments

Comments
 (0)