One test of node-rcedit 0.9.0 fails with rcedit 1.0.0 because of changed error message
robi-wan opened this issue · 1 comments
Running the test of github.com/electron/node-rcedit v0.9.0 with rcedit.exe v1.0.0 produces this result:
c:\development\work\rcedit\node-rcedit>npm run test
> rcedit@0.9.0 test c:\development\work\rcedit\node-rcedit
> mocha test/*.js && npm run lint
rcedit(exePath, options, callback)
v updates the information in the executable (937ms)
v supports non-ASCII characters in the .exe path (859ms)
v supports a product version of 1 (890ms)
v supports a product version of 1.0 (1094ms)
v supports setting requestedExecutionLevel to requireAdministrator (4984ms)
v supports replacing the manifest with a specified manifest file (4766ms)
1) reports an error when the .exe path does not exist
v reports an error when the icon path does not exist
v reports an error when the file version is invalid
v reports an error when the product version is invalid
9 passing (38s)
1 failing
1) rcedit(exePath, options, callback) reports an error when the .exe path does not exist:
Uncaught AssertionError: -1 != -1
+ expected - actual
at test\rcedit-test.js:156:14
at ChildProcess.<anonymous> (lib\rcedit.js:68:7)
at maybeClose (internal/child_process.js:862:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:222:5)
The test fails because the error message of rcedit was changed.
Prior this change the error message was something like rcedit.exe failed with exit code 1. Fatal error: Unable to load file
.
After the change the error message reads rcedit.exe failed with exit code 1. Unable to load file: "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\node-rcedit-11795-6132-1wa6nwa\does-n ot-exist.exe"
The failing test expects this error message/output: 'Fatal error: Unable to load file'
(After the change the part Fatal error:
is missing and thus the test fails.)
Solution 1:
Tweak the output of rcedit:
diff --git a/src/main.cc b/src/main.cc
index 7944303..58bb498 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -155,13 +155,13 @@ int wmain(int argc, const wchar_t* argv[]) {
} else {
if (loaded) {
- fprintf(stderr, "Unrecognized argument: \"%ls\"\n", argv[i]);
+ fprintf(stderr, "Fatal error: Unrecognized argument: \"%ls\"\n", argv[i]);
return 1;
}
loaded = true;
if (!updater.Load(argv[i])) {
- fprintf(stderr, "Unable to load file: \"%ls\"\n", argv[i]);
+ fprintf(stderr, "Fatal error: Unable to load file: \"%ls\"\n", argv[i]);
return 1;
}
Solution 2:
Adapt the node-rcedit test for the new error message/output (when updating the rcedit artifact in the node-rcedit repository).
diff --git a/test/rcedit-test.js b/test/rcedit-test.js
index 9af20fd..7c0b876 100644
--- a/test/rcedit-test.js
+++ b/test/rcedit-test.js
@@ -153,7 +153,7 @@ describe('rcedit(exePath, options, callback)', function () {
rcedit(path.join(tempPath, 'does-not-exist.exe'), {'file-version': '3.4.5.6'}, function (error) {
assert.ok(error instanceof Error)
assert.notEqual(error.message.indexOf('rcedit.exe failed with exit code 1.'), -1)
- assert.notEqual(error.message.indexOf('Fatal error: Unable to load file'), -1)
+ assert.notEqual(error.message.indexOf('Unable to load file: '), -1)
done()
})
This was resolved in electron/node-rcedit#34 (the tests were changed).