Skip to content

Commit

Permalink
first batch of real unit tests (#45)
Browse files Browse the repository at this point in the history
* move things around for better compatibility

* switch back to SWIG JSE current

* fix and test most of the basic CRS features

* basic CoordinateOperation tests

* retrieve the SWIG output when testing

* make a debug macro

* skip the crashing test

* drop unintended change

* emscripten is going a little bit too far

* use hash codes for the downcasting table

* obviously it is evaluated, why it wouldn't be?

* run all tests in the browser

* no need for two quickstarts in the browser

* use a proper name for this battery

* use forward slashes on Windows
  • Loading branch information
mmomtchev authored Oct 16, 2024
1 parent 9907453 commit 6b1ed59
Show file tree
Hide file tree
Showing 26 changed files with 469 additions and 147 deletions.
23 changes: 21 additions & 2 deletions .github/workflows/run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ jobs:
- uses: mmomtchev/setup-swig@main
with:
branch: jse
version: v5.0.5

version: main
cache: false

- name: Verify SWIG
run: swig-jse -version

Expand Down Expand Up @@ -121,6 +122,12 @@ jobs:
with:
node-version: 20

- name: Download the SWIG-generated wrappers
uses: actions/download-artifact@v4
with:
name: swig-generated
path: swig

- name: Download the native artifact ${{ matrix.platform }}
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -163,6 +170,12 @@ jobs:
with:
node-version: 18

- name: Download the SWIG-generated wrappers
uses: actions/download-artifact@v4
with:
name: swig-generated
path: swig

- name: Download the WASM artifact
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -200,6 +213,12 @@ jobs:
with:
node-version: 20

- name: Download the SWIG-generated wrappers
uses: actions/download-artifact@v4
with:
name: swig-generated
path: swig

- name: Download the WASM artifact
uses: actions/download-artifact@v4
with:
Expand Down
7 changes: 4 additions & 3 deletions lib/index.d.mts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type * as proj from './binding/proj.d.ts';
import type * as PROJ from '../swig/proj.d.ts';
export type * as Proj from '../swig/proj.d.ts';

/*
* Embedded file system access, available only in WASM
*/
declare type FSMode = 'r' | 'r+' | 'w' | 'wx' | 'w+' | 'wx+' | 'a' | 'ax' | 'a+' | 'ax+';

declare module './binding/proj.d.ts' {
declare module '../swig/proj.d.ts' {
namespace FS {
function open(path: string, mode?: FSMode): unknown;
function close(file: unknown): void;
Expand All @@ -21,5 +22,5 @@ declare module './binding/proj.d.ts' {
function loadDatabase(db: Uint8Array): void;
}

declare const bindings: Promise<typeof proj>;
declare const bindings: Promise<typeof PROJ>;
export default bindings;
1 change: 0 additions & 1 deletion lib/native.d.cts

This file was deleted.

2 changes: 0 additions & 2 deletions lib/wasm.d.mts

This file was deleted.

13 changes: 7 additions & 6 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ if get_option('inline_projdb') and meson.get_compiler('cpp').get_id() == 'emscri
add_project_arguments([ '-DINLINE_PROJDB' ], language: 'cpp')
inline_projdb = true
endif
if get_option('debug')
add_project_arguments([ '-DDEBUG' ], language: [ 'cpp', 'c' ])
endif
if meson.get_compiler('cpp').get_id() == 'emscripten'
add_project_arguments([ '-Wno-documentation' ], language: [ 'cpp', 'c' ])
add_project_arguments([ '-Wno-potentially-evaluated-expression' ], language: [ 'cpp' ])
endif

# Build PROJ and its dependencies
cmake = import('cmake')
Expand Down Expand Up @@ -103,12 +110,6 @@ main_target = napi.extension_module(
}
)

# --------------------
# SWIG generated JS/TS
# --------------------
install_data('swig' / 'proj.d.ts', install_dir: data_dir)
install_data('swig' / 'proj_wrap.cjs', install_dir: '.')

# --------------------
# The special case of proj.db
# --------------------
Expand Down
4 changes: 2 additions & 2 deletions lib/native.cjs → native/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
const process = require('node:process');
const path = require('node:path');
const os = require('node:os');
process.env['PROJ_DATA'] = path.resolve(__dirname, 'binding', 'proj');
module.exports = require(path.resolve(__dirname, 'binding', `${os.platform()}-${os.arch()}`, 'proj_wrap.cjs'));
process.env['PROJ_DATA'] = path.resolve(__dirname, '..', 'lib', 'binding', 'proj');
module.exports = require(path.resolve(__dirname, '..', 'lib', 'binding', `${os.platform()}-${os.arch()}`, 'proj.node'));
1 change: 1 addition & 0 deletions native/index.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../swig/proj.d.ts';
2 changes: 1 addition & 1 deletion lib/native.mjs → native/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* import qPROJ from 'proj.js';
* const PROJ = await qPROJ;
*/
import _PROJ from './native.cjs';
import _PROJ from '../swig/proj_wrap.cjs';

const PROJ = Promise.resolve(_PROJ);

Expand Down
140 changes: 108 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6b1ed59

Please sign in to comment.