From 85c80542a5c52311fdde71459a924d87ec95cc93 Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Fri, 1 Aug 2014 14:19:45 -0700 Subject: pactest: only snapshot needed files Only a few of our tests need file snapshots at all and most of them only need a few files. Taking snapshots of the entire test environment for every single test is a massive waste. Signed-off-by: Andrew Gregory Signed-off-by: Allan McRae --- test/pacman/pmrule.py | 6 ++++++ test/pacman/pmtest.py | 17 +++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) (limited to 'test/pacman') diff --git a/test/pacman/pmrule.py b/test/pacman/pmrule.py index a91741be..0eec8ea9 100644 --- a/test/pacman/pmrule.py +++ b/test/pacman/pmrule.py @@ -32,6 +32,12 @@ class pmrule(object): def __str__(self): return self.rule + def snapshots_needed(self): + (testname, args) = self.rule.split("=") + if testname == "FILE_MODIFIED" or testname == "!FILE_MODIFIED": + return [args] + return [] + def check(self, test): """ """ diff --git a/test/pacman/pmtest.py b/test/pacman/pmtest.py index 7079b78e..78b9e2d1 100644 --- a/test/pacman/pmtest.py +++ b/test/pacman/pmtest.py @@ -183,12 +183,17 @@ class pmtest(object): # Done. vprint(" Taking a snapshot of the file system") - for roots, dirs, files in os.walk(self.root): - for i in files: - filename = os.path.join(roots, i) - f = pmfile.PacmanFile(self.root, filename.replace(self.root + "/", "")) - self.files.append(f) - vprint("\t%s" % f.name) + for filename in self.snapshots_needed(): + f = pmfile.PacmanFile(self.root, filename) + self.files.append(f) + vprint("\t%s" % f.name) + + + def snapshots_needed(self): + files = set() + for r in self.rules: + files.update(r.snapshots_needed()) + return files def run(self, pacman): if os.path.isfile(util.PM_LOCK): -- cgit v1.2.3