Skip to content

Commit

Permalink
Add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
p120ph37 committed Jul 29, 2022
1 parent 85aa2fc commit 638b70b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 5 additions & 3 deletions spec-main/api-app-spec.ts
Expand Up @@ -370,9 +370,11 @@ describe('app module', () => {
server!.once('error', error => done(error));
server!.on('connection', client => {
client.once('data', data => {
if (String(data) === 'false' && state === 'none') {
if (String(data) === '--first' && state === 'none') {
state = 'first-launch';
} else if (String(data) === 'true' && state === 'first-launch') {
} else if (String(data) === '--second' && state === 'first-launch') {
state = 'second-launch';
} else if (String(data) === '--third' && state === 'second-launch') {
done();
} else {
done(`Unexpected state: "${state}", data: "${data}"`);
Expand All @@ -381,7 +383,7 @@ describe('app module', () => {
});

const appPath = path.join(fixturesPath, 'api', 'relaunch');
const child = cp.spawn(process.execPath, [appPath]);
const child = cp.spawn(process.execPath, [appPath, '--first']);
child.stdout.on('data', (c) => console.log(c.toString()));
child.stderr.on('data', (c) => console.log(c.toString()));
child.on('exit', (code, signal) => {
Expand Down
8 changes: 6 additions & 2 deletions spec/fixtures/api/relaunch/main.js
Expand Up @@ -11,11 +11,15 @@ app.whenReady().then(() => {
const lastArg = process.argv[process.argv.length - 1];
const client = net.connect(socketPath);
client.once('connect', () => {
client.end(String(lastArg === '--second'));
client.end(lastArg);
});
client.once('end', () => {
if (lastArg !== '--second') {
if (lastArg === '--first') {
// Once without execPath specified
app.relaunch({ args: process.argv.slice(1).concat('--second') });
} else if (lastArg !== '--second') {
// And once with execPath specified
app.relaunch({ execPath: process.argv[0], args: process.argv.slice(1).concat('--third') });
}
app.exit(0);
});
Expand Down

0 comments on commit 638b70b

Please sign in to comment.