diff --git a/README.md b/README.md index a310d69..c19bfb0 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,20 @@ Commands: @grahamcofborg build list of attrs ``` +This will run `nix-build ./default.nix -A list -A of -A attrs` in +the nixpkgs checkout. + +--- + +``` +@grahamcofborg test list of tests +``` + +This will run `nix-build ./nixos/default.nix -A tests.list -A tests.of -A tests.attrs` in +the nixpkgs checkout. Note: this will only run on x86_64-linux machines. + +--- + ``` @grahamcofborg eval ``` diff --git a/ofborg/src/commentparser.rs b/ofborg/src/commentparser.rs index 3eec94e..9a5effe 100644 --- a/ofborg/src/commentparser.rs +++ b/ofborg/src/commentparser.rs @@ -23,6 +23,17 @@ pub fn parse(text: &str) -> Option> { "build" => { instructions.push(Instruction::Build(Subset::Nixpkgs, right.to_vec())) } + "test" => { + instructions.push( + Instruction::Build(Subset::NixOS, + right + .into_iter() + .map(|attr| format!("tests.{}", attr)) + .collect() + ) + ); + + } "eval" => { instructions.push(Instruction::Eval) } @@ -119,6 +130,16 @@ mod tests { baz")); } + #[test] + fn test_comment() { + assert_eq!(Some(vec![Instruction::Build(Subset::NixOS, vec![ + String::from("tests.foo"), + String::from("tests.bar"), + String::from("tests.baz") + ])]), + parse("@GrahamCOfBorg test foo bar baz")); + } + #[test] fn build_comment_newlines() { assert_eq!(Some(vec![Instruction::Build(Subset::Nixpkgs, vec![