Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

build,dtf: cleanup

  • Loading branch information...
commit 7d05c8c573b40366beb567cc41728323c226c644 1 parent 4cd7d6a
@tychoish tychoish authored
View
1  bin/makefile.bootstrap
@@ -26,6 +26,7 @@ build/makefile.meta:$(output)/docs-tools/makecloth/meta.py
############## includes for static makefiles ##############
include $(tools)/makefiles/makefile.clean
include $(tools)/makefiles/makefile.push
+include $(tools)/makefiles/makefile.dtf
include $(build-tools)/makefile.manpages
############## generation steps for exceptional makefiles ##############
View
0  dtf/cases/__init__.py
No changes.
View
56 dtf/cases/change.py
@@ -1,56 +0,0 @@
-# Copyright 2012-2013 Sam Kleinman
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Part of the example distribution of DTF: https://pypi.python.org/pypi/dtf/
-
-import hashlib
-import os
-
-from dtf.cases import DtfCase
-from dtf.dtf import PASSING
-
-class DtfChange(DtfCase):
- @staticmethod
- def hash(file, block_size=2**20):
- md5 = hashlib.md5()
- with open(file, 'rb') as f:
- for chunk in iter(lambda: f.read(128*md5.block_size), b''):
- md5.update(chunk)
- return md5.hexdigest()
-
- def test(self, r=False):
- if self.hash(self.test_spec['file']) == self.test_spec['hash']:
- r = True
-
- if r is False:
- msg = ('[%s]: file named "%s" changed. Update other files as needed.'
- % ( self.test_spec['name'], self.test_spec['file']))
- else:
- msg = ('[%s]: file named "%s" is **not** changed. No further action required.'
- % ( self.test_spec['name'], self.test_spec['file']))
-
- return r, msg
-
- def passing(self):
- self.test_spec['hash'] = self.hash(self.test_spec['file'])
-
- return yaml.dump(self.test_spec, default_flow_style=False)
-
-def main(name, test_spec):
- c = DtfChange(name, test_spec)
- c.required_keys(['file', 'hash', 'type', 'name'])
- c.run()
-
- if PASSING is True:
- c.print_passing_spec()
View
62 dtf/cases/directory_paired.py
@@ -1,62 +0,0 @@
-# Copyright 2012-2013 Sam Kleinman
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Part of the example distribution of DTF: https://pypi.python.org/pypi/dtf/
-
-from change import DtfChange
-import os
-import yaml
-
-from dtf.dtf import PASSING
-
-class DtfDirectoryPaired(DtfChange):
- def test(self, a=False, b=False):
- if self.hash(self.test_spec['file']['path']) == self.test_spec['file']['hash']:
- a = True
-
- self.new_directory_count = len(os.listdir(self.test_spec['directory']))
-
- if self.test_spec['count'] == self.new_directory_count:
- b = True
-
- if a is True and b is True:
- msg = ('[%s]: number of files in "%s" and the content of "%s" has not changed.'
- % (self.name, self.test_spec['directory'], self.test_spec['file']['path']))
- else:
- if a is False and b is False:
- msg = ('[%s]: number of files in "%s" and the content of "%s" have changed.'
- % (self.name, self.test_spec['directory'], self.test_spec['file']['path']))
- elif a is False:
- msg = ('[%s]: content of "%s" has changed. Likely false positive.'
- % (self.name, self.test_spec['file']['path']))
- elif b is False:
- msg = ('[%s]: number of files in "%s" changed. Update "%s" now.'
- % (self.name, self.test_spec['directory'], self.test_spec['file']['path']))
-
- r = a and b
- return r, msg
-
- def passing(self):
- self.test_spec['file']['hash'] = self.hash(self.test_spec['file']['path'])
- self.test_spec['count'] = self.new_directory_count
-
- return yaml.dump(self.test_spec, default_flow_style=False)
-
-def main(name, test_spec):
- c = DtfDirectoryPaired(name, test_spec)
- c.required_keys(['directory', 'file', 'count', 'type', 'name'])
- c.run()
-
- if PASSING is True:
- c.print_passing_spec()
View
61 dtf/cases/line_length.py
@@ -1,61 +0,0 @@
-# Copyright 2012-2013 Sam Kleinman
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Part of the example distribution of DTF: https://pypi.python.org/pypi/dtf/
-
-try:
- from cases import DtfCase
- from utils import expand_tree
-except:
- from dtf.cases import DtfCase
- from dtf.utils import expand_tree
-
-class DtfLineLength(DtfCase):
- @staticmethod
- def check_line(line, max_length):
- if len(line) > max_length:
- return True
- else:
- return False
-
- def check_file(self, source_file, p=True):
- with open(source_file, 'r') as f:
- ln = 1
- for line in f.readlines():
- ln += 1
- if self.check_line(line, self.test_spec['max_length']):
- p = False
- break
-
- if p is False:
- return p, ln
- else:
- return p, None
-
- def test(self):
- result = self.check_file(self.test_spec['file'])
-
- if result[0] is True:
- msg = ('[%s]: %s has no lines longer than %s characters.'
- % (self.name, self.test_spec['file'], self.test_spec['max_length']))
- else:
- msg = ('[%s]: line %s in "%s" is longer than %s characters.'
- % (self.name, result[1], self.test_spec['file'], self.test_spec['max_length']))
-
- return result[0], msg
-
-def main(name, test_spec):
- c = DtfLineLength(name, test_spec)
- c.required_keys(['file', 'max_length', 'name'])
- c.run()
View
60 dtf/cases/paired.py
@@ -1,60 +0,0 @@
-# Copyright 2012-2013 Sam Kleinman
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Part of the example distribution of DTF: https://pypi.python.org/pypi/dtf/
-
-from change import DtfChange
-import yaml
-
-from dtf.dtf import PASSING
-
-class DtfPaired(DtfChange):
- def test(self, a=False, b=False):
- if self.hash(self.test_spec['file0']['path']) == self.test_spec['file0']['hash']:
- a = True
-
- if self.hash(self.test_spec['file1']['path']) == self.test_spec['file1']['hash']:
- b = True
-
- if a is True and b is True:
- msg = "[%s]: no changes" % self.name
- else:
- if a is False and b is False:
- msg = ('[%s]: both "%s" and "%s" files changed.'
- % (self.name, self.test_spec['file1']['path'], self.test_spec['file0']['path']))
- elif a is False:
- msg = ('[%s]: "%s" changed without "%s".'
- % (self.name, self.test_spec['file1']['path'], self.test_spec['file0']['path']))
- elif b is False:
- msg = ('[%s]: only "%s" changed without "%s".'
- % (self.name, self.test_spec['file0']['path'], self.test_spec['file1']['path']))
-
- r = a and b
-
- return r, msg
-
- def passing(self):
- self.test_spec['file0']['hash'] = self.hash(self.test_spec['file0']['path'])
- self.test_spec['file1']['hash'] = self.hash(self.test_spec['file1']['path'])
-
- return yaml.dump(self.test_spec, default_flow_style=False)
-
-
-def main(name, test_spec):
- c = DtfPaired(name, test_spec)
- c.required_keys(['file1', 'file0', 'type', 'name'])
- c.run()
-
- if PASSING is True:
- c.print_passing_spec()
View
66 dtf/cases/tree_line_length.py
@@ -1,66 +0,0 @@
-# Copyright 2012-2013 Sam Kleinman
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Part of the example distribution of DTF: https://pypi.python.org/pypi/dtf/
-
-from dtf.cases import DtfCase
-from dtf.utils import expand_tree
-
-from line_length import DtfLineLength
-
-class DtfTreeLineLength(DtfLineLength):
- def render_source_tree(self):
- self.msg('crawling "%s" for files.' % self.test_spec['directory'])
-
- output = [ item for item
- in expand_tree(self.test_spec['directory'], self.test_spec['extension'])
- if item not in self.test_spec['exceptions'] ]
-
- return output
-
- def check_directory(self, p=None):
- p = True
- for source_file in self.render_source_tree():
- result = self.check_file(source_file)
-
- if result[0] is False:
- p = False
- failing = source_file
- break
- else:
- self.msg('checked line lengths in %s, which passed.' % source_file)
- continue
-
- if p is False:
- return False, failing, result[1]
- elif p is True:
- return True, None, None
-
-
- def test(self):
- result = self.check_directory()
-
- if result[0] is True:
- msg = ('[%s]: all files in %s have no lines longer than %s characters.'
- % (self.name, self.test_spec['directory'], self.test_spec['max_length']))
- else:
- msg = ('[%s]: line %s in "%s" is longer than %s characters.'
- % (self.name, result[2], result[1], self.test_spec['max_length']))
-
- return result[0], msg
-
-def main(name, test_spec):
- c = DtfTreeLineLength(name, test_spec)
- c.required_keys(['type', 'directory', 'extension', 'max_length', 'exceptions', 'name'])
- c.run()
View
14 makefile
@@ -3,7 +3,7 @@ MAKEFLAGS += -j -r --no-print-directory
include bin/makefile.bootstrap
############# Meta targets that control the build and publication process. #############
-.PHONY: setup source/about.txt source/includes/hash.rst $(public-branch-output)/release.txt meta.yaml
+.PHONY: setup source/about.txt source/includes/hash.rst $(public-branch-output)/release.txt
############# Targets that define the production build process #############
# Generating files with build specific info.
@@ -55,15 +55,3 @@ $(branch-output)/sitemap.xml.gz:$(public-branch-output) $(public-branch-output)/
tags:
@etags -I --language=none --regex=@bin/etags.regexp `find source -name "*.txt" | grep -v "\.#"`
@echo "[dev]: etags generation complete."
-test:
- @echo "[dtf]: running test suite -- `date`"
- @dtf --casedir dtf/cases/ --testdir dtf/
- @echo "[dtf]: test suite complete -- `date`"
-dtf-verbose:
- @echo "[dtf]: running test suite -- `date`"
- @dtf --casedir dtf/cases/ --testdir dtf/ -v
- @echo "[dtf]: test suite complete -- `date`"
-dtf-passing:
- @echo "[dtf]: running test suite -- `date`"
- @dtf --casedir dtf/cases/ --testdir dtf/ -p
- @echo "[dtf]: test suite complete -- `date`"
Please sign in to comment.
Something went wrong with that request. Please try again.