Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Rust testing Action #849

Merged
merged 9 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions .github/workflows/testproject.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test backend
name: Test project

on:
push:
Expand All @@ -9,19 +9,32 @@ on:

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
build:
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential curl libssl-dev pkg-config

- name: Install Rust
run: rustup update stable

- name: Set up user environment on macOS
run: |
mkdir -p $HOME/Downloads
mkdir -p $HOME/Desktop
mkdir -p $HOME/Documents
echo "XDG_DOWNLOAD_DIR=$HOME/Downloads" >> $GITHUB_ENV
echo "XDG_DESKTOP_DIR=$HOME/Desktop" >> $GITHUB_ENV
echo "XDG_DOCUMENTS_DIR=$HOME/Documents" >> $GITHUB_ENV
echo "HOME_DIR set to $HOME"
ls -la $HOME # Verify the user directories

- name: Build
run: cargo build --verbose
run: cargo build --verbose --release

- name: Run tests
run: cargo test --workspace --verbose
run: cargo test --verbose --release
env:
IGNORE_PANICS: true
19 changes: 17 additions & 2 deletions src/tests/file_scanner_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#[cfg(test)]
mod tests {

#[test]
fn test_filescanner_invalid_path() {
use crate::backend::yara_scanner::YaraScanner;
Expand All @@ -24,13 +25,20 @@ mod tests {

#[test]
fn test_scan_file_found_none() {
use crate::backend::yara_scanner::YaraScanner;
use crate::backend::{downloader, yara_scanner::YaraScanner};
use iced::futures::channel::mpsc;
use std::{
path::Path,
sync::{Arc, Mutex},
};

let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();
let update = runtime.block_on(downloader::update());
dbg!(&update);

std::fs::write(
Path::new("./clean"),
"Test content of a file with no particular malicious intent".to_owned(),
Expand All @@ -53,13 +61,20 @@ mod tests {

#[test]
fn test_scan_file_found_one() {
use crate::backend::yara_scanner::YaraScanner;
use crate::backend::{downloader, yara_scanner::YaraScanner};
use iced::futures::channel::mpsc;
use std::{
path::Path,
sync::{Arc, Mutex},
};

let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();
let update = runtime.block_on(downloader::update());
dbg!(&update);

std::fs::write(
Path::new("./tag"),
"X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*".to_owned(),
Expand Down
Loading