From b251a188da57e69a5a3da2fbb4b6b6a23cfeb7a3 Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Fri, 21 Oct 2016 18:53:06 +0200 Subject: [PATCH] project: move config verify into project module Signed-off-by: Tobias Ulmer --- local/e2tool.lua | 38 ++++++-------------------------------- local/project.lua | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/local/e2tool.lua b/local/e2tool.lua index 98fce35..76e65e1 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -320,33 +320,6 @@ function e2tool.sourceconfig(name, prefix) return e2lib.join(e2tool.sourcedir(name, prefix), "config") end ---- Checks project information for consistancy. --- @return True on success, false on error. --- @return Error object on failure. -local function check_project_info() - local rc, re, e - e = err.new("error in project configuration") - - for r in project.default_results_iter() do - if not result.results[r] then - e:append("default_results: No such result: %s", r) - end - end - for r in project.deploy_results_iter() do - if not result.results[r] then - e:append("deploy_results: No such result: %s", r) - end - end - if e:getcount() > 1 then - return false, e - end - rc, re = e2tool.dsort() - if not rc then - return false, e:cat(re) - end - return true -end - --- collect project info. -- @param info Info table. -- @param skip_load_config If true, skip loading config files etc. @@ -468,6 +441,12 @@ function e2tool.collect_project_info(info, skip_load_config) return false, e:cat(re) end + -- after results are loaded, verify the project configuration + rc, re = project.verify_project_config() + if not rc then + return false, e:cat(re) + end + if e:getcount() > 1 then return false, e end @@ -549,11 +528,6 @@ function e2tool.collect_project_info(info, skip_load_config) end end - rc, re = check_project_info() - if not rc then - return false, re - end - return strict.lock(info) end diff --git a/local/project.lua b/local/project.lua index 2aa2877..74318bb 100644 --- a/local/project.lua +++ b/local/project.lua @@ -28,6 +28,7 @@ local e2tool = require("e2tool") local err = require("err") local hash = require("hash") local projenv = require("projenv") +local result = require("result") local strict = require("strict") local _prj = {} @@ -168,6 +169,34 @@ function project.load_project_config(info) return true end +--- Checks project information for consistancy once results are loaded. +-- @return True on success, false on error. +-- @return Error object on failure. +function project.verify_project_config() + local rc, re, e + e = err.new("error in project configuration") + + for r in project.default_results_iter() do + if not result.results[r] then + e:append("default_results: No such result: %s", r) + end + end + for r in project.deploy_results_iter() do + if not result.results[r] then + e:append("deploy_results: No such result: %s", r) + end + end + if e:getcount() > 1 then + return false, e + end + + rc, re = e2tool.dsort() + if not rc then + return false, e:cat(re) + end + return true +end + --- Get project name. -- @return Name. function project.name() -- 2.39.5