forked from ungleich-public/cdist
		
	Merge remote-tracking branch 'telmich/master'
This commit is contained in:
		
				commit
				
					
						129e47d0c1
					
				
			
		
					 9 changed files with 107 additions and 59 deletions
				
			
		
							
								
								
									
										6
									
								
								build.sh
									
										
									
									
									
								
							
							
						
						
									
										6
									
								
								build.sh
									
										
									
									
									
								
							|  | @ -126,6 +126,12 @@ case "$1" in | ||||||
|       | xargs rm -f |       | xargs rm -f | ||||||
|    ;; |    ;; | ||||||
| 
 | 
 | ||||||
|  |    t) | ||||||
|  |       shift # skip t | ||||||
|  |       PYTHONPATH=$PYTHONPATH:$(pwd -P)/lib \ | ||||||
|  |          python3 -m unittest "$@" | ||||||
|  |    ;; | ||||||
|  | 
 | ||||||
|    test) |    test) | ||||||
|       PYTHONPATH=$PYTHONPATH:$(pwd -P)/lib \ |       PYTHONPATH=$PYTHONPATH:$(pwd -P)/lib \ | ||||||
|          python3 -m cdist.test |          python3 -m cdist.test | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| 2.0.3: | 2.0.3: | ||||||
| 
 | 
 | ||||||
| - fix emulator | - fix emulator / require | ||||||
|  | - sanity checks | ||||||
| 
 | 
 | ||||||
| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,35 +1,3 @@ | ||||||
| Object: | Code fixes needed: | ||||||
| 
 | 
 | ||||||
| 
 |    - shutil, os.mkdir, etc. everywhere: catch/reraise exceptions correctly | ||||||
| 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 |  | ||||||
|    - 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 |  | ||||||
|  |  | ||||||
							
								
								
									
										28
									
								
								doc/dev/todo/tests
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								doc/dev/todo/tests
									
										
									
									
									
										Normal file
									
								
							|  | @ -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 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -19,8 +19,23 @@ | ||||||
| # | # | ||||||
| # | # | ||||||
| 
 | 
 | ||||||
| VERSION     = "2.0.3" | BANNER = """  | ||||||
|  |              ..          .       .x+=:.        s | ||||||
|  |            dF           @88>    z`    ^%      :8 | ||||||
|  |           '88bu.        %8P        .   <k    .88 | ||||||
|  |       .   '*88888bu      .       .@8Ned8"   :888ooo | ||||||
|  |  .udR88N    ^"*8888N   .@88u   .@^%8888"  -*8888888 | ||||||
|  | <888'888k  beWE "888L ''888E` x88:  `)8b.   8888 | ||||||
|  | 9888 'Y"   888E  888E   888E  8888N=*8888   8888 | ||||||
|  | 9888       888E  888E   888E   %8"    R88   8888 | ||||||
|  | 9888       888E  888F   888E    @8Wou 9%   .8888Lu= | ||||||
|  | ?8888u../ .888N..888    888&  .888888P`    ^%888* | ||||||
|  |  "8888P'   `"888*""     R888" `   ^"F        'Y" | ||||||
|  |    "P'        ""         "" | ||||||
|  | """ | ||||||
| DOT_CDIST   = ".cdist" | DOT_CDIST   = ".cdist" | ||||||
|  | VERSION     = "2.0.3" | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| import os | import os | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -22,25 +22,11 @@ | ||||||
| import logging | import logging | ||||||
| import sys | import sys | ||||||
| 
 | 
 | ||||||
| log = logging.getLogger(__name__) | import cdist | ||||||
| 
 | 
 | ||||||
| BANNER = """ | log = logging.getLogger(__name__) | ||||||
|              ..          .       .x+=:.        s |  | ||||||
|            dF           @88>    z`    ^%      :8 |  | ||||||
|           '88bu.        %8P        .   <k    .88 |  | ||||||
|       .   '*88888bu      .       .@8Ned8"   :888ooo |  | ||||||
|  .udR88N    ^"*8888N   .@88u   .@^%8888"  -*8888888 |  | ||||||
| <888'888k  beWE "888L ''888E` x88:  `)8b.   8888 |  | ||||||
| 9888 'Y"   888E  888E   888E  8888N=*8888   8888 |  | ||||||
| 9888       888E  888E   888E   %8"    R88   8888 |  | ||||||
| 9888       888E  888F   888E    @8Wou 9%   .8888Lu= |  | ||||||
| ?8888u../ .888N..888    888&  .888888P`    ^%888* |  | ||||||
|  "8888P'   `"888*""     R888" `   ^"F        'Y" |  | ||||||
|    "P'        ""         "" |  | ||||||
| """ |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def banner(args): | def banner(args): | ||||||
|     """Guess what :-)""" |     """Guess what :-)""" | ||||||
|     print(BANNER) |     print(cdist.BANNER) | ||||||
|     sys.exit(0) |  | ||||||
|  |  | ||||||
|  | @ -53,7 +53,7 @@ class ConfigInstall: | ||||||
|             debug=debug) |             debug=debug) | ||||||
| 
 | 
 | ||||||
|     def cleanup(self): |     def cleanup(self): | ||||||
|         self.path.cleanup() |         self.context.cleanup() | ||||||
| 
 | 
 | ||||||
|     def run_initial_manifest(self): |     def run_initial_manifest(self): | ||||||
|         """Run the initial manifest""" |         """Run the initial manifest""" | ||||||
|  | @ -163,10 +163,12 @@ class ConfigInstall: | ||||||
|             cdist.exec.run_or_fail([code_local]) |             cdist.exec.run_or_fail([code_local]) | ||||||
| 
 | 
 | ||||||
|         # code remote |         # code remote | ||||||
|         local_remote_code   = cdist_object.code_remote_path |         local_remote_code   = os.path.join(self.context.object_base_path, | ||||||
|         remote_remote_code  = cdist_object.remote_code_remote_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): |         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.exec.run_or_fail([remote_remote_code], remote_prefix=True) | ||||||
| 
 | 
 | ||||||
|         cdist_object.ran = True |         cdist_object.ran = True | ||||||
|  |  | ||||||
|  | @ -99,11 +99,11 @@ class Context: | ||||||
|         # "other globals referenced by the __del__() method may already have been deleted  |         # "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)" |         # 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 |         # Remove previous cache | ||||||
|         if os.path.exists(self.cache_path): |         if os.path.exists(self.cache_path): | ||||||
|             shutil.rmtree(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): |     def __init_out_paths(self): | ||||||
|         """Initialise output directory structure""" |         """Initialise output directory structure""" | ||||||
|  |  | ||||||
							
								
								
									
										42
									
								
								lib/cdist/test/test_banner.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								lib/cdist/test/test_banner.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -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 <http://www.gnu.org/licenses/>. | ||||||
|  | # | ||||||
|  | # | ||||||
|  | 
 | ||||||
|  | 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) | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue