Commit Graph

62 Commits

Author SHA1 Message Date
Saleem Abdulrasool
3d755b4a5d test: force line-directive to UTF-8
Treat the I/O data as UTF-8 rather than the system encoding, which can
fallback to `C`, treating unicode data as ASCII.  This improves the test
coverage on Linux with Python 3.
2020-07-20 22:23:38 -07:00
tbkka
3181dd1e4c Fix a bunch of python lint errors (#32951)
* Fix a bunch of python lint errors

* adjust indentation
2020-07-17 14:30:21 -07:00
Saleem Abdulrasool
37443a0ea1 validation: make line-directive python 3.5 friendly
`ModuleNotFoundError` was introduced in python 3.6 as a child of
`ImportError`.  However, some of the CI hosts use python 3.5.  Use
`ImportError` as the filter type to be compatible with earlier python
versions.
2020-07-13 20:55:05 +00:00
Saleem Abdulrasool
68a5343273 Merge pull request #32109 from compnerd/behold-the-future
Python 2/3 compat: gyb, gyb_sourcekit_support, gyb_syntax_support, li…
2020-06-01 14:17:51 -07:00
Gwynne Raskind
2001f07e52 Python 2/3 compat: gyb, gyb_sourcekit_support, gyb_syntax_support, line-directive 2020-05-31 14:20:20 -07:00
Mike Ash
2a55b9d08f Fix python lint errors. 2020-05-30 14:04:32 -04:00
David Zarzycki
80f0e39e1a [line-directive] Escape literal '['
New versions of Python warn if the literal is not escaped. Specifically:

    "Support for nested sets and set operations in regular expressions as in
    Unicode Technical Standard #18 might be added in the future. This would
    change the syntax. To facilitate this future change a FutureWarning will
    be raised in ambiguous cases for the time being. That include sets
    starting with a literal '[' or containing literal character sequences
    '--', '&&', '~~', and '||'. To avoid a warning, escape them with a
    backslash. (Contributed by Serhiy Storchaka in bpo-30349.)"

https://docs.python.org/dev/whatsnew/3.7.html
2020-04-14 07:19:25 -04: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
Daniel Rodríguez Troitiño
b981afb29b [windows][test] Improve line-directive test for Windows.
The line directive test was using a command for one of the tests. The
command was being built as a string, instead of relaying on Python
multi-platform command building from arrays. Additionally the command
itself was being escaped with single quotes, which in Windows mean
nothing and were ending in the output of the command.

The changes switches the string building for an array, and leaves the
string building and escaping to Python. This should work in both
macOS, Linux and Windows.

This should fix the failing test in Azure.
2019-07-17 12:37:41 -07:00
Dave Abrahams
c4d76fdc5c Satisfy the python linter 2019-01-07 15:27:48 -08:00
Dave Abrahams
4433a9f89e [line-directive] Add usage and explanatory text 2019-01-04 17:59:04 -08:00
Jordan Rose
6cd780395b [CMake] Make GNU-style response files for long argument lists (#18958)
...i.e. an actual shell-like argument list, rather than a
semicolon-separated list (CMake's internal stringification mechanism
for lists). Apart from being a little easier to read, this also works
directly with the response file support in swiftc itself now (not
depending on utils/line-directive).

(It's still not /quite/ enough to expand on a command-line, though,
since that will escape the quotes. The 'sed' command can get around
that: $(sed "s/'//g" foo.txt).)
2018-10-23 19:45:56 -07:00
Dave Abrahams
b52cf92609 Merge pull request #8292 from hughbe/gyb-line-direcrtive-cleanup
Cleanup recent line-directive and gyb test fixes
2017-03-26 23:54:40 -07:00
Hugh Bellamy
abfca72357 Run python linting on the file if running doctests 2017-03-27 12:31:56 +07:00
Hugh Bellamy
da9035cbb4 Cleanup recent line-directive and gyb test fixes 2017-03-25 15:45:27 +07:00
Hugh Bellamy
fbb4756cd8 Python-lint line-directive 2017-03-21 14:14:15 +07:00
Hugh Bellamy
53d0fba6e1 Use print_function in line-directive 2017-03-21 11:21:37 +07:00
Hugh Bellamy
79cf3bf171 Add regression test for recent line-directive breakage (SR-4238 ) 2017-03-21 10:32:27 +07:00
Hugh Bellamy
f235a78385 Properly clean up after line-directive doctests now delete=False 2017-03-21 08:29:40 +07:00
Hugh Bellamy
e3604357ea Fix line-directive test failures on Windows 2017-03-21 08:29:40 +07:00
swift-ci
b7163a6434 Merge pull request #8197 from hughbe/replace-line-directive-win-newline 2017-03-20 01:42:13 -07:00
swift-ci
854243b1cb Merge pull request #8192 from hughbe/line-directive-doctests 2017-03-20 00:16:47 -07:00
Hugh Bellamy
ff02ffe0f2 Fix newline errors in line-directive doctests 2017-03-20 14:09:58 +07:00
Hugh Bellamy
a52e7fc8b2 Return error code running line-directive doctests 2017-03-20 13:56:28 +07:00
Hugh Bellamy
995a879967 Use python to invoke line-directive doctests 2017-03-20 13:27:45 +07:00
Dave Abrahams
ea3cb07f10 Revert "Fix line-directive print errors on different python versions" 2017-03-19 14:35:33 -07:00
Dave Abrahams
3ce018e8d1 Revert "Python lint line-directive"
This reverts commit ccb7882ba0, as it broke the
line-directive tool per https://bugs.swift.org/browse/SR-4238
2017-03-19 13:52:43 -07:00
Hugh Bellamy
b43d63dc16 Fix line-directive print errors on different python versions 2017-02-10 14:51:48 +07:00
Hugh Bellamy
ccb7882ba0 Python lint line-directive 2017-02-09 18:15:07 +07:00
Hugh Bellamy
3b4187fcbb Fix line-directive tool to work around Windows command line max limit 2017-01-26 09:34:55 +00:00
practicalswift
a9d6d8938c [gardening] Fix recently introduced typos 2017-01-22 20:40:45 +01:00
Hugh Bellamy
e22e28e6a0 Fix line-directive-tool not being able to invoke swiftc.exe on Windows 2017-01-14 21:45:34 +00:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Ryan Lovelett
aa990aad58 Support Python 3 in the line-directive
* Switched to the "function" format of `RaiseError`
* Switched to the "function" format of `print`
2016-10-29 09:45:36 -04:00
Dave Abrahams
ee20a0193d [utils/line-directive] add reverse mapping
This will be useful for tooling involving gyb files.
2016-09-25 17:09:37 -07:00
Dave Abrahams
e253016a8d [utils/line-directive] add tests
in preparation for refactoring.
2016-09-25 16:40:03 -07:00
Michael Gottesman
07b463ba3e [gardening] Fix some python lint errors so this change is python lint clean. 2016-08-01 15:11:09 -07:00
Dave Abrahams
3f9b6aef01 utils/line-directive: cover type checker errors
This causes errors to be reported in the source file for things
generated by gyb.
2016-07-21 15:36:55 -07:00
practicalswift
da24168735 [Python] Fix recently introduced PEP-8 regression 2016-03-12 20:50:08 +01:00
Chris Lattner
7cbd5d96c3 update line-directive for #sourceLocation. 2016-03-12 09:25:29 -08:00
practicalswift
0796eaad1f [Python] Fix 80-column violations 2016-03-09 23:52:11 +01:00
Brian Gesiak
c9000af795 Merge pull request #1526 from practicalswift/fix-pep8-violations-ii
[Python] Fix five classes of PEP-8 violations (E101/E111/E128/E302/W191)
2016-03-08 23:55:46 -05:00
practicalswift
265835fdfc [Python] Use consistent import ordering for Python code
Ordering used:
1.) standard library imports
2.) third party imports
3.) local package imports

Each group is individually alphabetized.
2016-03-07 23:25:16 +01:00
practicalswift
183da818df [Python] Fix five classes of PEP-8 violations (E101/E111/E128/E302/W191)
* E101: indentation contains mixed spaces and tabs
* E111: indentation is not a multiple of four
* E128: continuation line under-indented for visual indent
* E302: expected 2 blank lines, found 1
* W191: indentation contains tabs
2016-03-07 22:36:23 +01:00
Daniel Duan
f14182a2b7 [Utils] replace #line with #setline in utils/line-directive 2016-03-01 23:08:54 -08:00
practicalswift
e395ea0f0e [Python] Follow standard Python docstrings conventions (PEP-0257).
https://www.python.org/dev/peps/pep-0257/
2016-02-20 17:11:57 +01:00
practicalswift
33452564f6 PEP8: Fix violations of type "continuation line under-indented for hanging indent" (E121) 2016-01-24 09:47:53 +01:00
practicalswift
84a31184c7 PEP8: Fix all violations of type "missing whitespace after ','" (E231) 2016-01-24 09:40:32 +01:00
practicalswift
1cd4d4e9c9 [gardening] Fix violations of non-controversial PEP8 rules
Fixes:
* multiple statements on one line (colon) (E701)
* missing whitespace around arithmetic operator (E226)
* missing whitespace around operator (E225)
* closing bracket does not match visual indentation (E124)
* blank line contains whitespace (W293)
* continuation line missing indentation or outdented (E122)
* continuation line over-indented for hanging indent (E126)
* missing expected blank line (E301)
* trailing whitespace (W291)
* unexpected spaces around keyword / parameter equals (E251)
* whitespace after '(', '[' or '{' (E201)
* whitespace before ')', ']' or '}' (E202)
* whitespace before ',' or ':' (E203)
2016-01-23 09:23:33 +01:00