Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit dd6fbe6

Browse files
committedAug 26, 2024·
mock REST API calls in tests
1 parent 9dde123 commit dd6fbe6

26 files changed

+2853
-273
lines changed
 

‎.github/workflows/binary-builds.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ jobs:
151151
env:
152152
GH_TOKEN: ${{ github.token }}
153153
run: |
154-
files=$(ls dist/cpp-linter*
154+
files=$(ls dist/cpp-linter*)
155155
gh release create ${{ github.ref_name }} --generate-notes $files
156156
- run: cargo publish
157157
working-directory: cpp-linter-lib

‎.github/workflows/python-packaging.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ jobs:
111111
- uses: actions/setup-python@v5
112112
with:
113113
python-version: '3.x'
114-
- name: Increment version
115-
if: startsWith(github.ref, 'refs/tags/')
116-
run: python .github/workflows/replace_version_spec.py --new-version=${{ github.ref_name }}
117114
- name: Build wheels
118115
uses: PyO3/maturin-action@v1
119116
with:
@@ -153,7 +150,8 @@ jobs:
153150
- name: Publish to PyPI
154151
uses: PyO3/maturin-action@v1
155152
env:
156-
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
153+
MATURIN_PYPI_TOKEN: ${{ contains(github.ref_name, 'rc') && secrets.TEST_PYPI_API_TOKEN || secrets.PYPI_API_TOKEN }}
154+
MATURIN_REPOSITORY: ${{ contains(github.ref_name, 'rc') && 'test-pypi' || 'pypi' }}
157155
with:
158156
command: upload
159157
args: --non-interactive --skip-existing dist/*

‎.github/workflows/run-dev-tests.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,16 @@ jobs:
7676
with:
7777
python-version: 3.x
7878

79-
# - name: Install workflow deps
80-
# run: python3 -m pip install meson
79+
- name: Install workflow deps
80+
run: python3 -m pip install meson
8181

8282
# # https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages
83-
# - name: Install ninja (Linux)
84-
# if: runner.os == 'Linux'
85-
# run: sudo apt-get install ninja-build
86-
# - name: Install ninja (Windows)
87-
# if: runner.os == 'Windows'
88-
# run: choco install ninja
83+
- name: Install ninja (Linux)
84+
if: runner.os == 'Linux'
85+
run: sudo apt-get install ninja-build
86+
- name: Install ninja (Windows)
87+
if: runner.os == 'Windows'
88+
run: choco install ninja
8989

9090
- name: Install Linux clang dependencies
9191
if: runner.os == 'Linux'

‎.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ repos:
33
rev: v4.6.0
44
hooks:
55
- id: trailing-whitespace
6-
exclude: cpp-linter-lib/tests/capture_tools_output/cpp-linter/cpp-linter/test_git_lib.patch
6+
exclude: cpp-linter-lib/tests/.*\.(?:patch|diff)
77
- id: end-of-file-fixer
88
- id: check-docstring-first
99
- id: check-added-large-files

‎Cargo.lock

Lines changed: 92 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎cpp-linter-lib/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ documentation.workspace = true
88
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
99

1010
[dependencies]
11+
chrono = "0.4.38"
1112
clap = "4.5.16"
13+
futures = "0.3.30"
1214
git2 = "0.19.0"
1315
lenient_semver = "0.4.2"
1416
log = "0.4.22"
@@ -26,6 +28,7 @@ tokio-stream = "0.1.15"
2628
which = "6.0.3"
2729

2830
[dev-dependencies]
31+
mockito = "1.5.0"
2932
tempfile = "3.9.0"
3033

3134
[features]
@@ -34,3 +37,5 @@ openssl-vendored = ["dep:openssl", "dep:openssl-probe"]
3437
[[bin]]
3538
name = "cpp-linter"
3639
path = "src/main.rs"
40+
test = false
41+
bench = false

‎cpp-linter-lib/examples/gh_rest_api.rs

Lines changed: 0 additions & 34 deletions
This file was deleted.

‎cpp-linter-lib/src/clang_tools/clang_tidy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl TidyNotification {
7777
pub fn diagnostic_link(&self) -> String {
7878
let ret_val = if let Some((category, name)) = self.diagnostic.split_once('-') {
7979
format!(
80-
"[{}](https://clang.llvm.org/extra/clang-tidy/checks/{category}/{name}).html",
80+
"[{}](https://clang.llvm.org/extra/clang-tidy/checks/{category}/{name}.html)",
8181
self.diagnostic
8282
)
8383
} else {
@@ -153,7 +153,7 @@ fn parse_tidy_output(
153153
line: captured[2].parse::<u32>().unwrap(),
154154
cols: captured[3].parse::<u32>().unwrap(),
155155
severity: String::from(&captured[4]),
156-
rationale: String::from(&captured[5]),
156+
rationale: String::from(&captured[5]).trim().to_string(),
157157
diagnostic: String::from(&captured[6]),
158158
suggestion: Vec::new(),
159159
});

‎cpp-linter-lib/src/cli/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ cpp-linter --extra-arg="-std=c++17" --extra-arg="-Wall"
226226
Arg::new("thread-comments")
227227
.long("thread-comments")
228228
.short('g')
229-
.value_parser(["true", "on", "1", "false", "off", "0", "updated"])
229+
.value_parser(["true", "on", "1", "false", "off", "0", "update"])
230230
.default_value("false")
231231
.help_heading("feedback options")
232232
.help(

‎cpp-linter-lib/src/common_fs/file_filter.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use std::{fs, path::Path};
1+
use std::{
2+
fs,
3+
path::{Path, PathBuf},
4+
};
25

36
use super::FileObj;
47

@@ -82,13 +85,21 @@ impl FileFilter {
8285
/// Returns a [`Some`] value of the the path/pattern that matches the given `file_name`.
8386
/// If given `file_name` is not in the specified list, then [`None`] is returned.
8487
pub fn is_file_in_list(&self, file_name: &Path, is_ignored: bool) -> Option<String> {
88+
let file_name = PathBuf::from(format!(
89+
"./{}",
90+
file_name
91+
.as_os_str()
92+
.to_string_lossy()
93+
.to_string()
94+
.replace("\\", "/")
95+
));
8596
let set = if is_ignored {
8697
&self.ignored
8798
} else {
8899
&self.not_ignored
89100
};
90101
for pattern in set {
91-
let pat = Path::new(&pattern);
102+
let pat = PathBuf::from(&pattern);
92103
if (pat.is_file() && file_name == pat) || (pat.is_dir() && file_name.starts_with(pat)) {
93104
return Some(pattern.to_owned());
94105
}

0 commit comments

Comments
 (0)
Please sign in to comment.