From 073717e07e68769a5878dd20cbe81eedbcd3e8b9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Oct 2011 17:07:10 +0200 Subject: [PATCH 01/11] some more relative to absolute path changes Signed-off-by: Nico Schottelius --- lib/cdist/config_install.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/cdist/config_install.py b/lib/cdist/config_install.py index c4c1af10..e6172a8c 100644 --- a/lib/cdist/config_install.py +++ b/lib/cdist/config_install.py @@ -163,10 +163,12 @@ class ConfigInstall: cdist.exec.run_or_fail([code_local]) # code remote - local_remote_code = cdist_object.code_remote_path - remote_remote_code = cdist_object.remote_code_remote_path + local_remote_code = os.path.join(self.context.object_base_path, + cdist_object.code_remote_path) + remote_remote_code = os.path.join(self.context.remote_object_path, + cdist_object.code_remote_path) if os.path.isfile(local_remote_code): - self.context.transfer_file(local_remote_code, remote_remote_code) + self.context.transfer_path(local_remote_code, remote_remote_code) cdist.exec.run_or_fail([remote_remote_code], remote_prefix=True) cdist_object.ran = True From d32aa37fba9713b80fa71de9f94a30d1fae94076 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Oct 2011 17:07:31 +0200 Subject: [PATCH 02/11] cleanup context Signed-off-by: Nico Schottelius --- lib/cdist/config_install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cdist/config_install.py b/lib/cdist/config_install.py index e6172a8c..fcbc79fc 100644 --- a/lib/cdist/config_install.py +++ b/lib/cdist/config_install.py @@ -53,7 +53,7 @@ class ConfigInstall: debug=debug) def cleanup(self): - self.path.cleanup() + self.context.cleanup() def run_initial_manifest(self): """Run the initial manifest""" From c0561958d0efca781a2c27fd1f73e58d7af236f2 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Oct 2011 17:10:10 +0200 Subject: [PATCH 03/11] todo(steven) == changed Signed-off-by: Nico Schottelius --- doc/dev/todo/steven | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/doc/dev/todo/steven b/doc/dev/todo/steven index 722b6b6b..2e38d817 100644 --- a/doc/dev/todo/steven +++ b/doc/dev/todo/steven @@ -1,25 +1,3 @@ -Object: - - -Type: - type.transferred_explorers - - -GlobalExplorer: - out_path: local path into which the output is written - - cdist.core.GlobalExplorer.base_dir - local directory containing explorers - cdist.core.GlobalExplorer.remote_base_dir - remote directory containing explorers - - path: local path to explorer - remote_path: remote path to explorer - - See config_install: run_global_explorers() - -Object/Type: - - rutern relative only - - Have accept absulet path on listing - Tests needed: - Fail if cache_dir from previous run cannot be deleted @@ -33,3 +11,7 @@ Tests needed: - ensure paths returned by object include dot-cdist - ensure path of explorer of object returns correct path + +Code fixes needed: + + - shutil, os.mkdir, etc. everywhere: catch/reraise exceptions correctly From 63c9a91bcad5eac759240f00c8ddc0cdcf0d9ff4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Oct 2011 17:12:06 +0200 Subject: [PATCH 04/11] +whitespace save out only Signed-off-by: Nico Schottelius --- lib/cdist/context.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cdist/context.py b/lib/cdist/context.py index fb00b423..a4fdbca5 100644 --- a/lib/cdist/context.py +++ b/lib/cdist/context.py @@ -99,11 +99,11 @@ class Context: # "other globals referenced by the __del__() method may already have been deleted # or in the process of being torn down (e.g. the import machinery shutting down)" # - log.debug("Saving" + self.base_path + "to " + self.cache_path) + log.debug("Saving " + self.out_path + " to " + self.cache_path) # Remove previous cache if os.path.exists(self.cache_path): shutil.rmtree(self.cache_path) - shutil.move(self.base_path, self.cache_path) + shutil.move(self.out_path, self.cache_path) def __init_out_paths(self): """Initialise output directory structure""" From 9b0c0be5568b503bd5435bc4448d758529097cb0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Oct 2011 17:13:01 +0200 Subject: [PATCH 05/11] ++todo(nico) Signed-off-by: Nico Schottelius --- doc/dev/todo/niconext | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/dev/todo/niconext b/doc/dev/todo/niconext index f96da0de..005f1bb0 100644 --- a/doc/dev/todo/niconext +++ b/doc/dev/todo/niconext @@ -1,6 +1,7 @@ 2.0.3: -- fix emulator +- fix emulator / require +- sanity checks -------------------------------------------------------------------------------- From be78955cc6fe28aef9dc0dd0de3fe3c11ba7890b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Oct 2011 17:18:39 +0200 Subject: [PATCH 06/11] move banner into cdist module Signed-off-by: Nico Schottelius --- lib/cdist/__init__.py | 17 ++++++++++++++++- lib/cdist/banner.py | 19 +++---------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/lib/cdist/__init__.py b/lib/cdist/__init__.py index 7aca5ac7..a3dc01cc 100644 --- a/lib/cdist/__init__.py +++ b/lib/cdist/__init__.py @@ -19,8 +19,23 @@ # # -VERSION = "2.0.3" +BANNER = """ + .. . .x+=:. s + dF @88> z` ^% :8 + '88bu. %8P . z` ^% :8 - '88bu. %8P . Date: Fri, 7 Oct 2011 17:38:10 +0200 Subject: [PATCH 07/11] 100% test coverage for the banner (feels good, doesn't it?) Signed-off-by: Nico Schottelius --- lib/cdist/test/test_banner.py | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 lib/cdist/test/test_banner.py diff --git a/lib/cdist/test/test_banner.py b/lib/cdist/test/test_banner.py new file mode 100644 index 00000000..4b0ab6ac --- /dev/null +++ b/lib/cdist/test/test_banner.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# 2011 Nico Schottelius (nico-cdist at schottelius.org) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +# + +import io +import sys +import unittest + +import cdist +import cdist.banner + +class Banner(unittest.TestCase): + def setUp(self): + self.banner = cdist.BANNER + "\n" + + def test_banner_output(self): + """Check that printed banner equals saved banner""" + output = io.StringIO() + + sys.stdout = output + + cdist.banner.banner(None) + + self.assertEqual(output.getvalue(), self.banner) From e985c0d69713d7f32be71b387088d5a36792bd83 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Oct 2011 17:38:50 +0200 Subject: [PATCH 08/11] remove sys.exit from banner Signed-off-by: Nico Schottelius --- lib/cdist/banner.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/cdist/banner.py b/lib/cdist/banner.py index d7ee1b00..4148fa72 100644 --- a/lib/cdist/banner.py +++ b/lib/cdist/banner.py @@ -30,4 +30,3 @@ log = logging.getLogger(__name__) def banner(args): """Guess what :-)""" print(cdist.BANNER) - sys.exit(0) From d3f0965ace998fe95cc8151b1d0de6b11f6b34f1 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Oct 2011 17:39:04 +0200 Subject: [PATCH 09/11] make t less verbose Signed-off-by: Nico Schottelius --- build.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build.sh b/build.sh index 6a91ff3d..63c380cf 100755 --- a/build.sh +++ b/build.sh @@ -126,6 +126,12 @@ case "$1" in | xargs rm -f ;; + t) + shift # skip t + PYTHONPATH=$PYTHONPATH:$(pwd -P)/lib \ + python3 -m unittest "$@" + ;; + test) PYTHONPATH=$PYTHONPATH:$(pwd -P)/lib \ python3 -m cdist.test From f2869161ed6c366e3f88d08b07ca977b8f4ffdec Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Oct 2011 17:45:39 +0200 Subject: [PATCH 10/11] ++todo(steven) Signed-off-by: Nico Schottelius --- doc/dev/todo/steven | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/dev/todo/steven b/doc/dev/todo/steven index 2e38d817..8d403245 100644 --- a/doc/dev/todo/steven +++ b/doc/dev/todo/steven @@ -12,6 +12,15 @@ Tests needed: - ensure paths returned by object include dot-cdist - ensure path of explorer of object returns correct path + config_install: + run_type_manifest() - same tests as for test_initial_manifest_*? + run_manifest() - raise exception if manifest is not existent + object_run(): ensure no object is run twice + object_run(): ensure requirements are taken into account + object_run(): check (from extern?) that all needed variables are setup + object_run(): ensure no code-{local, remote} is created, if gencode is not producing code + object_run(): ensure no code-{local, remote} contains what gencode created + Code fixes needed: - shutil, os.mkdir, etc. everywhere: catch/reraise exceptions correctly From 71af3b60c08850853954b71c2b506ef74f29cdc2 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Oct 2011 17:48:36 +0200 Subject: [PATCH 11/11] move test todos to own file Signed-off-by: Nico Schottelius --- doc/dev/todo/steven | 23 ----------------------- doc/dev/todo/tests | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 doc/dev/todo/tests diff --git a/doc/dev/todo/steven b/doc/dev/todo/steven index 8d403245..f0c867e1 100644 --- a/doc/dev/todo/steven +++ b/doc/dev/todo/steven @@ -1,26 +1,3 @@ -Tests needed: - - - Fail if cache_dir from previous run cannot be deleted - - Fail if cache_dir cannot be created from current out_dir - - transfer_type_explorers: Explorers are not transferred twice - - transfer_type_explorers: No transfer tried if there are no type_explorers - - - does $require work? - - $whatever should fail if there is no global explorer directory - - emulator may only be called with __ as prefix - fail otherwise! - - - ensure paths returned by object include dot-cdist - - ensure path of explorer of object returns correct path - - config_install: - run_type_manifest() - same tests as for test_initial_manifest_*? - run_manifest() - raise exception if manifest is not existent - object_run(): ensure no object is run twice - object_run(): ensure requirements are taken into account - object_run(): check (from extern?) that all needed variables are setup - object_run(): ensure no code-{local, remote} is created, if gencode is not producing code - object_run(): ensure no code-{local, remote} contains what gencode created - Code fixes needed: - shutil, os.mkdir, etc. everywhere: catch/reraise exceptions correctly diff --git a/doc/dev/todo/tests b/doc/dev/todo/tests new file mode 100644 index 00000000..8f019fed --- /dev/null +++ b/doc/dev/todo/tests @@ -0,0 +1,28 @@ +Tests needed: + + - Fail if cache_dir from previous run cannot be deleted + - Fail if cache_dir cannot be created from current out_dir + - transfer_type_explorers: Explorers are not transferred twice + - transfer_type_explorers: No transfer tried if there are no type_explorers + + - does $require work? + - $whatever should fail if there is no global explorer directory + - emulator may only be called with __ as prefix - fail otherwise! + + - ensure paths returned by object include dot-cdist + - ensure path of explorer of object returns correct path + + config_install: + run_type_manifest() - same tests as for test_initial_manifest_*? + run_manifest() - raise exception if manifest is not existent + object_run(): ensure no object is run twice + object_run(): ensure requirements are taken into account + object_run(): check (from extern?) that all needed variables are setup + object_run(): ensure no code-{local, remote} is created, if gencode is not producing code + object_run(): ensure no code-{local, remote} contains what gencode created + + run_type_explorer(): ensure output is saved to correct path + run_type_explorer(): ensure a type with no explorers works + run_type_explorer(): ensure environment is setup correctly + +