-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtransformer.test.ts
More file actions
67 lines (59 loc) · 1.64 KB
/
transformer.test.ts
File metadata and controls
67 lines (59 loc) · 1.64 KB
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
import assert from "node:assert";
import { describe, it } from "node:test";
import { bindingGypToCmakeLists } from "./transformer.js";
describe("bindingGypToCmakeLists", () => {
it("should declare a project name", () => {
const output = bindingGypToCmakeLists({
projectName: "some-project",
gyp: { targets: [] },
});
assert(output.includes("project(some-project)"));
});
it("should declare target libraries", () => {
const output = bindingGypToCmakeLists({
projectName: "some-project",
gyp: {
targets: [
{
target_name: "foo",
sources: ["foo.cc"],
},
{
target_name: "bar",
sources: ["bar.cc"],
},
],
},
});
assert(output.includes("add_library(foo SHARED foo.cc"));
assert(output.includes("add_library(bar SHARED bar.cc"));
});
it("transform \\ to / in source filenames", () => {
const output = bindingGypToCmakeLists({
projectName: "some-project",
gyp: {
targets: [
{
target_name: "foo",
sources: ["file\\with\\win32\\separator.cc"],
},
],
},
});
assert(output.includes("add_library(foo SHARED file/with/win32/separator.cc"));
});
it("escapes spaces in source filenames", () => {
const output = bindingGypToCmakeLists({
projectName: "some-project",
gyp: {
targets: [
{
target_name: "foo",
sources: ["file with spaces.cc"],
},
],
},
});
assert(output.includes("add_library(foo SHARED file\\ with\\ spaces.cc"));
});
});