-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuilder_tests.ts
76 lines (61 loc) · 2.81 KB
/
builder_tests.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*-------------------------------------------------------------------------------------------------
* Copyright (C) 2023 Intel Corporation. All rights reserved.
* Licensed under the Apache License 2.0. See LICENSE in the project root for license information.
* SPDX-License-Identifier: Apache-2.0
*-----------------------------------------------------------------------------------------------*/
import { expect } from "chai";
import { AdviseManager } from "../src/advisor";
import { Project } from "../src/project";
import { WEBINIZER_TEST_HOME } from "../src/constants";
import fs from "graceful-fs";
import path from "path";
import { backupFolderSync, deleteFolder, renameFolder } from "../src/helper";
import { IBuilder } from "webinizer";
const TEST_BUILDER_ASSETS_DIR = `${WEBINIZER_TEST_HOME}/assets/builders`;
async function build(root: string, target = "static"): Promise<boolean> {
const proj = new Project(root);
const builder = proj.config.getBuildConfigForTarget(target).builders?.[0];
expect(builder).to.not.be.null;
return (builder as IBuilder).build(new AdviseManager(proj));
}
describe("builder", () => {
before(() => {
//Backup the "assets/builders" folder
backupFolderSync(TEST_BUILDER_ASSETS_DIR, `${WEBINIZER_TEST_HOME}/assets/.builders`);
});
after(() => {
//Delete the older "assets/builders" and restore it from backup
deleteFolder(TEST_BUILDER_ASSETS_DIR);
renameFolder(`${WEBINIZER_TEST_HOME}/assets/.builders`, TEST_BUILDER_ASSETS_DIR);
});
it("CMakeBuilderTest", async () => {
const projRoot = path.join(TEST_BUILDER_ASSETS_DIR, "CMakeBuilder");
const result = await build(projRoot);
expect(result).to.equal(true);
expect(fs.existsSync(path.join(projRoot, "Makefile"))).to.equal(true);
});
it("ConfigureBuilderTest", async () => {
const projRoot = path.join(TEST_BUILDER_ASSETS_DIR, "ConfigureBuilder");
const result = await build(projRoot);
expect(result).to.equal(true);
expect(fs.existsSync(path.join(projRoot, "Makefile"))).to.equal(true);
});
it("EmccBuilderTest", async () => {
const projRoot = path.join(TEST_BUILDER_ASSETS_DIR, "EmccBuilder");
const result = await build(projRoot);
expect(result).to.equal(true);
expect(fs.existsSync(path.join(projRoot, "main.js"))).to.equal(true);
});
it("MakeBuilderTest", async () => {
const projRoot = path.join(TEST_BUILDER_ASSETS_DIR, "MakeBuilder");
const result = await build(projRoot);
expect(result).to.equal(true);
expect(fs.existsSync(path.join(projRoot, "main"))).to.equal(true);
});
it("NativeBuilderTest", async () => {
const projRoot = path.join(TEST_BUILDER_ASSETS_DIR, "NativeBuilder");
const result = await build(projRoot);
expect(result).to.equal(true);
expect(fs.existsSync(path.join(projRoot, "main"))).to.equal(true);
});
});