Server/scripts/test.js

51 lines
1.3 KiB
JavaScript
Raw Normal View History

2024-09-26 04:01:06 -07:00
/*
ValkyrieChat: A re-implementation and extension of the Discord.com backend.
Copyright (C) 2024 ValkyrieChat
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
2024-09-05 00:21:51 -07:00
/*
Super simple script to check if the server starts at all, for use in gh actions.
Not a proper test framework by any means.
*/
const { spawn } = require("child_process");
const path = require("path");
const server = spawn("node", [
path.join(__dirname, "..", "dist", "bundle", "start.js"),
]);
server.stdout.on("data", (data) => {
process.stdout.write(data);
if (data.toString().toLowerCase().includes("listening")) {
// we good :)
console.log("we good");
server.kill();
process.exit();
}
});
server.stderr.on("data", (err) => {
process.stdout.write(err);
// we bad :(
process.kill(1);
});
server.on("close", (code) => {
console.log("closed with code", code);
process.exit(code);
});