Skip to content

Commit 718abfe

Browse files
committed
precommit test and add pretty_assertions
1 parent e68b3b3 commit 718abfe

File tree

3 files changed

+197
-0
lines changed

3 files changed

+197
-0
lines changed

Cargo.lock

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

tests/test.rs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
use pretty_assertions::assert_eq;
2+
3+
use std::path::Path;
4+
5+
use rust_log_analyzer as rla;
6+
7+
const TEST_LOCATION: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests");
8+
9+
#[test]
10+
fn test_missing_line() {
11+
let log = std::fs::read(Path::new(TEST_LOCATION).join("test_missing_line.txt")).unwrap();
12+
let lines = rla::sanitize::split_lines(&log)
13+
.iter()
14+
.map(|l| {
15+
rla::index::Sanitized(rla::sanitize::clean(
16+
&rla::ci::GitHubActions::new("DUMMY_TOKEN"),
17+
l,
18+
))
19+
})
20+
.collect::<Vec<_>>();
21+
let blocks = rla::extract::extract(
22+
&rla::extract::Config::default(),
23+
&rla::index::Index::default(),
24+
&lines,
25+
);
26+
27+
let expected = r###"Current runner version: '2.320.0'
28+
Runner name: 'ubuntu-20.04-4core-16gb_f6653e6045ce'
29+
Runner group name: 'Default Larger Runners'
30+
Machine name: 'runner'
31+
##[group]Operating System
32+
Ubuntu
33+
LTS
34+
LTS
35+
##[endgroup]
36+
##[group]Runner Image
37+
Image: ubuntu-20.04
38+
Version: 20240922.1.0
39+
Included Software: https://github.com/actions/runner-images/blob/ubuntu20/20240922.1/images/ubuntu/Ubuntu2004-Readme.md
40+
Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu20%2F20240922.1
41+
##[endgroup]
42+
##[group]GITHUB_TOKEN Permissions
43+
Contents: read
44+
Metadata: read
45+
Packages: read
46+
##[endgroup]
47+
Secret source: None
48+
Prepare workflow directory
49+
Prepare all required actions
50+
Getting action download info
51+
Download action repository 'msys2/setup-msys2@v2.22.0' (SHA:cc11e9188b693c2b100158c3322424c4cc1dadea)
52+
Download action repository 'actions/checkout@v4' (SHA:eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871)
53+
Download action repository 'actions/upload-artifact@v4' (SHA:604373da6381bf24206979c74d06a550515601b9)
54+
Complete job name: PR - mingw-check
55+
##[group]Run git config --global core.autocrlf false
56+
git config --global core.autocrlf false
57+
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}"###;
58+
59+
let actual = blocks[0]
60+
.iter()
61+
.map(|line| String::from_utf8_lossy(&line.0).into_owned())
62+
.collect::<Vec<_>>()
63+
.join("\n");
64+
assert_eq!(actual, expected);
65+
}

tests/test_missing_line.txt

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
2024-10-08T13:24:44.9714395Z Current runner version: '2.320.0'
2+
2024-10-08T13:24:44.9720211Z Runner name: 'ubuntu-20.04-4core-16gb_f6653e6045ce'
3+
2024-10-08T13:24:44.9721030Z Runner group name: 'Default Larger Runners'
4+
2024-10-08T13:24:44.9721819Z Machine name: 'runner'
5+
2024-10-08T13:24:44.9737572Z ##[group]Operating System
6+
2024-10-08T13:24:44.9738426Z Ubuntu
7+
2024-10-08T13:24:44.9738831Z 20.04.6
8+
2024-10-08T13:24:44.9739117Z LTS
9+
2024-10-08T13:24:44.9739465Z ##[endgroup]
10+
2024-10-08T13:24:44.9739831Z ##[group]Runner Image
11+
2024-10-08T13:24:44.9740250Z Image: ubuntu-20.04
12+
2024-10-08T13:24:44.9740641Z Version: 20240922.1.0
13+
2024-10-08T13:24:44.9741642Z Included Software: https://github.com/actions/runner-images/blob/ubuntu20/20240922.1/images/ubuntu/Ubuntu2004-Readme.md
14+
2024-10-08T13:24:44.9743054Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu20%2F20240922.1
15+
2024-10-08T13:24:44.9743919Z ##[endgroup]
16+
2024-10-08T13:24:44.9758386Z ##[group]GITHUB_TOKEN Permissions
17+
2024-10-08T13:24:44.9760178Z Contents: read
18+
2024-10-08T13:24:44.9760679Z Metadata: read
19+
2024-10-08T13:24:44.9761095Z Packages: read
20+
2024-10-08T13:24:44.9761458Z ##[endgroup]
21+
2024-10-08T13:24:44.9764576Z Secret source: None
22+
2024-10-08T13:24:44.9765223Z Prepare workflow directory
23+
2024-10-08T13:24:45.0790330Z Prepare all required actions
24+
2024-10-08T13:24:45.0951557Z Getting action download info
25+
2024-10-08T13:24:45.2809779Z Download action repository 'msys2/setup-msys2@v2.22.0' (SHA:cc11e9188b693c2b100158c3322424c4cc1dadea)
26+
2024-10-08T13:24:45.7529926Z Download action repository 'actions/checkout@v4' (SHA:eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871)
27+
2024-10-08T13:24:46.0510433Z Download action repository 'actions/upload-artifact@v4' (SHA:604373da6381bf24206979c74d06a550515601b9)
28+
2024-10-08T13:24:46.6497915Z Complete job name: PR - mingw-check
29+
2024-10-08T13:24:46.7427541Z ##[group]Run git config --global core.autocrlf false
30+
2024-10-08T13:24:46.7428446Z git config --global core.autocrlf false
31+
2024-10-08T13:24:46.7460563Z shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
32+
2024-10-08T13:24:46.7461452Z env:
33+
2024-10-08T13:24:46.7462007Z TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
34+
2024-10-08T13:24:46.7462649Z TOOLSTATE_REPO_ACCESS_TOKEN:
35+
2024-10-08T13:24:46.7463065Z CI_JOB_NAME: mingw-check
36+
2024-10-08T13:24:46.7463438Z CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
37+
2024-10-08T13:24:46.7463988Z HEAD_SHA: 8c5b0edbe8c46fc2cd42de2cfc4cce2790262401
38+
2024-10-08T13:24:46.7464778Z DOCKER_TOKEN: ***
39+
2024-10-08T13:24:46.7465139Z SCCACHE_BUCKET: rust-lang-ci-sccache2
40+
2024-10-08T13:24:46.7465637Z CACHE_DOMAIN: ci-caches.rust-lang.org
41+
2024-10-08T13:24:46.7466055Z ##[endgroup]
42+
2024-10-08T13:24:47.1799712Z ##[group]Run actions/checkout@v4
43+
2024-10-08T13:24:47.1800134Z with:
44+
2024-10-08T13:24:47.1800369Z fetch-depth: 2
45+
2024-10-08T13:24:47.1800641Z repository: rust-lang/rust
46+
2024-10-08T13:24:47.1801140Z token: ***
47+
2024-10-08T13:24:47.1801377Z ssh-strict: true
48+
2024-10-08T13:24:47.1801626Z ssh-user: git
49+
2024-10-08T13:24:47.1801876Z persist-credentials: true
50+
2024-10-08T13:24:47.1802183Z clean: true
51+
2024-10-08T13:24:47.1802438Z sparse-checkout-cone-mode: true
52+
2024-10-08T13:24:47.1802751Z fetch-tags: false
53+
2024-10-08T13:24:47.1802996Z show-progress: true
54+
2024-10-08T13:24:47.1803253Z lfs: false
55+
2024-10-08T13:24:47.1803479Z submodules: false
56+
2024-10-08T13:24:47.1803724Z set-safe-directory: true
57+
2024-10-08T13:24:47.1804006Z env:
58+
2024-10-08T13:24:47.1804400Z TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
59+
2024-10-08T13:24:47.1804896Z TOOLSTATE_REPO_ACCESS_TOKEN:
60+
2024-10-08T13:24:47.1805217Z CI_JOB_NAME: mingw-check
61+
2024-10-08T13:24:47.1805672Z CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
62+
2024-10-08T13:24:47.1806109Z HEAD_SHA: 8c5b0edbe8c46fc2cd42de2cfc4cce2790262401
63+
2024-10-08T13:24:47.1806629Z DOCKER_TOKEN: ***
64+
2024-10-08T13:24:47.1806904Z SCCACHE_BUCKET: rust-lang-ci-sccache2
65+
2024-10-08T13:24:47.1807265Z CACHE_DOMAIN: ci-caches.rust-lang.org
66+
2024-10-08T13:24:47.1807593Z ##[endgroup]
67+
2024-10-08T13:24:47.2929497Z Syncing repository: rust-lang/rust
68+
2024-10-08T13:24:47.2931117Z ##[group]Getting Git version info
69+
2024-10-08T13:24:47.2931684Z Working directory is '/home/runner/work/rust/rust'
70+
2024-10-08T13:24:47.2932381Z [command]/usr/bin/git version
71+
2024-10-08T13:24:47.2932678Z git version 2.46.1
72+
2024-10-08T13:24:47.2933764Z ##[endgroup]
73+
2024-10-08T13:24:47.2945100Z Copying '/home/runner/.gitconfig' to '/home/runner/work/_temp/23e68be9-1b8b-4b10-8ace-ed08cab47f1e/.gitconfig'
74+
2024-10-08T13:24:47.2951942Z Temporarily overriding HOME='/home/runner/work/_temp/23e68be9-1b8b-4b10-8ace-ed08cab47f1e' before making global git config changes
75+
2024-10-08T13:24:47.2953149Z Adding repository directory to the temporary git global config as a safe directory
76+
2024-10-08T13:24:47.2957354Z [command]/usr/bin/git config --global --add safe.directory /home/runner/work/rust/rust
77+
2024-10-08T13:24:47.2987507Z Deleting the contents of '/home/runner/work/rust/rust'
78+
2024-10-08T13:24:47.2990999Z ##[group]Initializing the repository
79+
2024-10-08T13:24:47.2995629Z [command]/usr/bin/git init /home/runner/work/rust/rust
80+
2024-10-08T13:24:47.3680602Z hint: Using 'master' as the name for the initial branch. This default branch name
81+
2024-10-08T13:24:47.3681927Z hint: is subject to change. To configure the initial branch name to use in all
82+
2024-10-08T13:24:47.3683101Z hint: of your new repositories, which will suppress this warning, call:
83+
2024-10-08T13:24:47.3683909Z hint:
84+
2024-10-08T13:24:47.3684561Z hint: git config --global init.defaultBranch <name>
85+
2024-10-08T13:24:47.3685224Z hint:
86+
2024-10-08T13:24:47.3685726Z hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
87+
2024-10-08T13:24:47.3686482Z hint: 'development'. The just-created branch can be renamed via this command:
88+
2024-10-08T13:24:47.3686984Z hint:
89+
2024-10-08T13:24:47.3687251Z hint: git branch -m <name>
90+
2024-10-08T13:24:47.3687907Z Initialized empty Git repository in /home/runner/work/rust/rust/.git/
91+
2024-10-08T13:24:47.3694337Z [command]/usr/bin/git remote add origin https://github.com/rust-lang/rust
92+
2024-10-08T13:24:47.3788184Z ##[endgroup]
93+
2024-10-08T13:24:47.3789110Z ##[group]Disabling automatic garbage collection
94+
2024-10-08T13:24:47.3793450Z [command]/usr/bin/git config --local gc.auto 0
95+
2024-10-08T13:24:47.3821131Z ##[endgroup]
96+
2024-10-08T13:24:47.3821981Z ##[group]Setting up auth
97+
2024-10-08T13:24:47.3828842Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
98+
2024-10-08T13:24:47.3859866Z [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
99+
2024-10-08T13:24:47.7730825Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
100+
2024-10-08T13:24:47.7758099Z [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
101+
2024-10-08T13:24:47.7977189Z [command]/usr/bin/git config --local http.https://github.com/.extraheader AUTHORIZATION: basic ***
102+
2024-10-08T13:24:47.8011736Z ##[endgroup]
103+
2024-10-08T13:24:47.8012475Z ##[group]Fetching the repository
104+
2024-10-08T13:24:47.8020846Z [command]/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=2 origin +d7844ebeec0d4ff6b742a4f303ec63e2bfe74a0e:refs/remotes/pull/131375/merge
105+
2024-10-08T13:24:53.8717035Z From https://github.com/rust-lang/rust
106+
2024-10-08T13:24:53.8718509Z * [new ref] d7844ebeec0d4ff6b742a4f303ec63e2bfe74a0e -> pull/131375/merge
107+
2024-10-08T13:24:53.8739637Z ##[endgroup]
108+
2024-10-08T13:24:53.8740518Z ##[group]Determining the checkout info
109+
2024-10-08T13:24:53.8741825Z ##[endgroup]

0 commit comments

Comments
 (0)