Skip to content

Commit

Permalink
test(deb): check file associations
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Jul 31, 2019
1 parent c36f6c8 commit 371296a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/app-builder-lib/src/targets/LinuxTargetHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class LinuxTargetHelper {
<glob pattern="*.${fileAssociation.ext}"/>
${fileAssociation.description ? `<comment>${fileAssociation.description}</comment>` : ""}
<icon name="x-office-document" />
</mime-type>`
</mime-type>`
items.push(data)
}

Expand Down
1 change: 1 addition & 0 deletions packages/app-builder-lib/src/targets/fpm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ export default class FpmTarget extends Target {
DYLD_LIBRARY_PATH: computeEnv(process.env.DYLD_LIBRARY_PATH, [path.join(linuxToolsPath, "lib")]),
})
}

await executeAppBuilder(["fpm", "--configuration", JSON.stringify(fpmConfiguration)], undefined, {env})

await packager.dispatchArtifactCreated(artifactPath, this, arch)
Expand Down
11 changes: 11 additions & 0 deletions test/out/linux/__snapshots__/debTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,17 @@ Object {

exports[`deb file associations 4`] = `"Test Application (test quite “ #378)"`;

exports[`deb file associations 5`] = `
"<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
<mime-info xmlns=\\"http://www.freedesktop.org/standards/shared-mime-info\\">
<mime-type type=\\"application/x-example\\">
<glob pattern=\\"*.my-app\\"/>
<icon name=\\"x-office-document\\" />
</mime-type>
</mime-info>"
`;

exports[`no quotes for safe exec name 1`] = `
"[Desktop Entry]
Name=foo
Expand Down
5 changes: 3 additions & 2 deletions test/src/helpers/packTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ async function checkLinuxResult(outDir: string, packager: Packager, arch: Arch,
const control = parseDebControl(await execShell(`ar p '${packageFile}' control.tar.gz | ${await getTarExecutable()} zx --to-stdout ./control`, {
maxBuffer: 10 * 1024 * 1024,
}))

delete control.Version
delete control.Size
const description = control.Description
Expand Down Expand Up @@ -397,9 +398,9 @@ async function checkWindowsResult(packager: Packager, checkOptions: AssertPackOp
}
}

const execShell: any = BluebirdPromise.promisify(require("child_process").exec)
export const execShell: any = BluebirdPromise.promisify(require("child_process").exec)

async function getTarExecutable() {
export async function getTarExecutable() {
return process.platform === "darwin" ? path.join(await getLinuxToolsPath(), "bin", "gtar") : "tar"
}

Expand Down
9 changes: 8 additions & 1 deletion test/src/linux/debTest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Arch, Platform } from "electron-builder"
import { promises as fs } from "fs"
import { app } from "../helpers/packTester"
import { app, execShell, getTarExecutable } from "../helpers/packTester"

test.ifNotWindows("deb", app({
targets: Platform.LINUX.createTarget("deb"),
Expand Down Expand Up @@ -46,4 +46,11 @@ test.ifNotWindows.ifNotCiMac.ifAll("deb file associations", app({
}
],
},
}, {
packed: async context => {
const mime = await execShell(`ar p '${context.outDir}/TestApp_1.1.0_amd64.deb' data.tar.xz | ${await getTarExecutable()} Jx --to-stdout ./usr/share/mime/packages/testapp.xml`, {
maxBuffer: 10 * 1024 * 1024,
})
expect(mime.trim()).toMatchSnapshot()
}
}))

0 comments on commit 371296a

Please sign in to comment.