[3/4] Add warn-on-fail for non-critical tests
diff mbox series

Message ID 20180208020140.20903-3-andrew.donnellan@au1.ibm.com
State Accepted
Headers show
Series
  • [1/4] Upstream Patchwork support
Related show

Commit Message

Andrew Donnellan Feb. 8, 2018, 2:01 a.m. UTC
From: Russell Currey <ruscur@russell.cc>

Signed-off-by: Russell Currey <ruscur@russell.cc>
[ajd: rebase on serde changes]
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
---
 src/main.rs     |  5 ++++-
 src/settings.rs | 10 ++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/src/main.rs b/src/main.rs
index 82beac6b2ab3..b1b143babdcc 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -140,8 +140,11 @@  fn run_tests(settings: &Config, client: Arc<Client>, project: &Project, tag: &st
         }
         debug!("Build URL: {}", build_url_real);
         jenkins.wait_build(&build_url_real);
-        let test_result = jenkins.get_build_result(&build_url_real).unwrap();
+        let mut test_result = jenkins.get_build_result(&build_url_real).unwrap();
         info!("Jenkins job for {}/{} complete.", branch_name, job.title);
+        if test_result == TestState::Fail && job.warn_on_fail {
+            test_result = TestState::Warning;
+        }
         results.push(TestResult {
             description: Some(format!("Test {} on branch {}", job.title,
                                       branch_name.to_string()).to_string()),
diff --git a/src/settings.rs b/src/settings.rs
index 7e3c87ddd0ac..0ce70313b3dd 100644
--- a/src/settings.rs
+++ b/src/settings.rs
@@ -81,6 +81,7 @@  pub struct Job {
     pub remote: String,
     pub branch: String,
     pub hefty: bool,
+    pub warn_on_fail: bool,
     pub parameters: BTreeMap<String, String>,
 }
 
@@ -105,6 +106,7 @@  impl<'de> Deserialize<'de> for Job {
                 let mut remote = None;
                 let mut branch = None;
                 let mut hefty = None;
+                let mut warn_on_fail = None;
                 let mut parameters = BTreeMap::new();
                 while let Some(key) = map.next_key::<String>()? {
                     match key.as_str() {
@@ -138,6 +140,12 @@  impl<'de> Deserialize<'de> for Job {
                             }
                             hefty = Some(map.next_value()?);
                         }
+                        "warn_on_fail" => {
+                            if warn_on_fail.is_some() {
+                                return Err(de::Error::duplicate_field("warn_on_fail"));
+                            }
+                            warn_on_fail = Some(map.next_value()?);
+                        }
                         _ => {
                             parameters.insert(key, map.next_value()?);
                         }
@@ -149,6 +157,7 @@  impl<'de> Deserialize<'de> for Job {
                 let branch = branch.ok_or_else(|| de::Error::missing_field("branch"))?;
                 let title = title.unwrap_or(job.clone());
                 let hefty = hefty.unwrap_or(false);
+                let warn_on_fail = warn_on_fail.unwrap_or(false);
 
                 Ok(Job {
                     job: job,
@@ -156,6 +165,7 @@  impl<'de> Deserialize<'de> for Job {
                     remote: remote,
                     branch: branch,
                     hefty: hefty,
+                    warn_on_fail: warn_on_fail,
                     parameters: parameters,
                 })
             }