84 Commits
Author SHA1 Message Date
Matthew Johnson 8b56c225b1 Create mock chroot with a unique uniqueext
This prevents collisions when two instances are trying to build the same
package in parallel. Unit tests added as well.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-10-11 15:38:14 -07:00
Matthew Johnson a09ea7005e Skip two more trouble tests in Travis
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-26 15:38:23 -07:00
Matthew Johnson adaea4202a Skip problem tests on Travis CI only
These tests regularly fail in Travis for unknown reasons. Skip them
until the tests can be rewritten.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-26 15:30:45 -07:00
Matthew Johnson 2552c9786f Move test generators out of name guard
This allows python3 unittest to properly generate the tests when running
all the tests in the tests directory.

Also adds a fix to test_test.py to reset buildpattern.default_pattern
every test. This was a bug introduced by running all tests at once -
this was not being cleared correctly.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-26 15:30:34 -07:00
Gabi Beyer c68e877bd2 Fix unittests that use mock_open
with the imlpementation of the write_out functionality,
some unittests need to be changed to use that fuction.

Signed-off-by: Gabi Beyer <gabrielle.n.beyer@intel.com>
2017-08-31 12:44:04 -07:00
Matthew Johnson 37021b8505 Remove architecture string from version string 2017-07-31 13:56:11 -07:00
Matthew Johnson 7a648c8e66 Add another version pattern for stack 2017-07-17 16:01:42 -07:00
Matthew Johnson a6c82dc940 Clean up buildreq module
Minor clean up of buildreq module, including the following changes:

- Remove unused import "tarball"
- Add function docstrings
- Convert to list-driven pattern checks instead of a long list of
  conditionals.
- Rename variable names that were overriding keywords (file, buffer,
  etc.)
- Remove unused setup_py_python3 function
- Remove unused arguments and variables from scan_for_configure function
  (and corresponding function calls in test_buildreq.py and autospec.py)

Most changes made at pylint and pycodestyle suggestions.
2017-07-13 10:55:41 -07:00
Matthew Johnson d200c719d7 Add simple unit tests for the util module 2017-07-13 09:14:45 -07:00
Matthew Johnson ddf7927c3c Update and add to tarball unit tests
Updates include generating an individual test for each url to be tested
instead of doing it all in one test and appending to an error list where
appropriate. This has the benefit of showing failures for each
individual test case in a recognizable manner.

Tests are also added for most of the remaining functions.

These tests do not pass without the accompanying tarball module cleanup
and restructure.
2017-07-13 09:14:45 -07:00
Matthew Johnson f8eb22b8f1 Update unit tests for latest changes
Some changes have recently been pushed to autospec sources without
updating the unit tests. This patch brings the unit tests up-to-date
again.

test_build.py: Remove go buildtool bits (was deprecated)
test_specdescription.py: Newline added to post-scripts
test_specfile.py: Reset license_translations dict
files.py: Check dict with get() in case of missing key
2017-07-12 08:46:47 -07:00
Matthew Johnson 99b9ed6dd5 Add unit tests for the test module
This patch adds unit tests for the test module.
2017-07-12 08:46:47 -07:00
Matthew Johnson 9f023f87eb Add unit tests for count.py
Add unit tests for the very large count.py module/script. These unit
tests attempt to test every regular expression present in the parse_log
function and helped catch several bugs in the original regexes ported
from perl.
2017-07-11 14:16:55 -07:00
Matthew Johnson c3231eaed5 Remove unchangeable default_grp from specfiles
Since default_group in specdescription is never modified, remove it as a
class member from the Specfiles class and just write the default.
2017-07-07 15:10:48 -07:00
Matthew Johnson a1f13af7ab Clean up specdescription module
Clean up the specdescription module, including resolving two bugs and
making the code more readable and more robust.

BUGS:

- description_from_pkginfo

  A string was checked for a substring using the string.find() method
  but was treated as a boolean, assuming that find() returned 0 when the
  substring was not found. This was causing a section end to be
  immediately detected and the section was not parsed. The call was
  replaced with the `in` keyword.

- description_from_spec

  The default description was overwritten regardless of whether the
  detected description had any content. A check was added to only
  overwrite the default if there was a detected description.

Other general cleanup:

- Remove unused default_group global
- Remove unused argument in summary_from_R
- Add assign_summary/description methods to reduce global usage and
  reduce code repetition
- Add function docstrings
- Convert to `with open()` blocks when working with files instead of
  explicitly handling closing the files
- Wrap open() calls in try...catch blocks
2017-07-07 14:54:42 -07:00
Matthew Johnson e8efee61dc Add unit tests for the specdescription module
Unit tests added for the specdescription module. At the time of this
commit, there are two failing tests due to bugs in the module.

Failures:

- test_description_from_pkginfo

  This test fails because a string.find() method is checked as a boolean
  as if find returned 0 if the substring was not present. find()
  actually returns -1 in this case. Because find() was being used as a
  guard to find the end of a section, the end was found immediately and
  the section was not parsed.

- test_description_from_spec_no_info

  This test fails due to the default description being overridden, even
  when the override is just an empty string.
2017-07-07 12:34:30 -07:00
Matthew Johnson ccc278e657 Add more tests for setup.py buildreq parsing
Shortcomings were identified in setup.py parsing for python build
requirements. These tests more exhaustively test the cases we have been
seeing in the wild.
2017-07-06 16:26:48 -07:00
Arjan van de Ven 193efe132e Revert "Simplify the buildreq module"
This reverts commit 52e986c07d.

it breaks quite a few packages, including gtk+
2017-05-03 02:41:30 +00:00
Matthew Johnson 52e986c07d Simplify the buildreq module
This patch makes some simplifications to the buildreq module and related
modules (autospec and config). These are mostly readability changes and
code cleanup.
2017-05-01 11:47:00 -07:00
Matthew Johnson d5b6abc9d2 Add unittests for the buildreq module
Unit tests can be run from the root of the autospec directory by
invoking `make test_buildreq` or `make unittests`.
2017-05-01 11:47:00 -07:00
Matthew Johnson f3ac7c3a83 Fix test configuration files 2017-04-27 12:58:51 -07:00
Matthew Johnson 13c6cdd838 Add unittests for the build module
This patch adds 26 tests for the build module. They can be tested by
running `make test_build` from the root of the autospec repo.
2017-04-25 16:55:07 -07:00
Matthew Johnson 11569333b4 Add simple tests for buildpattern module
The complexity of the buildpattern has been significantly reduced with
the move to a centralized specfiles class to handle specfile writes.
This patch tests the remaining functionality and fixes a typo in
buildpattern.py (pattern_strengh -> pattern_strength).
2017-04-25 14:48:33 -07:00
Matthew Johnson 9b7bba0683 Create options.conf in relative directory
Instead of creating in the current directory, which assumes autospec is
being run via a make target from the package directory, create
options.conf in the target directory. This insures the configuration
file will be placed correctly when autospec is run directly with a
different target directory provided.
2017-04-25 12:08:01 -07:00
Matthew Johnson 33b98ebaba Add option to add all *.so$ files to lib subpackage
The lib_to_so boolean option in options.conf for a specific package
causes files ending with .so to be added to the lib subpackage instead
of the dev subpackage. This is helpful for packages with a plugin
architecture that use .so files as their plugins. Specific examples of
the packages this is helpful for is mesa and elfutils.

Functional tests updated.
2017-04-18 16:48:08 -07:00
Matthew Johnson 5fd6b5d857 Add proxy exports to %build sections
A proxy redirect to localhost prevents package builds from accessing the
internet (they will receive a connection refused). Package build access
to the internet is a security issue if successful, and a very long
timeout if the build is behind an actual proxy.

Update the functional tests to reflect this change.
2017-04-18 10:19:42 -07:00
Alex Jaramillo f9ff1e11b1 Adding shasum verification for domain gnome.org
Implemented support for hash verification of packages from
download.gnome.org. This commit includes tests for domain
based verification (pypi ang gnome)
2017-04-06 21:42:26 +00:00
Matthew Johnson 2ebf8f3212 Update functional tests for version/name detection changes
Update functional tests to reflect the recent version and name detection
changes, such as the addition of the [configuration] section of the
options.conf file.
2017-04-04 17:30:11 -07:00
Matthew Johnson 1ecdc45959 Convert name argument from list to string
Due to an 'nargs' specification in the argument parser, the name
argument was being read as a list. The list was then always accessed as
name_argument[0] to access the name. This patch removes the 'nargs'
specifier so name is always a string and removes the logic to parse the
list.

If both version and name arguments exist, set them and skip automated
detection. If one is not set, continue with the automated detection
since the URL parsing for both are done together, override at the end.
2017-04-04 17:30:11 -07:00
Matthew Johnson 872a1d1e12 Add command-line version configuration
Autospec is unable to accurately parse every type of URL for the correct
name and version of the package. When this is the case, the detected
version can be overwritten by the --version argument on the command
line.
2017-04-04 17:30:11 -07:00
Matthew Johnson 9ba5bd1e05 Detect 'alpha' version similar to 'beta'
Add 'alpha' to acceptable version suffixes and add a test URL to
packageurls.
2017-04-04 12:56:35 -07:00
Matthew Johnson 1c09a0c5a4 license: Remove manual license detection functions
Instead of manually searching for identifying strings in package
licenses, rely on the configuration file and license server to set the
license information. Remove unit tests that tested these functions.

Convert license_blacklist back to dict for faster lookup times.
2017-04-03 20:36:12 -07:00
Matthew Johnson 5a805b704a Refactor and test the license module
Several changes to the license module including changes to where local
hashes are stored. Tests were added as well. Detailed changes below.

config:
  - Move the license hashes from an internal repo to a config file
    (license_hashes) in autospec.

test_license:
  - Unit tests added
  - Unit test target added to autospec Makefile
  - COPYING_TEST file added with GPL-3.0 text for test purposes

license:
  - scan_for_licenses: separate out search strings from conditional to
    make the code more readable and remove unused parameter (required a
    change to where autospec.py called the function).
  - remove duplicate licenses from license_translation list.
  - convert license_blacklist dict to list (values were unused, it was
    being treated as a list anyways).
  - separate out search strings from code in license_from_copying_hash
    and license_from_doc.
  - move curl code out of `with open(file) as fname:` clause in
    license_from_copying_hash.
2017-04-03 20:36:12 -07:00
Alex Jaramillo f61aecd6ae Cleaning after test
Public key import was not cleanning after running. With this
change the state of the keyring will be reverted to the
original state after the test runs.
2017-04-03 16:07:10 +00:00
Matthew Johnson d497f7e2cb files: general cleanup of module
The files module was being treated like a class, in that it was
necessary to keep state throughout the entire autospec run. Convert the
files module to a class and make some other general clean ups. This
changed how the files module was instantiated and called by the main
autospec module and other modules such as tarball and config.

Test the files module with unit tests and add the target to the
makefile.
2017-03-28 22:35:11 -07:00
Matthew Johnson 8384daf05e Use secure temporary directory instead of public
Autospec previously used an unsecure public temporary directory as its
working directory. This patch creates a secure temporary directory only
accessible by the creating user ID.
2017-03-09 11:55:58 -08:00
Matthew Johnson 5580b46e43 Allow http github URLs when parsing for version
This shortcoming was identified when a github package URL was changed to
http from https. The 's' character is made optional when parsing the
github URL and two test cases are added to the packageurl list for
testing.
2017-03-09 11:05:59 -08:00
William Douglas d9f03bc2c6 Add ability to run autospec tests with conf file
The test_autospec builds currently use no configuration. This patch adds
the ability to have per test configuration files added to the autospec
run.
2017-03-07 22:08:48 +00:00
William Douglas d2a616175b Convert test_autospec output to utf-8
When running build_and_run for test_autospec if subprocess.check_output
throws an exception, output was a byte encoded string and a later test
to see if a unicode string was contained in that byte encoded string
would throw an exception.

Instead of doing the decode in a try block put it in finally. This does
add the posibility of utf-8 decode failing but that's fatal later on
either way.
2017-03-07 22:08:48 +00:00
Matthew Johnson a0bad7923b Simplify version detection logic
Version detection could be considerably simplified using builtin python
functions such as strip, replace, and list comprehension. The logic was
also modified a bit to provide more consistent version strings
containing only numbers and periods '.'. More unit tested urls were
added to tests.

9.11.0-P1 -> 9.11.0.1
1.0.0-rc1 -> 1.0.0.1
7_4_2     -> 7.4.2
2.1-3     -> 2.1.3

Some non-digit strings are conserved for upstream version update detection:

2.1-beta1 -> 2.1.beta1
2.1-pre8  -> 2.1.pre8
3.5.0b2   -> 3.5.0b2
2017-03-07 13:39:34 -08:00
William Douglas 73823a6c86 Remove unused arg for test_autospec function 2017-02-23 20:35:37 +00:00
Matthew Johnson 0f66c9f60c Copy build and output logs over when failure occurs
Instead of only copying logs over on errors in the build, copy the logs
over whenever a test failure has occurred.
2017-02-23 10:40:13 -08:00
William Douglas eab12f1589 Add support for manual requires
This patch allows users to specify requires_add and requires_ban to
augment the automatic runtime requirement handling.

As part of this change, the handling of python requires has been
modified so that they are managed under generic requires instead of
their own special mechanism. python requires detection was also improved
by adding install_requires section contents when the section is detected
in setup.py.

The primary change aside from python handling is to remove main_requires
handling in files.py and consolidate requires fully in buildreq.py.
2017-02-23 17:57:48 +00:00
Matthew Johnson 09be79136e Save all logs for functional test runs
Previously, we were only saving the build log, but the mock logs and the
output should be saved as well for debugging.
2017-02-21 16:22:14 -08:00
William Douglas 94245bda88 Delete temporary test file after use 2017-02-21 22:08:44 +00:00
Alex Jaramillo 4faa9e77df Verifying MD5 hashes for pypi packages
With this change python packages in pypi will be
verified using the MD5 hash posted in pypi along
the package if all the other verifications are
not possible.
2017-02-17 21:46:44 +00:00
Matthew Johnson 13e16210aa Update c-helloworld-opts test case for security flag 2017-02-16 15:36:28 -08:00
Matthew Johnson bd8702e7dc Add a unit test for commitmessage.scan_for_changes
The scan_for_changes was moved from docs.py to commitmessage.py, this
patch adds a commitmessage test for scan_for_changes.
2017-02-16 15:36:28 -08:00
Matthew Johnson 192ee3570d Add unit tests for commitmessage module 2017-02-16 15:35:35 -08:00
Alex Jaramillo 4e4530744c Pkg verification interactive mode special cases
This patch adds handling for two cases for interactive
mode. 1- when non pty, the interactive mode is disabled
, and 2- timeout input function, when user fails to type
an input in interactive mode the script will continue
after a timeout.
2017-02-14 19:43:34 +00:00