Skip to content

Commit e608a61

Browse files
committed
feat: startup test
1 parent 8b9d3f3 commit e608a61

File tree

5 files changed

+63
-34
lines changed

5 files changed

+63
-34
lines changed

.github/workflows/testMacOS.yml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,9 @@ jobs:
2626
deno-version: 1.30.0
2727
- name: install llvm@14
2828
run: brew install llvm@14
29-
- name: debug path
30-
run: brew --prefix llvm@14
31-
- name: list lib
32-
run: ls $(brew --prefix llvm@14)
33-
- name: list lib/lib
34-
run: ls $(brew --prefix llvm@14)/lib
35-
- name: run test LIBCLANG_PATH pointing to file
29+
- name: test
3630
run: |
37-
export LIBCLANG_PATH="$(brew --prefix llvm@14)/lib/libclang.dylib"
38-
deno task test
39-
- name: run test LIBCLANG_PATH pointing to directory
40-
run: |
41-
export LIBCLANG_PATH="$(brew --prefix llvm@14)/lib/"
42-
deno task test
31+
export LIBCLANG_PATH="$(brew --prefix llvm@14)/lib"
32+
export TEST_DIR=$LIBCLANG_PATH
33+
export TEST_PATH="$TEST_DIR/libclang.dylib"
34+
deno task test

.github/workflows/testUbuntu.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,9 @@ jobs:
3333
run: |
3434
sudo apt-get install -y libclang1-14
3535
36-
- name: run test LIBCLANG_PATH pointing to file
36+
- name: test
3737
run: |
38-
export LIBCLANG_PATH=/usr/lib/llvm-14/lib/libclang-14.so.1
39-
deno task test
40-
41-
- name: run test LIBCLANG_PATH pointing to directory
42-
run: |
43-
export LIBCLANG_PATH=/usr/lib/llvm-14/lib/
38+
export LIBCLANG_PATH=/usr/lib/llvm-14/lib
39+
export TEST_DIR=$LIBCLANG_PATH
40+
export TEST_PATH=$TEST_DIR/libclang-14.so.1
4441
deno task test

.github/workflows/testWindows.yml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,9 @@ jobs:
2929
run: |
3030
choco install -y --allow-downgrade --version 14.0.6 llvm
3131
32-
# - name: add LLVM path to PATH environment variable
33-
# uses: myci-actions/export-env-var-powershell@1
34-
# with:
35-
# name: PATH
36-
# value: $env:PATH;$env:LIBCLANG_PATH
37-
38-
- name: run test LIBCLANG_PATH pointing to file
39-
run: |
40-
$Env:LIBCLANG_PATH="C:\Program Files\LLVM\bin\libclang.dll"
41-
deno task test
42-
43-
- name: run test LIBCLANG_PATH pointing to directory
32+
- name: test
4433
run: |
45-
$Env:LIBCLANG_PATH="C:\Program Files\LLVM\bin\"
34+
$Env:LIBCLANG_PATH="C:\Program Files\LLVM\bin"
35+
$Env:TEST_DIR=$Env:LIBCLANG_PATH
36+
$Env:TEST_PATH="$Env:LIBCLANG_PATH\libclang.dll"
4637
deno task test

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"lock": true,
33
"tasks": {
44
"build": "deno run --unstable --allow-env=LIBCLANG_PATH --allow-run=deno --allow-ffi --allow-write=lib/include build/build.ts",
5-
"test": "deno test --unstable --allow-env=LIBCLANG_PATH --allow-run=deno --allow-ffi"
5+
"test": "deno test --unstable --allow-env=LIBCLANG_PATH,TEST_PATH,TEST_DIR --allow-run=deno --allow-ffi"
66
}
77
}

test/0_startup.test.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Tests that libclang can be loaded in the given environment.
3+
*/
4+
5+
import { assert } from "https://deno.land/[email protected]/testing/asserts.ts";
6+
7+
Deno.test("Startup", async (t) => {
8+
await t.step({
9+
name: "with LIBCLANG_PATH pointing to a file",
10+
ignore: !Deno.env.get("TEST_PATH"),
11+
fn: () => {
12+
const output = new Deno.Command("deno", {
13+
args: [
14+
"run",
15+
"--unstable",
16+
"--allow-ffi",
17+
"--allow-env=LIBCLANG_PATH",
18+
"./lib/mod.ts",
19+
],
20+
env: {
21+
LIBCLANG_PATH: Deno.env.get("TEST_PATH")!,
22+
},
23+
}).outputSync();
24+
25+
assert(output.success);
26+
},
27+
});
28+
29+
await t.step({
30+
name: "with LIBCLANG_PATH pointing to a directory",
31+
ignore: !Deno.env.get("TEST_DIR"),
32+
fn: () => {
33+
const output = new Deno.Command("deno", {
34+
args: [
35+
"run",
36+
"--unstable",
37+
"--allow-ffi",
38+
"--allow-env=LIBCLANG_PATH",
39+
"./lib/mod.ts",
40+
],
41+
env: {
42+
LIBCLANG_PATH: Deno.env.get("TEST_DIR")!,
43+
},
44+
}).outputSync();
45+
46+
assert(output.success);
47+
},
48+
});
49+
});

0 commit comments

Comments
 (0)