Skip to content

Commit 1232fbc

Browse files
committed
fixup: pre-commit config
1 parent db3a8ab commit 1232fbc

19 files changed

+46
-28
lines changed

.pre-commit-config.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ repos:
66
- id: end-of-file-fixer
77
- id: check-yaml
88
- id: check-json
9+
exclude: ^go-runner/testdata/
910
- id: check-merge-conflict
1011
- id: check-added-large-files
1112

@@ -14,7 +15,24 @@ repos:
1415
hooks:
1516
- id: fmt
1617
args: [--all, --]
18+
files: ^go-runner/
19+
pass_filenames: false
20+
additional_dependencies: []
21+
entry: bash -c 'cd go-runner && cargo fmt --all'
22+
language: system
23+
1724
- id: cargo-check
1825
args: [--all-targets]
26+
files: ^go-runner/
27+
pass_filenames: false
28+
additional_dependencies: []
29+
entry: bash -c 'cd go-runner && cargo check --all-targets'
30+
language: system
31+
1932
- id: clippy
2033
args: [--all-targets, --, -D, warnings]
34+
files: ^go-runner/
35+
pass_filenames: false
36+
additional_dependencies: []
37+
entry: bash -c 'cd go-runner && cargo clippy --all-targets -- -D warnings'
38+
language: system

go-runner/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
build-*/
22
target/
3-
.codspeed
3+
.codspeed

go-runner/src/builder/discovery.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
use std::{collections::HashMap, path::Path, process::Command};
44

5-
use crate::prelude::*;
65
use crate::builder::verifier;
6+
use crate::prelude::*;
77
use serde::{Deserialize, Serialize};
88

99
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -283,16 +283,15 @@ mod tests {
283283

284284
#[test]
285285
fn test_parse_go_list_output() {
286-
let content = include_str!("tests/go_list_output.json");
287-
let packages: Vec<GoPackage> =
288-
GoPackage::from_go_list_output(content).expect("Failed to parse JSON");
286+
let content = include_str!("../../testdata/builder/go_list_output.json");
287+
let packages: Vec<GoPackage> = GoPackage::from_go_list_output(content).unwrap();
289288

290289
insta::assert_json_snapshot!(packages);
291290
}
292291

293292
#[test]
294293
fn test_discover_benchmarks() {
295-
let content = include_str!("tests/multiple-pkgs.json");
294+
let content = include_str!("../../testdata/builder/multiple-pkgs.json");
296295
let packages: Vec<GoPackage> = GoPackage::from_go_list_output(content).unwrap();
297296
let benchmark_packages = discover_benchmarks(packages).unwrap();
298297

@@ -303,12 +302,12 @@ mod tests {
303302

304303
#[test]
305304
fn test_benchmarks_for_package() {
306-
let content = include_str!("tests/go_list_output.json");
305+
let content = include_str!("../../testdata/builder/go_list_output.json");
307306
let packages: Vec<GoPackage> = GoPackage::from_go_list_output(content).unwrap();
308307
let benchmark_packages = discover_benchmarks(packages).unwrap();
309308
let package = benchmark_packages
310309
.get("local.dev/example-complex/internal/config [local.dev/example-complex/internal/config.test]")
311-
.expect("Package not found");
310+
.unwrap();
312311

313312
let mut benches = package.benchmarks().unwrap();
314313
benches.sort_by_cached_key(|b| b.name.clone());

go-runner/src/builder/patcher.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ pub fn patch_imports<P: AsRef<Path>>(
2323
let patched_content = patch_go_source(&content)?;
2424

2525
if patched_content != content {
26-
fs::write(&go_file, patched_content).context(
27-
format!("Failed to write patched Go file: {}", go_file.display())
28-
)?;
26+
fs::write(&go_file, patched_content).context(format!(
27+
"Failed to write patched Go file: {}",
28+
go_file.display()
29+
))?;
2930

3031
debug!("Patched imports in: {}", go_file.display());
3132
patched_files += 1;
@@ -156,9 +157,9 @@ import (
156157
157158
import (
158159
"fmt"
159-
160+
160161
"testing"
161-
162+
162163
"strings"
163164
)
164165
"#;

go-runner/src/builder/snapshots/go_runner__builder__patcher__tests__import_with_extra_whitespace.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ package main
66

77
import (
88
"fmt"
9-
9+
1010
testing "github.com/AvalancheHQ/codspeed-go/compat/testing"
11-
11+
1212
"strings"
1313
)

go-runner/src/builder/template.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"reflect"
88
codspeed "github.com/AvalancheHQ/codspeed-go/compat/testing"
99
codspeed_testing "github.com/AvalancheHQ/codspeed-go/testing/testing"
10-
10+
1111
// Import parent package containing the benchmarks
1212
{{#each benchmarks}}
1313
{{import_alias}} "{{module_path}}"
@@ -83,4 +83,4 @@ func main() {
8383

8484
m := codspeed_testing.MainStart(simpleDeps{}, tests, benchmarks, fuzzTargets, examples)
8585
m.Run()
86-
}
86+
}

go-runner/src/builder/tests/multiple-pkgs.json renamed to go-runner/testdata/builder/multiple-pkgs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,4 +920,4 @@
920920
"fmt",
921921
"local.dev/codspeed-go/pkg/compat/testing"
922922
]
923-
}
923+
}

go-runner/src/builder/tests/simple_go_list.json renamed to go-runner/testdata/builder/simple_go_list.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,4 +362,4 @@
362362
"TestImports": [
363363
"github.com/AvalancheHQ/codspeed-go/compat/testing"
364364
]
365-
}
365+
}

0 commit comments

Comments
 (0)