Skip to content

Commit

Permalink
test: scope internal test fixtures under @electron-ci (#34023)
Browse files Browse the repository at this point in the history
* test: scope internal test fixtures under `@electron`

* Missed references

* Move packages from @electron to @electron-ci scope

* Fix tests

* fix require

Co-authored-by: Jamie Magee <jamie.magee@gmail.com>
Co-authored-by: Milan Burda <milan.burda@gmail.com>
  • Loading branch information
3 people committed May 4, 2022
1 parent 5a91ea8 commit 252f9cb
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 18 deletions.
Expand Up @@ -7,7 +7,7 @@
let requireError

try {
echo = require('echo')
echo = require('@electron-ci/echo')
} catch (error) {
requireError = error
}
Expand Down
2 changes: 1 addition & 1 deletion spec-main/fixtures/module/echo-renamed.js
@@ -1,6 +1,6 @@
let echo;
try {
echo = require('echo');
echo = require('@electron-ci/echo');
} catch (e) {
process.exit(1);
}
Expand Down
2 changes: 1 addition & 1 deletion spec-main/fixtures/module/echo.js
Expand Up @@ -2,5 +2,5 @@ process.on('uncaughtException', function (err) {
process.send(err.message);
});

const echo = require('echo');
const echo = require('@electron-ci/echo');
process.send(echo('ok'));
2 changes: 1 addition & 1 deletion spec-main/fixtures/module/uv-dlopen.js
@@ -1 +1 @@
require('uv-dlopen');
require('@electron-ci/uv-dlopen');
3 changes: 1 addition & 2 deletions spec-main/fixtures/native-addon/echo/package.json
@@ -1,6 +1,5 @@

{
"main": "./lib/echo.js",
"name": "echo",
"name": "@electron-ci/echo",
"version": "0.0.1"
}
2 changes: 1 addition & 1 deletion spec-main/fixtures/native-addon/uv-dlopen/package.json
@@ -1,5 +1,5 @@
{
"name": "uv-dlopen",
"name": "@electron-ci/uv-dlopen",
"version": "0.0.1",
"main": "index.js"
}
8 changes: 6 additions & 2 deletions spec-main/modules-spec.ts
Expand Up @@ -21,7 +21,11 @@ describe('modules support', () => {
it('can be required in renderer', async () => {
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
w.loadURL('about:blank');
await expect(w.webContents.executeJavaScript('{ require(\'echo\'); null }')).to.be.fulfilled();
await expect(
w.webContents.executeJavaScript(
"{ require('@electron-ci/echo'); null }"
)
).to.be.fulfilled();
});

ifit(features.isRunAsNodeEnabled())('can be required in node binary', async function () {
Expand Down Expand Up @@ -53,7 +57,7 @@ describe('modules support', () => {
it('can be required in renderer', async () => {
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
w.loadURL('about:blank');
await expect(w.webContents.executeJavaScript('{ require(\'uv-dlopen\'); null }')).to.be.fulfilled();
await expect(w.webContents.executeJavaScript('{ require(\'@electron-ci/uv-dlopen\'); null }')).to.be.fulfilled();
});

ifit(features.isRunAsNodeEnabled())('can be required in node binary', async function () {
Expand Down
4 changes: 2 additions & 2 deletions spec-main/package.json
Expand Up @@ -4,13 +4,13 @@
"main": "index.js",
"version": "0.1.0",
"devDependencies": {
"@electron-ci/echo": "file:./fixtures/native-addon/echo",
"@electron-ci/uv-dlopen": "file:./fixtures/native-addon/uv-dlopen/",
"@types/sinon": "^9.0.4",
"@types/ws": "^7.2.0",
"busboy": "^0.3.1",
"echo": "file:fixtures/native-addon/echo",
"q": "^1.5.1",
"sinon": "^9.0.1",
"uv-dlopen": "./fixtures/native-addon/uv-dlopen/",
"ws": "^7.4.6"
},
"dependencies": {
Expand Down
12 changes: 6 additions & 6 deletions spec-main/yarn.lock
Expand Up @@ -2,6 +2,12 @@
# yarn lockfile v1


"@electron-ci/echo@file:./fixtures/native-addon/echo":
version "0.0.1"

"@electron-ci/uv-dlopen@file:./fixtures/native-addon/uv-dlopen":
version "0.0.1"

"@sinonjs/commons@^1", "@sinonjs/commons@^1.6.0", "@sinonjs/commons@^1.7.0", "@sinonjs/commons@^1.7.2":
version "1.8.0"
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.0.tgz#c8d68821a854c555bba172f3b06959a0039b236d"
Expand Down Expand Up @@ -330,9 +336,6 @@ ecc-jsbn@~0.1.1:
jsbn "~0.1.0"
safer-buffer "^2.1.0"

"echo@file:fixtures/native-addon/echo":
version "0.0.1"

emojis-list@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389"
Expand Down Expand Up @@ -959,9 +962,6 @@ uuid@^3.3.2:
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==

uv-dlopen@./fixtures/native-addon/uv-dlopen/:
version "0.0.1"

verror@1.10.0:
version "1.10.0"
resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400"
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/pages/native-module.html
Expand Up @@ -2,7 +2,7 @@
<body>
<script type="text/javascript" charset="utf-8">
var path = require('path');
console.log(typeof require(path.join(__dirname, '..', '..', '..', 'spec-main', 'node_modules', 'echo')));
console.log(typeof require(path.join(__dirname, '..', '..', '..', 'spec-main', 'node_modules', '@electron-ci', 'echo')));
</script>
</body>
</html>
Expand Down

0 comments on commit 252f9cb

Please sign in to comment.