Skip to content

Commit

Permalink
why you holding me hostage
Browse files Browse the repository at this point in the history
  • Loading branch information
amr-crabnebula committed Nov 23, 2023
1 parent 447954c commit f40447b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check Rust
name: Check

on:
push:
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --workspace --all-targets --all-features -- -D warnings

test:
rust-test:
strategy:
fail-fast: false
matrix:
Expand Down
32 changes: 20 additions & 12 deletions bindings/packager/nodejs/__test__/index.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import test from 'ava'
import process from 'process'
import { execSync } from "child_process"
import test from "ava";
import process from "process";
import { execSync } from "child_process";

import { bundleApp } from '../build/index.js'
import { bundleApp } from "../build/index.js";

test('log error', async (t) => {
process.env.CI = true
process.chdir('../../../examples/electron')
execSync('yarn install')
t.is(await bundleApp({
formats: process.env.PACKAGER_FORMATS ? process.env.PACKAGER_FORMATS.split(',') : null
}, { verbosity: 2 }), undefined)
})
test("log error", async (t) => {
process.env.CI = true;
process.chdir("../../../examples/electron");
execSync("yarn install");
t.is(
await bundleApp(
{
formats: process.env.PACKAGER_FORMATS
? process.env.PACKAGER_FORMATS.split(",")
: null,
},
{ verbosity: 2 },
),
undefined,
);
});
23 changes: 7 additions & 16 deletions bindings/updater/nodejs/__test__/index.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test("it works", async (t) => {
const buildApp = async (version, updaterFormats) => {
await writeFile(
join(appDir, "dist", "ver.js"),
`module.exports.version = "${version}";`,
`module.exports.version = "${version}";`
);

try {
Expand All @@ -43,7 +43,7 @@ test("it works", async (t) => {
CARGO_PACKAGER_SIGN_PRIVATE_KEY: UPDATER_PRIVATE_KEY,
CARGO_PACKAGER_SIGN_PRIVATE_KEY_PASSWORD: "",
},
},
}
);
} catch (e) {
console.error("failed to package app");
Expand All @@ -54,7 +54,7 @@ test("it works", async (t) => {
// bundle app update
await buildApp(
"1.0.0",
isWindows ? ["nsis", "wix"] : isMacos ? ["app"] : ["appimage"],
isWindows ? ["nsis", "wix"] : isMacos ? ["app"] : ["appimage"]
);

const packgePaths = (version) => {
Expand Down Expand Up @@ -143,25 +143,14 @@ test("it works", async (t) => {
? "updater-app-test.exe"
: isMacos
? "PackagerAppUpdaterTestNodejs.app/Contents/MacOS/cargo-packager-updater-app-test"
: `updater-app-test_${version}_x86_64.AppImage`,
: `updater-app-test_${version}_x86_64.AppImage`
);

try {
await execa(app, [], {
env: { UPDATER_FORMAT: updaterFormat },
});
} catch (e) {
console.error("failed to run app");
console.error(e);
}

// wait until the update is finished and the new version has been installed
// before starting another updater test, this is because we use the same starting binary
// and we can't use it while the updater is installing it
let counter = 0;
while (true) {
await sleep(2000);

try {
const { stdout, stderr } = await execa(app, [], {
env: { UPDATER_FORMAT: updaterFormat },
Expand All @@ -183,10 +172,12 @@ test("it works", async (t) => {
counter += 1;
if (counter == 10) {
console.error(
"updater test timedout and couldn't verify the update has happened",
"updater test timedout and couldn't verify the update has happened"
);
break;
}

await sleep(2000);
}

server.close();
Expand Down
8 changes: 1 addition & 7 deletions crates/updater/tests/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,18 +293,11 @@ fn update_app() {
// This is read by the updater app test
binary_cmd.env("UPDATER_FORMAT", updater_format.name());

let status = binary_cmd.status().expect("failed to run app");

if !status.success() {
panic!("failed to run app");
}

// wait until the update is finished and the new version has been installed
// before starting another updater test, this is because we use the same starting binary
// and we can't use it while the updater is installing it
let mut counter = 0;
loop {
std::thread::sleep(std::time::Duration::from_secs(2));
match binary_cmd.output() {
Ok(o) => {
let output = String::from_utf8_lossy(&o.stdout).to_string();
Expand All @@ -325,6 +318,7 @@ fn update_app() {
if counter == 10 {
panic!("updater test timedout and couldn't verify the update has happened")
}
std::thread::sleep(std::time::Duration::from_secs(2));
}

// force a new build of the updater app test
Expand Down

0 comments on commit f40447b

Please sign in to comment.