summaryrefslogtreecommitdiff
path: root/src/tools/docwriter/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/docwriter/tests')
-rw-r--r--src/tools/docwriter/tests/assets/test.c141
-rw-r--r--src/tools/docwriter/tests/output/.gitignore1
-rw-r--r--src/tools/docwriter/tests/output/markdown/.gitignore1
-rw-r--r--src/tools/docwriter/tests/test_integration.py55
-rw-r--r--src/tools/docwriter/tests/test_parse.py57
-rw-r--r--src/tools/docwriter/tests/test_siteconfig.py72
-rw-r--r--src/tools/docwriter/tests/test_tomarkdown.py90
-rw-r--r--src/tools/docwriter/tests/test_utils.py67
8 files changed, 0 insertions, 484 deletions
diff --git a/src/tools/docwriter/tests/assets/test.c b/src/tools/docwriter/tests/assets/test.c
deleted file mode 100644
index 1ab7b2d68..000000000
--- a/src/tools/docwriter/tests/assets/test.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/****************************************************************************
- *
- * ftbbox.h
- *
- * Test header file for docwriter.
- *
- * Copyright 2018 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-
- /**************************************************************************
- *
- * This component has a _single_ role: to test docwriter
- *
- * This file is ONLY used to test docwriter, and should not be taken
- * seriously.
- *
- */
-
-
-#ifndef FTBBOX_H_
-#define FTBBOX_H_
-
-
-#include <ft2build.h>
-#include FT_FREETYPE_H
-
-#ifdef FREETYPE_H
-#error "freetype.h of FreeType 1 has been loaded!"
-#error "Please fix the directory search order for header files"
-#error "so that freetype.h of FreeType 2 is found first."
-#endif
-
-
-FT_BEGIN_HEADER
-
-
- /**************************************************************************
- *
- * @section:
- * outline_processing
- *
- * @title:
- * Outline Processing
- *
- * @abstract:
- * Functions to create, transform, and render vectorial glyph images.
- *
- * @description:
- * This section contains routines used to create and destroy scalable
- * glyph images known as 'outlines'. These can also be measured,
- * transformed, and converted into bitmaps and pixmaps.
- *
-
-
- /**************************************************************************
- *
- * @function:
- * FT_Foo_Bar
- *
- * @description:
- * Compute the exact bar for the given foo.
- *
- * @input:
- * foo ::
- * A pointer to the source foo.
- *
- * @values:
- * FT_FOO ::
- * The foo.
- *
- * FT_BAR ::
- * The bar.
- *
- * @output:
- * bar ::
- * The foo's exact bar.
- *
- * @return:
- * FreeType error code. 0~means success.
- *
- * @note:
- * If the foo is tricky and the bar has been loaded with
- * @FT_FOO, the resulting bar is meaningless. To get
- * reasonable values for the bar it is necessary to load the foo
- * at a large baz value (so that the hinting instructions can
- * properly shift and scale the subfoos), then extracting the bar,
- * which can be eventually converted back to baz units.
- */
- FT_EXPORT( FT_Error )
- FT_Outline_Get_BBox( FT_Outline* outline,
- FT_BBox *abbox );
-
- /* */
-
-
-FT_END_HEADER
-
-#endif /* FTBBOX_H_ */
-
- /****************************************************************************
- *
- * @chapter:
- * support_api
- *
- * @title:
- * Support API
- *
- * @sections:
- * outline_processing
- *
- */
-
- /*************************************************************************
- *
- * @macro:
- * FT_BBOX_H
- *
- * @description:
- * A macro used in #include statements to name the file containing the
- * API of the optional exact bounding box computation routines.
- *
- */
-#define FT_BBOX_H <freetype/ftbbox.h>
-
-/* */
-
-/* END */
-
-
-/* Local Variables: */
-/* coding: utf-8 */
-/* End: */
diff --git a/src/tools/docwriter/tests/output/.gitignore b/src/tools/docwriter/tests/output/.gitignore
deleted file mode 100644
index 1cda54be9..000000000
--- a/src/tools/docwriter/tests/output/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.yml
diff --git a/src/tools/docwriter/tests/output/markdown/.gitignore b/src/tools/docwriter/tests/output/markdown/.gitignore
deleted file mode 100644
index dd449725e..000000000
--- a/src/tools/docwriter/tests/output/markdown/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.md
diff --git a/src/tools/docwriter/tests/test_integration.py b/src/tools/docwriter/tests/test_integration.py
deleted file mode 100644
index db5c91d9d..000000000
--- a/src/tools/docwriter/tests/test_integration.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#
-# test_integration.py
-#
-# Integration test for docwriter.
-#
-# Copyright 2018 by
-# Nikhil Ramakrishnan.
-#
-# This file is part of the FreeType project, and may only be used,
-# modified, and distributed under the terms of the FreeType project
-# license, LICENSE.TXT. By continuing to use, modify, or distribute
-# this file you indicate that you have read the license and
-# understand and accept it fully.
-
-"""Docwriter Integration tests.
-
-This is a simple integration test that builds Docwriter
-documentation against a test file.
-
-From the root of the Docwriter git repo, use:
- python -m pytest tests/test_integration.py
-"""
-
-import logging
-import subprocess
-
-log = logging.getLogger('docwriter')
-
-def test_integration( capfd ):
-
- log.propagate = False
- stream = logging.StreamHandler()
- formatter = logging.Formatter(
- "\033[1m\033[1;32m *** %(message)s *** \033[0m")
- stream.setFormatter(formatter)
- log.addHandler(stream)
- log.setLevel(logging.DEBUG)
-
- base_cmd = ['python', 'docwriter.py', '--prefix=test',
- '--title=Docwriter Test', '--output=./tests/output',
- '--verbose' ]
- folders = ['./tests/assets/*.c']
-
- log.debug("Building markdown docs.")
- command = base_cmd + folders
- # run the command
- subprocess.check_call( command )
- # capture output to check for warnings
- captured = capfd.readouterr()
- # print the logs on failure
- print( captured.err )
- # fail if there are warnings
- assert not "WARNING" in captured.err
-
-# eof
diff --git a/src/tools/docwriter/tests/test_parse.py b/src/tools/docwriter/tests/test_parse.py
deleted file mode 100644
index 7df95c081..000000000
--- a/src/tools/docwriter/tests/test_parse.py
+++ /dev/null
@@ -1,57 +0,0 @@
-#
-# test_parse.py
-#
-# Tests for docwriter parsing (sources.py and content.py).
-#
-# Copyright 2018 by
-# Nikhil Ramakrishnan.
-#
-# This file is part of the FreeType project, and may only be used,
-# modified, and distributed under the terms of the FreeType project
-# license, LICENSE.TXT. By continuing to use, modify, or distribute
-# this file you indicate that you have read the license and
-# understand and accept it fully.
-
-"""Docwriter parse tests.
-
-The tests in this module use the `SourceProcessor` and
-`ContentProcessor` classes to test file and content parsing.
-"""
-
-import content
-import sources
-import utils
-
-# create context and processor
-source_processor = sources.SourceProcessor()
-content_processor = content.ContentProcessor()
-
-def test_parse_file():
- # retrieve the list of files to process
- file_list = utils.make_file_list( ['./tests/assets/*.c'] )
- for filename in file_list:
- source_processor.parse_file( filename )
- # get blocks
- blocks = source_processor.blocks
- count = len( blocks )
-
- # there must be 12 blocks in file
- assert count == 12
-
-def test_parse_source():
- # retrieve the list of files to process
- file_list = utils.make_file_list( ['./tests/assets/*.c'] )
- for filename in file_list:
- source_processor.parse_file( filename )
- content_processor.parse_sources( source_processor )
- # process sections
- content_processor.finish()
- # get headers
- headers = content_processor.headers
- # expected values
- expected_key = 'freetype/ftbbox.h'
- expected_val = 'FT_BBOX_H'
-
- assert headers[expected_key] == expected_val
-
-# eof
diff --git a/src/tools/docwriter/tests/test_siteconfig.py b/src/tools/docwriter/tests/test_siteconfig.py
deleted file mode 100644
index 32fb00577..000000000
--- a/src/tools/docwriter/tests/test_siteconfig.py
+++ /dev/null
@@ -1,72 +0,0 @@
-#
-# test_siteconfig.py
-#
-# Tests for site config generation (siteconfig.py).
-#
-# Copyright 2018 by
-# Nikhil Ramakrishnan.
-#
-# This file is part of the FreeType project, and may only be used,
-# modified, and distributed under the terms of the FreeType project
-# license, LICENSE.TXT. By continuing to use, modify, or distribute
-# this file you indicate that you have read the license and
-# understand and accept it fully.
-
-"""Docwriter site config tests.
-
-This module tests the validity of the `yml` configuration
-generated by `siteconfig.py`.
-"""
-import os
-
-import yaml
-
-import siteconfig
-import utils
-
-config = siteconfig.SiteConfig()
-
-# Config vars
-site_name = "Foo Bar Test"
-site_description = "Test documentation for Foo Bar."
-site_author = "Pytest"
-toc_filename = "foo-toc.md"
-index_filename = "foo-index.md"
-
-# Add chapters and pagess
-c1_sec = ["c1s1", "c1s2", "c1s3"]
-c2_sec = ["c2s1", "c2s2"]
-
-pages = {}
-pages['chap1'] = c1_sec
-pages['chap2'] = c2_sec
-
-def test_config( tmpdir, caplog ):
- utils.output_dir = str( tmpdir )
- # Set site config
- config.set_site_info( site_name, site_description,
- site_author )
- # Add toc and index
- config.add_single_page( "TOC", toc_filename )
- config.add_single_page( "Index", index_filename )
-
- # Add chapters and pages
- for chap, parts in pages.items():
- config.start_chapter( chap )
- for sec in parts:
- config.add_chapter_page( sec, sec + ".md" )
- config.end_chapter()
-
- # Done, Build config
- config.build_config()
-
- # Open file and parse yml
- filepath = os.path.join( str( tmpdir ), 'mkdocs.yml' )
- result = open( filepath, 'rb' ).read()
- data = yaml.safe_load(result)
-
- # Assertions
- assert data is not None
- for record in caplog.records:
- # Strict build - there should be no warnings
- assert record.levelname != 'WARNING'
diff --git a/src/tools/docwriter/tests/test_tomarkdown.py b/src/tools/docwriter/tests/test_tomarkdown.py
deleted file mode 100644
index b19074fee..000000000
--- a/src/tools/docwriter/tests/test_tomarkdown.py
+++ /dev/null
@@ -1,90 +0,0 @@
-#
-# test_tomarkdown.py
-#
-# Tests for markdown formatter (tomarkdown.py).
-#
-# Copyright 2018 by
-# Nikhil Ramakrishnan.
-#
-# This file is part of the FreeType project, and may only be used,
-# modified, and distributed under the terms of the FreeType project
-# license, LICENSE.TXT. By continuing to use, modify, or distribute
-# this file you indicate that you have read the license and
-# understand and accept it fully.
-
-"""Unit tests for `tomarkdown`.
-
-This module contains tests for functions in `tomarkdown.py`.
-"""
-
-import content
-import sources
-import tomarkdown
-import utils
-
-# Create test objects
-# create context and processor
-source_processor = sources.SourceProcessor()
-content_processor = content.ContentProcessor()
-# Names
-project_title = 'Test Docs'
-project_prefix = 'test'
-# retrieve the list of files to process
-file_list = utils.make_file_list( ['./tests/assets/*.c'] )
-for filename in file_list:
- source_processor.parse_file( filename )
- content_processor.parse_sources( source_processor )
-# process sections
-content_processor.finish()
-
-formatter = tomarkdown.MdFormatter( content_processor,
- project_title,
- project_prefix )
-
-def test_html_quote():
- test_string = '7 & 9 < 4 & 5 but 12 & 15 > 4 & 5'
- expt_string = '7 &amp; 9 &lt; 4 &amp; 5 but 12 &amp; 15 &gt; 4 &amp; 5'
- assert tomarkdown.html_quote(test_string) == expt_string
-
-def test_normalize_url():
- global formatter
- url = 'protocol://test-url-with/[square-brackets]?and-query'
- expected_url = 'protocol://test-url-with/(square-brackets)?and-query'
- assert formatter.normalize_url( url ) == expected_url
-
-def test_slugify():
- global formatter
- name = 'FT_HAS_MULTIPLE_MASTERS'
- expected = 'ft_has_multiple_masters'
- assert formatter.slugify( name ) == expected
-
-def test_slugify2():
- global formatter
- name = 'FT_GetFilePath_From_Mac_ATS_Name'
- expected = 'ft_getfilepath_from_mac_ats_name'
- assert formatter.slugify( name ) == expected
-
-def test_slugify3():
- global formatter
- name = 'default-script'
- expected = 'default-script'
- assert formatter.slugify( name ) == expected
-
-def test_make_section_url():
- global formatter
- expected_url = '../test-outline_processing/index.html'
-
- section = list(formatter.sections)[0]
- out_url = formatter.make_section_url( section, code = True )
- assert out_url == expected_url
-
-def test_make_chapter_url():
- global formatter
- expected_text = '[Support API](test-toc.md#support-api)'
-
- section = list(formatter.sections)[0]
- out_text = formatter.make_chapter_url( section.chapter.title )
-
- assert out_text == expected_text
-
-# eof
diff --git a/src/tools/docwriter/tests/test_utils.py b/src/tools/docwriter/tests/test_utils.py
deleted file mode 100644
index 53b1e8b0c..000000000
--- a/src/tools/docwriter/tests/test_utils.py
+++ /dev/null
@@ -1,67 +0,0 @@
-#
-# test_utils.py
-#
-# Tests for utility functions (utils.py).
-#
-# Copyright 2018 by
-# Nikhil Ramakrishnan.
-#
-# This file is part of the FreeType project, and may only be used,
-# modified, and distributed under the terms of the FreeType project
-# license, LICENSE.TXT. By continuing to use, modify, or distribute
-# this file you indicate that you have read the license and
-# understand and accept it fully.
-
-"""Unit tests for `utils`.
-
-This module contains tests for functions in `utils.py`.
-"""
-
-import utils
-import sys
-
-def test_index_key():
- test_dict = {"hello": "world", "foo": "bar", "FOO": "BAZ",
- "HELLO": "WORLD", "zzz": "sleep"}
- # expected output
- out_list = ["FOO", "foo", "HELLO", "hello", "zzz"]
- block_index = test_dict.keys()
- block_index = sorted( block_index, key = utils.index_key )
- assert block_index == out_list
-
-def test_sort_order_list():
- input_list = ["z", "b", "a"]
- order_list = ["b", "c", "d"]
- # expected output
- expected = ["b", "c", "d", "z", "a"]
-
- out_list = utils.sort_order_list(input_list, order_list)
- assert out_list == expected
-
-def test_output( tmpdir ):
- # check if sys.stdout is diverting to file
- # this tests both open_output and close_output
- utils.output_dir = str( tmpdir )
- old_std = sys.stdout
- out = utils.open_output("test.txt", config=True)
- assert sys.stdout != old_std
- utils.close_output( out )
- assert sys.stdout == old_std
-
-def test_make_file_list( tmpdir ):
- utils.output_dir = tmpdir
- f1 = tmpdir.join( "test1.c" )
- f2 = tmpdir.join( "test2.c" )
- f3 = tmpdir.join( "test3.txt" )
- f1.write( "foo" )
- f2.write( "bar" )
- f3.write( "baz" )
- args = [str( tmpdir + '/*.c' )]
- expected = ['test1.c', 'test2.c']
-
- out_list = utils.make_file_list( args )
- out_list = [f for f in out_list]
- for i in range( len( expected ) ):
- assert expected[i] in out_list[i]
-
-# eof