Commit Graph

38 Commits

Author SHA1 Message Date
Daniel Rodríguez Troitiño
b0a199e1b8 [test] Isolate swift_build_support.swift testing (#80192)
The test was using the default value for SWIFT_BUILD_ROOT, which tried
to write into `.build_script_log`. Use an environment variable so the
tests use their own directory and write files that do not append to the
actual `.build_script_log`.

Follow up to #80102
2025-03-21 03:36:44 -07:00
Alastair Houghton
71abe6f26b [Tests] Disable backtracing in some tests.
These tests can be negatively affected by the warnings about unsupported
Swift backtracer settings.

rdar://144497613
2025-02-25 10:53:28 +00:00
Ben Barham
ec1550c92a [validation] Fix line-directive validation test
This was disabled due to:
```
Unable to decode the command from the command line:
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 13-20: surrogates not allowed
```

Note that this error isn't in `line-directive`, but in Python decoding
surrogates from the command line. Not sure why that's not allowed, but
printing from within a script works so change to that.

We already set `PYTHONIOENCODING=UTF8` in the environment in
`test/lit.cfg`, which makes sure stdout is UTF8 as opposed to ASCII.

Resolves rdar://92613094.
2023-08-30 11:52:21 -07:00
Becca Royal-Gordon
1cc7e3b72c Move Python linting to primary tests
This will make it more likely that contributors discover Python style mistakes at their desks instead of in Swift CI.
2022-10-05 16:19:04 -07:00
Ben Barham
0627a20d5e [Test] Disable test to unblock CI 2022-05-03 13:57:53 -07:00
Evan Wilde
70c92cab52 Use less exotic unicode chars
The characters used before were in the private-use section had surrogate
chars. This led to issues with some python utf8 decoder implementations
resulting in the error

```
UnicodeEncodeError: 'utf-8' codec can't encode characters in position
13-20: surrogates not allowed
```

This uses more normal utf8 characters that should hopefully work
everywhere while still exhibiting issues decoding to ascii.
2022-05-02 10:17:27 -07:00
Evan Wilde
edc30c3296 Add utf8 line-directive test 2022-04-28 18:26:45 -07:00
Eric Miotto
187f4dbaf8 [Build] Add option to alter default location of module cache in Linux (#35711)
This is meant to support parallel CI runs on the same Linux bot, so that
they don't share the module cache and reduce (hopefully) the likelihood
of issues related to invalid signatures.

When the option is enabled, the environment variable `XDG_CACHE_HOME`
is explicitly set in `build-script` and should be inherited by all the
child processes.
Currently we don't check the operating system before setting the
variable (since it should be a noop for other OSes).

Addresses rdar://73887745
2021-02-03 07:32:29 -08:00
Ross Bayer
c096e29967 [Python: flake8] Update the utils/python_lint.py script to fail with a non-zero exit code if flake8 and flake8-import-order are not installed. 2020-02-03 13:10:15 -08:00
Ross Bayer
d39dae54e4 [Build System: Python] Renamed the Python lint validation test and updated the contents to match the other tests. 2020-01-19 01:32:58 -08:00
Ross Bayer
83bfc69ea3 [Build System: update-checkout] Added a new run_test.py script to utils/update_checkout which is used to run the validation test. 2020-01-19 01:32:47 -08:00
Ross Bayer
de1759c84f [Build System: build-script] Added a new run_test.py script to utils/swift_build_support which is used to run the unit test suite. 2020-01-19 01:31:21 -08:00
Ross Bayer
7587c7c0ac [Build System: build-script] Re-structured the build_swift module tests to contain a build_swift directory.
Having the test directory match the module we are testing means we can have scripts in the top level of utils/build_swift which can also have tests. As part of this re-structure the test utilties have been simplified somewhat and all tests no longer use a custom TestCase, rather the standard one exposed by the unittest module.
2020-01-19 01:31:21 -08:00
Ross Bayer
31f063b8b8 [Build System: build-script] Remove the old arguments module hiding in swift_build_support in favor of the more featureful one living in build_swift. 2020-01-17 00:30:17 -08:00
Michael Gottesman
ab3db3e37a [bug-reducer] Disable test for now until I have time to look at this. 2019-08-13 14:17:42 -07:00
Michael Gottesman
a9d384dac3 [update-checkout] Add a simple mock update-checkout test that makes sure that we can clone.
This commit is not meant to completely test update-checkout, but rather create
some scaffolding for testing update-checkout so we can create starter bugs to
fill out the rest of the functionality. Once we have enough testing in place, we
can start refactoring/simplifying update-checkout.

Design
------

This is just a standard python unittest test suite except that the tests expect
an environment variable (UPDATECHECKOUT_TEST_WORKSPACE_DIR) to be set that
specifies the directory that the unittests have for creating mock git repos
during setup/teardown. lit invokes the test by calling the unittests with the
environment variable set to the appropriate temporary directory.

In this temporary directory, each test creates a pristine set of "fake" remote
repos and a test-config.json file that can be passed to update-checkout to work
with these "fake" remote repos. This allows each test that we write to test
various update-checkout functionalities against a pristime set of git repos. I
choose the git clone test, just b/c it was really simple.

NOTE: One can also run the tests locally using the script
test_update_checkout.sh that uses /tmp/workspace as the workspace directory.
2019-06-21 18:25:08 -07:00
Michael Gottesman
6be8a68c41 [update-checkout] Do not run tests when testing simulators.
Feedback from Mishal on 0b8381ae78.
2018-07-27 12:39:34 -07:00
Michael Gottesman
0b8381ae78 [update-checkout] Move all files except the top level entrypoints into ./utils/update_checkout/*.
This makes update_checkout into a true python module that we can add nosetests
for, readme, and also split up without issue into multiple small files.

I also added a small stub test directory and support for running tests for
update_checkout during validation-testing. So once we add some tests, everything
is setup correctly in terms of the swift build for testing purposes.
2018-07-26 10:07:18 -07:00
Pavol Vaskovic
b7eb476f94 [benchmark] Moved tests for benchmark scripts
Moved `lit` test that runs unit tests for benchmark scripts from `validation-test/Python` to `test/benchmark` directory. Run the tests for benchmark infrustructure with single lit invocation:
````
swift-source$ ./llvm/utils/lit/lit.py -sv ${SWIFT_BUILD_DIR}/test-macosx-x86_64/benchmark
````

Documented the invocation of benchmark infrastructure tests in README.md
2018-07-09 13:55:48 +02:00
Michael Gottesman
b77a47ed83 [bug_reducer] Update/fix for mangling/bitrot.
rdar://31044019
2018-06-03 18:50:35 -07:00
Ross Bayer
85abdcd62d Argparse "Overlay" Module (#12873)
* Implemented a wrapper module around the standard argparse package, exposing the same interface with some extras on top, including a new builder type with expressive DSL for constructing complex argument parsers.

* Fixed imports in build_swift/argparse/__init__.py to make flake8 happy.

* More re-formmating to meet the exacting standards of the python_lint script.

* Added doc-strings to all the modules in the build_swift argparse overlay.

* Implemented a new BoolType for the argparse module which handles boolean-like values and replaces the hard-coded boolean values in the _ToggleAction class.

* Fixed the mess of imports in the tests sub-package to favor relative imports, so now the unit-tests will actually run as expected. The README has also been updated with a better command for executing the unit-test suite.

* Updated the add_positional method on the ArgumentParser builder class to only take a single action or default to the store action.

* Cleaned up the set_defaults method.

* Added validation test to run the build_swift unit-tests.

* Updated validation-test for the build_swift unit-test suite to use %utils.

* Fixed hard-coded default values in the expected_options module used for generating argument parser tests.

* Updated the comment in the Python validation test to run the build_swift unit-tests.
2017-11-27 21:49:44 -08:00
Pavol Vaskovic
49ddd96c83 Added documentation and test coverage.
compare_perf_test.py is now covered with unit tests and public methods are documented in the implementation.

Minor refactoring  to better conform to Python conventions:
* classes declared in new style
* proper private method prefix of single underscore
* replacing map with list comprehension where it was clearer

Unit test are executed as part of validation-test.

.gitignore was modified to ignore .coverage and htmlcov artifacts generated by the coverage.py package
2017-06-01 20:05:40 +02:00
Hugh Bellamy
abfca72357 Run python linting on the file if running doctests 2017-03-27 12:31:56 +07:00
Hugh Bellamy
fbad5fdfa6 Integrate python linting into validation tests 2017-03-23 14:05:15 +07:00
Mishal Shah
dd9c81c965 Revert "Integrate python-lint into validation tests" 2017-03-21 12:24:46 -07:00
Hugh Bellamy
7007c34dfd Integrate python linting into validation tests 2017-03-21 19:28:31 +07:00
Michael Gottesman
96a087ecdc Update requires line in bug-reducer.test-sh to work around master-next not liking rdar:// in requires lines. 2017-03-16 14:55:23 -07:00
Erik Eckstein
2a55b26e46 Mangling: enable new mangling for symbols 2017-03-16 12:04:08 -07:00
Michael Gottesman
efb1ea4701 [bug-reducer] Disable bug reducer when the CMAKE_GENERATOR used is not Ninja.
The bug reducer makes assumptions about the layout of the swift build directory
that may not be true in non-Ninja builds. Two examples of cmake generators that
would cause problems are VisualStudio and Xcode. I do not have time right now to
add such support, hence the disabling of the test.

rdar://30311943
2017-02-01 12:54:37 -08:00
Michael Gottesman
cddc50a5e8 [sil-bug-reducer] Only test the bug reducer when asserts are enabled.
Quick fix to unbreak bots.
2016-12-14 09:48:53 -08:00
Michael Gottesman
b7a79756db [sil-bug-reducer] Initial version of bug_reducer.
Currently it supports random bug finding and opt pipeline reduction. At some
point in the future it will support:

1. Reducing of optimizer crasher test cases.
2. Reducing optimizer miscompile test cases.

But those are for another time, this is just a first step. Patches welcome = ).
Check out llvm's bugpoint for inspiration.

It also has a basic test of pass pipeline reduction that is triggered via the
validation testing in lit. One thing to note here is that the tool right now
assumes darwin. This can be fixed in the future.
2016-12-12 23:30:51 -08:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Rintaro Ishizaki
81aa5dbbd2 [tests] Fix missing %utils and %gyb utilization. 2016-06-11 22:59:39 +09:00
Rintaro Ishizaki
1bdce7ced6 [lit] Add substitutions: %utils and %line-directive
%utils => ${SWIFT_SOURCE_DIR}/utils
%line-directive => ${SWIFT_SOURCE_DIR}/utils/line-directive
2016-06-11 02:41:15 +09:00
Rintaro Ishizaki
87246629f3 [gyb] Add gyb doctest to validation-test 2016-06-10 18:56:17 +09:00
Brian Gesiak
57380faa3b [validation-test] Add line-directive doctests
`utils/line-directive` is used when building Swift (see
`cmake/modules/AddSwift.cmake`), and includes some doctests. In order
to make sure it continues to behave as intended, add its tests to
`validation-test`.
2015-12-29 00:22:47 -05:00
Brian Gesiak
ca3e11b2d6 [build-script] Determine HOST_CC in build-script
https://bugs.swift.org/browse/SR-237 calls for `build-script` and
`build-script-impl` to be merged. This commit takes another step towards
that goal by moving the logic that finds the path to the `clang` and
`clang++` executables up into Python-land.

Rather than simply moving all of the logic into `utils/build-script`,
this commit moves relevant functions into a new Python module, named
`swift_build_support`. This has several benefits:

- The logic can be tested. Whereas `build-script-impl` needed to be run
  in order to verify its behavior, the logic extracted out of it into
  `swift_build_support` can be tested in isolation.
- The logic can be split up into several files without polluting the
  `utils` directory, which now contains many different files that are
  unrelated to `build-script`.
2015-12-27 02:35:32 -05:00
Brian Gesiak
0ede0c4bcd [test] Run Python unit tests in validation tests
This repository includes several Python modules, each with unit tests.
Add a step to the validation tests to ensure these tests pass.
2015-12-27 01:57:33 -05:00