Add the test command

This commit is contained in:
Graham Christensen 2017-11-24 14:08:00 -05:00
parent 53308f057b
commit 20c4d2a302
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C
2 changed files with 35 additions and 0 deletions

View file

@ -20,6 +20,20 @@ Commands:
@grahamcofborg build list of attrs @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 @grahamcofborg eval
``` ```

View file

@ -23,6 +23,17 @@ pub fn parse(text: &str) -> Option<Vec<Instruction>> {
"build" => { "build" => {
instructions.push(Instruction::Build(Subset::Nixpkgs, right.to_vec())) 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" => { "eval" => {
instructions.push(Instruction::Eval) instructions.push(Instruction::Eval)
} }
@ -119,6 +130,16 @@ mod tests {
baz")); 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] #[test]
fn build_comment_newlines() { fn build_comment_newlines() {
assert_eq!(Some(vec![Instruction::Build(Subset::Nixpkgs, vec![ assert_eq!(Some(vec![Instruction::Build(Subset::Nixpkgs, vec![