Skip to content

Commit 4f6422a

Browse files
committed
Add basic rust wrapper
1 parent 740e234 commit 4f6422a

File tree

6 files changed

+91
-1
lines changed

6 files changed

+91
-1
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,36 @@ jobs:
1010
- uses: actions/checkout@v4
1111
- name: Check Whitespace
1212
run: git diff --check -- HEAD~1
13+
rust-build:
14+
strategy:
15+
matrix:
16+
os:
17+
- runner: ubuntu-latest
18+
arch: x86_64
19+
- runner: ubuntu-24.04-arm
20+
arch: aarch64
21+
- runner: macos-15
22+
arch: aarch64
23+
name: Rust Build (${{ matrix.os.runner }}-${{ matrix.os.arch }})
24+
runs-on: ${{ matrix.os.runner }}
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: actions/cache@v4
28+
with:
29+
path: |
30+
target/
31+
~/.cargo/bin/
32+
~/.cargo/git/db/
33+
~/.cargo/registry/cache/
34+
~/.cargo/registry/index/
35+
~/.rustup
36+
key: ${{ matrix.os.runner }}-${{ matrix.os.arch }}-rust-${{ hashFiles('.github/workflows/ci.yml', 'Cargo.lock', 'rust-toolchain.yaml') }}
37+
- name: Run fmt
38+
run: cargo fmt --check
39+
- name: Build release
40+
run: cargo build --release
41+
- name: Run clippy
42+
run: cargo clippy --release
1343
ruby-spec:
1444
name: Unit Specs
1545
runs-on: ${{ matrix.os }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/.bundle
2+
/Cargo.lock
3+
/target
24
/tmp
3-
/.bundle

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[workspace]
2+
resolver = "2"
3+
members = ["mutant"]

mutant/Cargo.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "mutant"
3+
version = "0.13.9"
4+
edition = "2021"
5+
authors = ["Markus Schirp <[email protected]>"]
6+
license = "Nonstandard"
7+
description = "Mutation Testing"
8+
homepage = "https://github.com/mbj/mutant"
9+
repository = "https://github.com/mbj/mutant"
10+
readme = "../README.md"
11+
12+
[[bin]]
13+
name = "mutant"
14+
path = "src/main.rs"
15+
16+
[dependencies]
17+
clap = { version = "4.5", features = ["derive"] }
18+
log = "0.4"
19+
env_logger = "0.11"
20+
21+
[dev-dependencies]

mutant/src/main.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
use log::warn;
2+
use std::env;
3+
use std::os::unix::process::CommandExt;
4+
use std::process::Command;
5+
6+
fn main() {
7+
env_logger::Builder::from_default_env()
8+
.filter_level(log::LevelFilter::Warn)
9+
.init();
10+
11+
let args: Vec<String> = env::args().collect();
12+
13+
// For now, always delegate to Ruby with a warning
14+
warn!("Rust wrapper did not handle this command yet, delegating to Ruby implementation");
15+
16+
exec_ruby_mutant(&args[1..]);
17+
}
18+
19+
fn exec_ruby_mutant(args: &[String]) {
20+
env::set_current_dir("ruby").unwrap_or_else(|error| {
21+
panic!("Failed to change to ruby directory: {}", error);
22+
});
23+
24+
let error = Command::new("bundle")
25+
.arg("exec")
26+
.arg("mutant")
27+
.args(args)
28+
.exec();
29+
30+
panic!("Failed to execute Ruby mutant: {}", error);
31+
}

rust-toolchain.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[toolchain]
2+
channel = "1.91.1"
3+
components = ["rustfmt", "clippy"]
4+
targets = ["x86_64-unknown-linux-musl", "aarch64-unknown-linux-musl"]

0 commit comments

Comments
 (0)