Skip to content

Commit

Permalink
Split feature tests and examples (#117)
Browse files Browse the repository at this point in the history
* Move feature_tests to new folder

* Move tests over

* Rescope under include/

* Regen everything

* Add new regen script

* Update CI
  • Loading branch information
Manishearth authored Dec 21, 2021
1 parent 27e52e2 commit b448e1e
Show file tree
Hide file tree
Showing 88 changed files with 1,184 additions and 409 deletions.
28 changes: 19 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,39 @@ jobs:
run: cd example && ./gen_all.sh
- name: Test example is fresh
run: git diff --exit-code
example:
tests-and-example:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build
- name: Build tests
run: cd feature_tests && cargo build
- name: CPP tests
run: cd feature_tests/cpp && make CXX=g++-10
- name: Build examples
run: cd example && cargo build
- name: CPP
- name: CPP examples
run: cd example/cpp && make CXX=g++-10
- name: C
- name: C examples
run: cd example/c && make
example-wasm:
tests-and-example-wasm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Load Rust toolchain for WASM.
run: rustup target add wasm32-unknown-unknown
- name: Build
run: cd example && cargo build --target wasm32-unknown-unknown
- name: Install Node.js v14.17.0
uses: actions/setup-node@v1
with:
node-version: 14.17.0
- name: install node deps
- name: Build feature tests
run: cd feature_tests && cargo build --target wasm32-unknown-unknown
- name: install node deps for feature_tests
run: cd feature_tests/js && npm install
- name: test feature_tests
run: cd feature_tests/js && npm run test
- name: Build examples
run: cd example && cargo build --target wasm32-unknown-unknown
- name: install node deps for example
run: cd example/js && npm install
- name: test
- name: test example
run: cd example/js && npm run test
34 changes: 21 additions & 13 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ members = [
"macro",
"runtime",
"tool",
"example"
"example",
"feature_tests",
]
2 changes: 1 addition & 1 deletion example/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "example"
name = "diplomat-example"
version = "0.2.0"
authors = ["Shadaj Laddad <[email protected]>"]
edition = "2018"
Expand Down
6 changes: 3 additions & 3 deletions example/c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ $(ALL_RUST):
$(ALL_HEADERS):


../../target/debug/libexample.a: $(ALL_RUST)
../../target/debug/libdiplomat_example.a: $(ALL_RUST)
cargo build

a.out: ../../target/debug/libexample.a $(ALL_HEADERS) main.c
$(CC) main.c ../../target/debug/libexample.a -ldl -lpthread -lm -g
a.out: ../../target/debug/libdiplomat_example.a $(ALL_HEADERS) main.c
$(CC) main.c ../../target/debug/libdiplomat_example.a -ldl -lpthread -lm -g

build: a.out

Expand Down
20 changes: 6 additions & 14 deletions example/cpp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,16 @@ $(ALL_RUST):
$(ALL_HEADERS):


../../target/debug/libexample.a: $(ALL_RUST)
../../target/debug/libdiplomat_example.a: $(ALL_RUST)
cargo build

./tests/fixeddecimal.out: ../../target/debug/libexample.a $(ALL_HEADERS) ./tests/fixeddecimal.cpp
$(CXX) -std=c++17 ./tests/fixeddecimal.cpp ../../target/debug/libexample.a -ldl -lpthread -lm -g -o ./tests/fixeddecimal.out
./tests/fixeddecimal.out: ../../target/debug/libdiplomat_example.a $(ALL_HEADERS) ./tests/fixeddecimal.cpp
$(CXX) -std=c++17 ./tests/fixeddecimal.cpp ../../target/debug/libdiplomat_example.a -ldl -lpthread -lm -g -o ./tests/fixeddecimal.out

./tests/fixeddecimal-20.out: ../../target/debug/libexample.a $(ALL_HEADERS) ./tests/fixeddecimal.cpp
$(CXX) -std=c++20 ./tests/fixeddecimal.cpp ../../target/debug/libexample.a -ldl -lpthread -lm -g -o ./tests/fixeddecimal-20.out
./tests/fixeddecimal-20.out: ../../target/debug/libdiplomat_example.a $(ALL_HEADERS) ./tests/fixeddecimal.cpp
$(CXX) -std=c++20 ./tests/fixeddecimal.cpp ../../target/debug/libdiplomat_example.a -ldl -lpthread -lm -g -o ./tests/fixeddecimal-20.out

./tests/structs.out: ../../target/debug/libexample.a $(ALL_HEADERS) ./tests/structs.cpp
$(CXX) -std=c++17 ./tests/structs.cpp ../../target/debug/libexample.a -ldl -lpthread -lm -g -o ./tests/structs.out

./tests/result.out: ../../target/debug/libexample.a $(ALL_HEADERS) ./tests/result.cpp
$(CXX) -std=c++17 ./tests/result.cpp ../../target/debug/libexample.a -ldl -lpthread -lm -g -o ./tests/result.out


test: ./tests/fixeddecimal.out ./tests/fixeddecimal-20.out ./tests/structs.out ./tests/result.out
test: ./tests/fixeddecimal.out ./tests/fixeddecimal-20.out
./tests/fixeddecimal.out
./tests/fixeddecimal-20.out
./tests/structs.out
./tests/result.out
40 changes: 0 additions & 40 deletions example/cpp/ResultOpaque.h

This file was deleted.

2 changes: 0 additions & 2 deletions example/cpp/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ Documentation

data_provider_ffi
decimal_ffi
feature_tests_result_ffi
feature_tests_structs_ffi
fixed_decimal_ffi
locale_ffi

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion example/cpp/tests/fixeddecimal.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <iostream>
#include "../ICU4XFixedDecimalFormat.hpp"
#include "../include/ICU4XFixedDecimalFormat.hpp"
#include "assert.hpp"

int main(int argc, char *argv[]) {
Expand Down
2 changes: 1 addition & 1 deletion example/gen_all.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
../target/debug/diplomat-tool js js/ --docs js/docs/
../target/debug/diplomat-tool c c/
../target/debug/diplomat-tool cpp cpp/ --docs cpp/docs/
../target/debug/diplomat-tool cpp cpp/include --docs cpp/docs/
Loading

0 comments on commit b448e1e

Please sign in to comment.