diff --git a/.travis.yml b/.travis.yml index 6825260..45d6696 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,5 +2,6 @@ language: nix matrix: include: - script: - - nix-shell --run 'cd ofborg && cargo test --lib -- --nocapture' - - nix-shell --run 'cd ofborg && cargo test --lib -- --nocapture' --arg useNix1 true + - nix-shell --run checkPhase + - nix-shell --run checkPhase --arg useNix1 true + - nix-build -A ofborg.rs diff --git a/nix/nixpkgs.json b/nix/nixpkgs.json index 18ce7f6..f0e97b4 100644 --- a/nix/nixpkgs.json +++ b/nix/nixpkgs.json @@ -1,7 +1,7 @@ { "url": "https://github.com/nixos/nixpkgs-channels.git", - "rev": "c2fbd472a4ebaae739257a3df93aef25f19dd04f", - "date": "2018-02-23T08:08:30+00:00", - "sha256": "07mir6nqb98mbykabppgj4dli66h18qsyi4zqp640x22k6bkp2vp", + "rev": "2e855dc6b0cd88767a8a5df2faff9e66e1cd7f18", + "date": "2018-04-11T10:16:39+08:00", + "sha256": "08s6mfh5a05kd2qs3hmza50ng3pyhd3qha4nanwwk0s8fjzqnv4a", "fetchSubmodules": true } diff --git a/ofborg/build.rs b/ofborg/build.rs index 4881c36..58ca368 100644 --- a/ofborg/build.rs +++ b/ofborg/build.rs @@ -518,24 +518,27 @@ impl MetricCollector { .map(|mtype| { let fields: Vec = mtype.enum_field_names(); - let variant_match: String; - if fields.len() > 0 { - variant_match = format!("{}({})", &mtype.variant(), fields.join(", ")); + let variant_match = if fields.len() > 0 { + format!("{}({})", &mtype.variant(), fields.join(", ")) } else { - variant_match = format!("{}", &mtype.variant()); + format!("{}", &mtype.variant()) + }; + + let mut index_names: Vec = mtype.enum_index_names(); + index_names.push("instance".to_owned()); + + let mut index_fields = index_names.join(", "); + if index_names.len() > 1 { + index_fields = format!("({})", index_fields); } - let mut index_fields: Vec = mtype.enum_index_names(); - index_fields.push("instance".to_owned()); - - format!(" Event::{} => {{ let mut accum_table = self.{} .lock() .expect(\"Failed to unwrap metric mutex for {}\"); let accum = accum_table - .entry(({})) + .entry({}) .or_insert(0); *accum += {}; }} @@ -543,7 +546,7 @@ impl MetricCollector { variant_match, &mtype.metric_name(), &mtype.metric_name(), - index_fields.join(", "), + index_fields, &mtype.record_value(), ) }).collect(); diff --git a/shell.nix b/shell.nix index 9843aec..5a35ebe 100644 --- a/shell.nix +++ b/shell.nix @@ -15,7 +15,7 @@ let curl bash ] - ++ stdenv.lib.optional useNix1 nix; + ++ stdenv.lib.optional useNix1 nix1; # HISTFILE = "${src}/.bash_hist"; }; @@ -32,10 +32,18 @@ let pkgconfig git ] - ++ stdenv.lib.optional useNix1 nix + ++ stdenv.lib.optional useNix1 nix1 ++ stdenv.lib.optional stdenv.isDarwin pkgs.darwin.Security; + postHook = '' + checkPhase() { + ( cd "${builtins.toString ./.}/ofborg" && cargo test --lib ) + } + ''; + HISTFILE = "${toString ./.}/.bash_hist"; + RUSTFLAGS = "-D warnings"; + passthru.phpEnv = phpEnv; };