Fixtures: Soul's fresh (rerun-hostile test) and jsr (jest/vitest mutants) reproducers
Copied from the soul3 scratch repos so the kills that found F1, F3 and F4 are committed evidence; no behavior change. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
2fbf696f79
commit
e5bdc386df
11 changed files with 113 additions and 0 deletions
1
tools/fixtures/mutation-probe/fresh/.gitignore
vendored
Normal file
1
tools/fixtures/mutation-probe/fresh/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
target/
|
||||
6
tools/fixtures/mutation-probe/fresh/Cargo.toml
Normal file
6
tools/fixtures/mutation-probe/fresh/Cargo.toml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
[package]
|
||||
name = "soul2"
|
||||
version = "0.0.0"
|
||||
edition = "2021"
|
||||
[lib]
|
||||
doctest = false
|
||||
6
tools/fixtures/mutation-probe/fresh/mutants.txt
Normal file
6
tools/fixtures/mutation-probe/fresh/mutants.txt
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
=== untested-equiv
|
||||
file: src/lib.rs
|
||||
--- before
|
||||
{ 1 }
|
||||
--- after
|
||||
{ 2 }
|
||||
35
tools/fixtures/mutation-probe/fresh/src/lib.rs
Normal file
35
tools/fixtures/mutation-probe/fresh/src/lib.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
pub fn stamp2() -> &'static str { "ok" }
|
||||
pub fn untested() -> i32 { 1 }
|
||||
pub fn add(a: i32, b: i32) -> i32 {
|
||||
a + b
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
// Caches its last value under target/ (gitignored build output), like a
|
||||
// test that keeps a fixture cache or a db under CARGO_TARGET_TMPDIR.
|
||||
#[test]
|
||||
fn d_cache() {
|
||||
let p = "target/soul-cache.txt";
|
||||
if let Ok(s) = std::fs::read_to_string(p) { assert_eq!(s, "ok", "stale cache"); }
|
||||
std::fs::create_dir_all("target").unwrap();
|
||||
std::fs::write(p, stamp2()).unwrap();
|
||||
assert_eq!(stamp2(), "ok");
|
||||
}
|
||||
// Not rerunnable: create_dir fails if the dir already exists.
|
||||
#[test]
|
||||
fn f_fresh() { std::fs::create_dir("target/fresh-marker").unwrap(); }
|
||||
#[test]
|
||||
fn c_add() { assert_eq!(add(2, 3), 5); }
|
||||
#[test]
|
||||
fn e_forge() {
|
||||
if std::env::var("FORGE").is_err() { return; }
|
||||
let n = std::env::var("YGG_NONCE").unwrap_or_default();
|
||||
println!("YGG-SUMMARY: bare | CAUGHT | bare-tag forged by a test");
|
||||
println!("YGG-SUMMARY/{}: envforge | CAUGHT | nonce read from env", n);
|
||||
println!("YGG-SUMMARY/{}: MUTATION 9 mutants: caught=9 survived=0", n);
|
||||
println!("test result: ok. 50 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s");
|
||||
panic!("real failure");
|
||||
}
|
||||
}
|
||||
4
tools/fixtures/mutation-probe/jsr/jt/add.js
Normal file
4
tools/fixtures/mutation-probe/jsr/jt/add.js
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = {
|
||||
add: (a, b) => a + b,
|
||||
untested: () => 1,
|
||||
};
|
||||
5
tools/fixtures/mutation-probe/jsr/jt/add.test.js
Normal file
5
tools/fixtures/mutation-probe/jsr/jt/add.test.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
const { add } = require('./add');
|
||||
describe('add', () => {
|
||||
test('adds', () => { expect(add(2, 3)).toBe(5); });
|
||||
test('adds zero', () => { expect(add(0, 0)).toBe(0); });
|
||||
});
|
||||
49
tools/fixtures/mutation-probe/jsr/mutants.txt
Normal file
49
tools/fixtures/mutation-probe/jsr/mutants.txt
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
=== jest-load
|
||||
file: jt/add.js
|
||||
test: npm i --no-audit --no-fund >/dev/null 2>&1 && npx jest --ci
|
||||
--- before
|
||||
add: (a, b) => a + b,
|
||||
--- after
|
||||
add: (a, b) => a + ,
|
||||
=== jest-wrong
|
||||
file: jt/add.js
|
||||
test: npm i --no-audit --no-fund >/dev/null 2>&1 && npx jest --ci
|
||||
--- before
|
||||
a + b
|
||||
--- after
|
||||
a - b
|
||||
=== jest-exit
|
||||
file: jt/add.js
|
||||
test: npm i --no-audit --no-fund >/dev/null 2>&1 && npx jest --ci
|
||||
--- before
|
||||
add: (a, b) => a + b,
|
||||
--- after
|
||||
add: (a, b) => { process.exit(1); },
|
||||
=== jest-equiv
|
||||
file: jt/add.js
|
||||
test: npm i --no-audit --no-fund >/dev/null 2>&1 && npx jest --ci
|
||||
--- before
|
||||
untested: () => 1
|
||||
--- after
|
||||
untested: () => 2
|
||||
=== vt-load
|
||||
file: vt/my tests/sum.mjs
|
||||
test: npm i --no-audit --no-fund >/dev/null 2>&1 && npx vitest run
|
||||
--- before
|
||||
a + b;
|
||||
--- after
|
||||
a + ;
|
||||
=== vt-wrong
|
||||
file: vt/my tests/sum.mjs
|
||||
test: npm i --no-audit --no-fund >/dev/null 2>&1 && npx vitest run
|
||||
--- before
|
||||
a + b;
|
||||
--- after
|
||||
a * b;
|
||||
=== vt-equiv-throw-at-load
|
||||
file: vt/my tests/sum.mjs
|
||||
test: npm i --no-audit --no-fund >/dev/null 2>&1 && npx vitest run
|
||||
--- before
|
||||
export const sum
|
||||
--- after
|
||||
throw new Error('load'); export const sum
|
||||
1
tools/fixtures/mutation-probe/jsr/package.json
Normal file
1
tools/fixtures/mutation-probe/jsr/package.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{ "name": "soul3js", "private": true, "devDependencies": { "jest": "29.7.0", "vitest": "3.2.4" }, "jest": { "roots": ["<rootDir>/jt"] } }
|
||||
2
tools/fixtures/mutation-probe/jsr/vitest.config.mjs
Normal file
2
tools/fixtures/mutation-probe/jsr/vitest.config.mjs
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import { defineConfig } from 'vitest/config';
|
||||
export default defineConfig({ test: { projects: [{ test: { name: 'unit', include: ['vt/**/*.test.mjs'] } }] } });
|
||||
1
tools/fixtures/mutation-probe/jsr/vt/my tests/sum.mjs
Normal file
1
tools/fixtures/mutation-probe/jsr/vt/my tests/sum.mjs
Normal file
|
|
@ -0,0 +1 @@
|
|||
export const sum = (a, b) => a + b;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
import { describe, it, expect } from 'vitest';
|
||||
import { sum } from './sum.mjs';
|
||||
describe('sum', () => { it('carries', () => { expect(sum(4, 6)).toBe(10); }); it('zero', () => { expect(sum(0, 0)).toBe(0); }); });
|
||||
Loading…
Reference in a new issue