Skip to content

Commit

Permalink
[General] Fixed test foldrs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dacode45 committed Dec 21, 2019
1 parent 91c0c67 commit 4976649
Show file tree
Hide file tree
Showing 33 changed files with 28 additions and 24 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
run: cargo build -p raylib --verbose
# - name: Run tests [Requires window system]
# run: cargo test -p raylib-test --verbose
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Cargo.lock
/.vscode
/.idea
raylib/test_out/*
!raylib/test_out/.gitkeep
raylib-test/test_out/*
!raylib-test/test_out/.gitkeep
raylib-test/storage.data
samples/savegame
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[workspace]
members = ["raylib", "raylib-sys", "samples"]
members = ["raylib", "raylib-sys", "raylib-test", "samples"]
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
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
15 changes: 7 additions & 8 deletions raylib-test/drawing.rs → raylib-test/src/drawing.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@

#[cfg(test)]
mod draw_test {
use raylib::prelude::*;
use crate::tests::*;
use raylib::prelude::*;
ray_draw_test!(test_pixel);
fn test_pixel(d: &mut RaylibDrawHandle<RaylibHandle>, _: &TestAssets) {
fn test_pixel(d: &mut RaylibDrawHandle, _: &TestAssets) {
d.clear_background(Color::WHITE);
d.draw_pixel(10, 10, Color::RED);
d.draw_pixel_v(Vector2::new(20.0, 20.0), Color::RED);
}
ray_draw_test!(test_line);
fn test_line(d: &mut RaylibDrawHandle<RaylibHandle>, _: &TestAssets) {
fn test_line(d: &mut RaylibDrawHandle, _: &TestAssets) {
d.clear_background(Color::WHITE);
d.draw_line(0, 5, 100, 5, Color::RED);
d.draw_line_v(
Expand All @@ -32,7 +31,7 @@ mod draw_test {
);
}
ray_draw_test!(test_circle);
fn test_circle(d: &mut RaylibDrawHandle<RaylibHandle>, _: &TestAssets) {
fn test_circle(d: &mut RaylibDrawHandle, _: &TestAssets) {
d.clear_background(Color::WHITE);
d.draw_circle(20, 20, 10.0, Color::RED);
d.draw_circle_v(Vector2::new(40.0, 20.0), 10.0, Color::RED);
Expand All @@ -45,7 +44,7 @@ mod draw_test {
}

ray_draw_test!(test_rectangle);
fn test_rectangle(d: &mut RaylibDrawHandle<RaylibHandle>, _: &TestAssets) {
fn test_rectangle(d: &mut RaylibDrawHandle, _: &TestAssets) {
d.clear_background(Color::WHITE);
d.draw_rectangle(10, 10, 10, 10, Color::RED);
d.draw_rectangle_v(
Expand Down Expand Up @@ -87,7 +86,7 @@ mod draw_test {
}

ray_draw_test!(test_triangle);
fn test_triangle(d: &mut RaylibDrawHandle<RaylibHandle>, _: &TestAssets) {
fn test_triangle(d: &mut RaylibDrawHandle, _: &TestAssets) {
d.clear_background(Color::WHITE);
d.draw_triangle(
Vector2::new(30.0, 30.0),
Expand All @@ -104,7 +103,7 @@ mod draw_test {
}

ray_draw_test!(test_poly);
fn test_poly(d: &mut RaylibDrawHandle<RaylibHandle>, _: &TestAssets) {
fn test_poly(d: &mut RaylibDrawHandle, _: &TestAssets) {
d.clear_background(Color::WHITE);
d.draw_poly(Vector2::new(100.0, 100.0), 12, 20.0, 45.0, Color::RED);
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion raylib-test/storage.rs → raylib-test/src/storage.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

#[cfg(test)]
mod core_test {
use super::*;
use crate::tests::*;
use raylib::prelude::*;

#[test]
fn test_storage() {
let mut handle = TEST_HANDLE.write().unwrap();
Expand Down
7 changes: 4 additions & 3 deletions raylib-test/tests.rs → raylib-test/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::test::{TestDescAndFn, TestFn};
use lazy_static::lazy_static;
use raylib::prelude::*;
use std::sync::RwLock;
use test::test::parse_opts;

pub const TEST_WIDTH: i32 = 640;
pub const TEST_HEIGHT: i32 = 480;
Expand Down Expand Up @@ -29,7 +30,7 @@ fn clone_testfn(testfn: &TestFn) -> TestFn {
pub fn test_runner(tests: &[&Testable]) {
let (thread, assets) = {
let mut handle = TEST_HANDLE.write().unwrap();
let (rl, thread) = crate::core::init()
let (rl, thread) = raylib::init()
.size(TEST_WIDTH, TEST_HEIGHT)
.title("Hello, World")
.build();
Expand All @@ -45,7 +46,7 @@ pub fn test_runner(tests: &[&Testable]) {
};

let args = std::env::args().collect::<Vec<_>>();
let opts = match test::parse_opts(&args) {
let opts = match parse_opts(&args) {
Some(Ok(o)) => o,
Some(Err(msg)) => panic!("{:?}", msg),
None => return,
Expand Down Expand Up @@ -127,7 +128,7 @@ pub struct RayTest {

pub struct RayDrawTest {
pub name: &'static str,
pub test: fn(&mut RaylibDrawHandle<RaylibHandle>, &TestAssets),
pub test: fn(&mut RaylibDrawHandle, &TestAssets),
}

macro_rules! ray_test {
Expand Down
7 changes: 3 additions & 4 deletions raylib-test/text.rs → raylib-test/src/text.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

#[cfg(test)]
mod text_test {
use raylib::prelude::*;
use crate::tests::*;
use raylib::prelude::*;
ray_test!(test_font_load);
fn test_font_load(thread: &RaylibThread) {
let mut handle = TEST_HANDLE.write().unwrap();
Expand All @@ -13,14 +12,14 @@ mod text_test {
}

ray_draw_test!(test_default_font);
fn test_default_font(d: &mut RaylibDrawHandle<RaylibHandle>, _: &TestAssets) {
fn test_default_font(d: &mut RaylibDrawHandle, _: &TestAssets) {
d.clear_background(Color::WHITE);
d.draw_fps(0, 0);
d.draw_text("Hello World", 100, 100, 32, Color::RED);
}

ray_draw_test!(test_custom_font);
fn test_custom_font(d: &mut RaylibDrawHandle<RaylibHandle>, assets: &TestAssets) {
fn test_custom_font(d: &mut RaylibDrawHandle, assets: &TestAssets) {
d.clear_background(Color::WHITE);
d.draw_fps(0, 0);
d.draw_text_ex(
Expand Down
File renamed without changes.
6 changes: 4 additions & 2 deletions raylib-test/window.rs → raylib-test/src/window.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

#[cfg(test)]
mod core_test {
use super::*;
use crate::core::camera::*;
use crate::tests::*;
use raylib::camera::*;
use raylib::math::*;
use raylib::RaylibThread;
#[test]
fn test_clipboard() {
let mut handle = TEST_HANDLE.write().unwrap();
Expand Down Expand Up @@ -40,6 +41,7 @@ mod core_test {
}

#[test]
#[cfg(not(target_os = "windows"))]
fn test_window_ops() {
// Call twice to make sure multiple calls won't panic
let mut handle = TEST_HANDLE.write().unwrap();
Expand Down
File renamed without changes.
Binary file removed raylib/storage.data
Binary file not shown.

0 comments on commit 4976649

Please sign in to comment.