Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
xasopheno committed Dec 29, 2024
1 parent 78446ec commit d8f9c56
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 17 deletions.
43 changes: 30 additions & 13 deletions .github/workflows/cool_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,34 +62,51 @@ jobs:
run: just test

macos:
runs-on: macos-latest
runs-on: macos-latest

steps:
- name: Install dependencies
run: |
brew update
brew install lame libvorbis just
- name: Debug environment
run: |
which lame
- name: Set library path
run: |
export LIBRARY_PATH=/opt/homebrew/lib:$LIBRARY_PATH
export LD_LIBRARY_PATH=/opt/homebrew/lib:$LD_LIBRARY_PATH
steps:
- name: install dependancies
run: brew install lame libvorbis just
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
toolchain: stable
override: true

- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
key: "weresocool-windows"
- name: run tests
key: "weresocool-macos"

- name: Run tests
env:
LIBRARY_PATH: /opt/homebrew/lib:$LIBRARY_PATH
LD_LIBRARY_PATH: /opt/homebrew/lib:$LD_LIBRARY_PATH
run: just test

windows:
runs-on: windows-latest
steps:
- name: start audiosrv
run: net start audiosrv
- name: install scream
- name: Install scream (non-admin)
run: |
Invoke-WebRequest https://github.com/duncanthrax/scream/releases/download/3.8/Scream3.8.zip -OutFile Scream3.8.zip
Expand-Archive -Path Scream3.8.zip -DestinationPath Scream
Import-Certificate -FilePath Scream\Install\driver\x64\Scream.cat -CertStoreLocation Cert:\LocalMachine\TrustedPublisher
Scream\Install\helpers\devcon-x64.exe install Scream\Install\driver\x64\Scream.inf *Scream
Invoke-WebRequest https://github.com/duncanthrax/scream/releases/download/3.8/Scream3.8.zip -OutFile Scream3.8.zip
Expand-Archive -Path Scream3.8.zip -DestinationPath Scream
Write-Host "Skipping certificate and driver installation due to lack of admin privileges."
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
Expand Down
40 changes: 36 additions & 4 deletions src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ mod cli_tests {
#[cfg(target_os = "linux")]
let expected_filename = "src/test_data/play_unix.mp3";

dbg!(&expected_filename);

let written_filename = format!("{}/play.mp3", tmp_dir.path().display());
assert_same_bytes(expected_filename, &written_filename);
}
Expand Down Expand Up @@ -189,11 +191,41 @@ mod cli_tests {

fn assert_same_bytes(expected_filename: &str, written_filename: &str) {
let written_read =
std::fs::read(written_filename).expect("Something went wrong reading file");
let expected_read =
std::fs::read(expected_filename).expect("Something went wrong reading file");
std::fs::read(written_filename).expect("Something went wrong reading the written file");
let expected_read = std::fs::read(expected_filename)
.expect("Something went wrong reading the expected file");

// Compare file sizes first
if written_read.len() != expected_read.len() {
eprintln!(
"File size mismatch: expected {} bytes, got {} bytes",
expected_read.len(),
written_read.len()
);
}

assert!(written_read == expected_read);
// Compare full content byte by byte
for (i, (w, e)) in written_read.iter().zip(expected_read.iter()).enumerate() {
if w != e {
eprintln!(
"Mismatch at byte {}: expected 0x{:02x}, got 0x{:02x}",
i, e, w
);

// Print a side-by-side view of the bytes for further analysis
let start = i.saturating_sub(16);
let end = (i + 16).min(written_read.len()).min(expected_read.len());
eprintln!("Context around mismatch:");
eprintln!("Expected: {:x?}", &expected_read[start..end]);
eprintln!("Written : {:x?}", &written_read[start..end]);
panic!("Files differ at byte {}", i);
}
}

// If no mismatch was found
if written_read == expected_read {
println!("Files match!");
}
}

fn assert_same_file_contents(expected_filename: &str, written_filename: &str) {
Expand Down

0 comments on commit d8f9c56

Please sign in to comment.