Skip to content

Commit

Permalink
fix test + add workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ksyeo1010 committed Apr 28, 2023
1 parent b328e74 commit 763a02f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Web Utils Test

on:
workflow_dispatch:
push:
branches: [ main ]
paths:
- 'src/**'
- 'test/**'
- 'lib/**'
pull_request:
branches: [ main, 'v[0-9]+.[0-9]+' ]
paths:
- 'src/**'
- 'test/**'
- 'lib/**'

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [lts/*]

steps:
- uses: actions/checkout@v3

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Pre-build dependencies
run: npm install yarn

- name: Install dependencies
run: yarn install

- name: Build
run: yarn build

- name: Prepare Test
run: yarn setup-test

- name: Test
run: yarn test
8 changes: 5 additions & 3 deletions lib/pv_web_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extern void pv_https_request_wasm(
const char *endpoint,
const char *header,
const char *body,
int32_t timeout_msec,
void **response,
size_t *response_size,
int32_t *response_code);
Expand All @@ -35,7 +36,7 @@ extern void pv_get_origin_info(char **origin_info);
extern void pv_file_open_wasm(void *f, const char *path, const char *mode, int32_t *status);
extern void pv_file_close_wasm(void *f, int32_t *status);
extern void pv_file_write_wasm(void *f, const void *content, size_t size, size_t count, size_t *num_write);
extern void pv_file_read_wasm(void *f, void *content, size_t size, size_t count, size_t *num_read);
extern void pv_file_read_wasm(void *f, void *content, size_t size, size_t count, int32_t *num_read);
extern void pv_file_seek_wasm(void *f, long int offset, int whence, int32_t *status);
extern void pv_file_tell_wasm(void *f, long *offset);
extern void pv_file_remove_wasm(const char *path, int32_t *status);
Expand Down Expand Up @@ -70,6 +71,7 @@ PV_API pv_web_utils_status_t pv_web_utils_test_https_request(void) {
"/test_route",
"",
"",
7000,
(void **) &response,
&response_size,
&response_code);
Expand Down Expand Up @@ -161,7 +163,7 @@ PV_API pv_web_utils_status_t pv_web_utils_test_file_read(void) {
}

char content[sizeof (test_content)];
size_t num_read = -1;
int32_t num_read = -1;
pv_file_read_wasm(file, content, sizeof (char), sizeof (test_content), &num_read);

if (num_read != sizeof (test_content)) {
Expand All @@ -183,7 +185,7 @@ PV_API pv_web_utils_status_t pv_test_utils_test_file_close(void) {
return FAILURE;
}

size_t num_read = -1;
int32_t num_read = -1;
char content[1];
pv_file_read_wasm(file, content, sizeof (char), 1, &num_read);

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"lint": "eslint . --ext .js,.ts",
"prepack": "npm-run-all build",
"start": "cross-env TARGET='debug' rollup --config --watch",
"setup-test": "cmake -S lib -B lib/build && cmake --build lib/build",
"setup-test": "cmake -DCMAKE_BUILD_TYPE=Release -S lib -B lib/build && cmake --build lib/build",
"test": "cypress run --browser chrome",
"watch": "rollup --config --watch"
},
Expand Down

0 comments on commit 763a02f

Please sign in to comment.