Skip to content

Commit da63b0b

Browse files
authored
Merge pull request boj-rs#60 from byeongkeunahn/fix-test
Fix test/bench
2 parents 25ed182 + 56052c5 commit da63b0b

File tree

7 files changed

+37
-6
lines changed

7 files changed

+37
-6
lines changed

.cargo/config.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build]
2-
rustflags = ["-Z", "export-executable-symbols", "-C", "target-feature=+avx,+avx2,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+fma,+f16c,+aes", "-C", "relocation-model=pie", "-C", "target-cpu=haswell"]
2+
rustflags = ["-Z", "share-generics=no", "-Z", "export-executable-symbols", "-C", "target-feature=+avx,+avx2,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+fma,+f16c,+aes", "-C", "relocation-model=pie", "-C", "target-cpu=haswell"]
33

44
[target.wasm32-unknown-unknown]
5-
rustflags = ["-C", "link-args=-z stack-size=67108864"]
5+
rustflags = ["-Z", "share-generics=no", "-C", "link-args=-z stack-size=67108864"]

.github/workflows/build-linux.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ jobs:
4747
- name: Test
4848
if: ${{ matrix.target != 'wasm32-unknown-unknown' }}
4949
run: cargo test --lib -- --test-threads 1
50-
env:
51-
RUSTFLAGS: ""
5250
- name: Check C (x86_64)
5351
if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }}
5452
run: |

.github/workflows/build-windows.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ jobs:
4848
- name: Test
4949
if: ${{ matrix.target != 'wasm32-unknown-unknown' }}
5050
run: cargo test --lib -- --test-threads 1
51-
env:
52-
RUSTFLAGS: ""
5351
- name: Check C (x86_64)
5452
if: ${{ matrix.target == 'x86_64-pc-windows-msvc' }}
5553
run: |

basm/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ edition = "2021"
55
default-run = "basm"
66
autobins = false
77

8+
[lib]
9+
test = true
10+
bench = true
11+
path = "src/bin/basm-lib.rs"
12+
813
[[bin]]
914
name = "basm"
1015
test = false

basm/src/bin/basm-lib.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#![feature(fn_align)]
2+
#![feature(maybe_uninit_uninit_array)]
3+
#![feature(maybe_uninit_slice)]
4+
#![feature(maybe_uninit_array_assume_init)]
5+
#![feature(naked_functions)]
6+
#![feature(alloc_error_handler)]
7+
#![cfg_attr(not(test), no_builtins)]
8+
#![cfg_attr(not(test), no_std)]
9+
#![cfg_attr(not(test), no_main)]
10+
extern crate alloc;
11+
12+
extern crate basm_std as basm;
13+
14+
#[allow(dead_code)]
15+
#[path = "../solution.rs"]
16+
mod solution;
17+
18+
#[cfg(test)]
19+
mod verify_test_works {
20+
fn add(x: i64, y: i64) -> i64 {
21+
x + y
22+
}
23+
24+
#[test]
25+
fn run() {
26+
assert_eq!(8, add(5, 3));
27+
}
28+
}

basm/src/bin/basm-submit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ extern crate basm_std as basm;
1616
mod solution;
1717
mod codegen;
1818

19+
#[cfg(not(test))]
1920
#[panic_handler]
2021
fn panic(_pi: &core::panic::PanicInfo) -> ! {
2122
unsafe { core::hint::unreachable_unchecked() }

basm/src/bin/basm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ extern crate basm_std as basm;
1616
mod solution;
1717
mod codegen;
1818

19+
#[cfg(not(test))]
1920
#[panic_handler]
2021
fn panic(_pi: &core::panic::PanicInfo) -> ! {
2122
use alloc::string::ToString;

0 commit comments

Comments
 (0)