Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/AlDanial/cloc
Browse files Browse the repository at this point in the history
  • Loading branch information
AlDanial committed May 11, 2024
2 parents 57d223b + 657038f commit 97a71c4
Show file tree
Hide file tree
Showing 14 changed files with 258 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
IMAGE_TAG: ${{ github.sha }}
run: |
# Build a docker container to run tests
docker build .
docker build . --target test
37 changes: 25 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,44 @@
# Dockerfile by Sébastien HOUZÉ, https://github.com/shouze
FROM perl:slim AS base
FROM perl:slim AS builder

RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
git \
unzip \
dos2unix \
&& rm -rf /var/lib/apt/lists/*
gcc

#Install all dependencies
# 2024-01-19 cpanm command has been failing -- no explanation
#RUN cpanm \
# Algorithm::Diff \
# Digest::MD5 \
# Parallel::ForkManager \
# Regexp::Common \
# && rm -rf $HOME/.cpanm
RUN cpanm \
Algorithm::Diff \
Digest::MD5 \
Parallel::ForkManager \
Regexp::Common

#Copy source code
COPY cloc /usr/src/
RUN find /usr/src/ -type f -exec dos2unix {} \;

FROM perl:slim AS base

RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
git \
unzip \
&& rm -rf /var/lib/apt/lists/*

#Copy dependencies and source prepared in base image
COPY --from=builder /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=builder /usr/src/ /usr/src/

####################
FROM base AS test

RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates

#Copy test code
COPY .git /usr/src/.git
COPY tests /usr/src/tests
Expand Down
55 changes: 55 additions & 0 deletions Unix/t/01_opts.t
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,61 @@ my @Tests = (
'ref' => '../tests/outputs/issues/816/results.yaml',
},

{
'name' => '--fullpath issues/822 (github issue #822 T1)',
'cd' => '../tests/inputs',
'args' => '--fullpath --not-match-f "^c.csv" issues/822',
'ref' => '../tests/outputs/issues/822/T1.yaml',
},

{
'name' => '--fullpath issues/822 (github issue #822 T2)',
'cd' => '../tests/inputs',
'args' => '--vcs git --fullpath --not-match-f "^c.csv" issues/822',
'ref' => '../tests/outputs/issues/822/T2.yaml',
},

{
'name' => '--fullpath issues/822 (github issue #822 T3)',
'cd' => '../tests/inputs',
'args' => '--fullpath --not-match-f "b/c.csv" issues/822',
'ref' => '../tests/outputs/issues/822/T3.yaml',
},

{
'name' => '--fullpath issues/822 (github issue #822 T4)',
'cd' => '../tests/inputs',
'args' => '--vcs git --fullpath --not-match-f "b/c.csv" issues/822',
'ref' => '../tests/outputs/issues/822/T4.yaml',
},

{
'name' => '--fullpath issues/822 (github issue #822 T5)',
'cd' => '../tests/inputs',
'args' => '--fullpath --not-match-d "^b" issues/822',
'ref' => '../tests/outputs/issues/822/T5.yaml',
},

{
'name' => '--fullpath issues/822 (github issue #822 T6)',
'cd' => '../tests/inputs',
'args' => '--vcs git --fullpath --not-match-d "^b" issues/822',
'ref' => '../tests/outputs/issues/822/T6.yaml',
},

{
'name' => '--fullpath issues/822 (github issue #822 T7)',
'cd' => '../tests/inputs',
'args' => '--fullpath --not-match-d "a/b" issues/822',
'ref' => '../tests/outputs/issues/822/T7.yaml',
},

{
'name' => '--fullpath issues/822 (github issue #822 T8)',
'cd' => '../tests/inputs',
'args' => '--vcs git --fullpath --not-match-d "a/b" issues/822',
'ref' => '../tests/outputs/issues/822/T8.yaml',
},
);

# Special cases:
Expand Down
9 changes: 6 additions & 3 deletions cloc
Original file line number Diff line number Diff line change
Expand Up @@ -5807,15 +5807,18 @@ sub invoke_generator { # {{{1
if ($opt_fullpath and any_match($F, 0, \$rule, @opt_not_match_d)) {
$Ignored{$F} = "--not-match-d=$rule";
next;
} elsif (any_match(basename($F), 0, \$rule, @opt_not_match_d)) {
} elsif (!$opt_fullpath and any_match(basename($F), 0, \$rule, @opt_not_match_d)) {
$Ignored{$F} = "--not-match-d (basename) =$rule";
next;
}
}
if (@opt_not_match_f) {
my $rule;
if (any_match(basename($F), 0, \$rule, @opt_not_match_f)) {
$Ignored{$F} = "--not-match-d =$rule";
if ($opt_fullpath and any_match($F, 0, \$rule, @opt_not_match_f)) {
$Ignored{$F} = "--not-match-f=$rule";
next;
} elsif (!$opt_fullpath and any_match(basename($F), 0, \$rule, @opt_not_match_f)) {
$Ignored{$F} = "--not-match-f (basename) =$rule";
next;
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/inputs/issues/822/a.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
111,222
2 changes: 2 additions & 0 deletions tests/inputs/issues/822/a/b/c.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
aaa,bbb
ccc,ddd
21 changes: 21 additions & 0 deletions tests/outputs/issues/822/T1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# github.com/AlDanial/cloc
header :
cloc_url : github.com/AlDanial/cloc
cloc_version : 2.01
elapsed_seconds : 0.00448489189147949
n_files : 2
n_lines : 3
files_per_second : 445.9416298974
lines_per_second : 668.912444846101
report_file : ../outputs/issues/822/T1.yaml
'CSV' :
nFiles: 2
blank: 0
comment: 0
code: 3
SUM:
blank: 0
comment: 0
code: 3
nFiles: 2
21 changes: 21 additions & 0 deletions tests/outputs/issues/822/T2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# github.com/AlDanial/cloc
header :
cloc_url : github.com/AlDanial/cloc
cloc_version : 2.01
elapsed_seconds : 0.0277459621429443
n_files : 2
n_lines : 3
files_per_second : 72.0825606874329
lines_per_second : 108.123841031149
report_file : ../outputs/issues/822/T2.yaml
'CSV' :
nFiles: 2
blank: 0
comment: 0
code: 3
SUM:
blank: 0
comment: 0
code: 3
nFiles: 2
21 changes: 21 additions & 0 deletions tests/outputs/issues/822/T3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# github.com/AlDanial/cloc
header :
cloc_url : github.com/AlDanial/cloc
cloc_version : 2.01
elapsed_seconds : 0.00403499603271484
n_files : 1
n_lines : 1
files_per_second : 247.831718269913
lines_per_second : 247.831718269913
report_file : ../outputs/issues/822/T3.yaml
'CSV' :
nFiles: 1
blank: 0
comment: 0
code: 1
SUM:
blank: 0
comment: 0
code: 1
nFiles: 1
21 changes: 21 additions & 0 deletions tests/outputs/issues/822/T4.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# github.com/AlDanial/cloc
header :
cloc_url : github.com/AlDanial/cloc
cloc_version : 2.01
elapsed_seconds : 0.0277609825134277
n_files : 1
n_lines : 1
files_per_second : 36.0217798313265
lines_per_second : 36.0217798313265
report_file : ../outputs/issues/822/T4.yaml
'CSV' :
nFiles: 1
blank: 0
comment: 0
code: 1
SUM:
blank: 0
comment: 0
code: 1
nFiles: 1
21 changes: 21 additions & 0 deletions tests/outputs/issues/822/T5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# github.com/AlDanial/cloc
header :
cloc_url : github.com/AlDanial/cloc
cloc_version : 2.01
elapsed_seconds : 0.00425601005554199
n_files : 2
n_lines : 3
files_per_second : 469.923701753403
lines_per_second : 704.885552630105
report_file : ../outputs/issues/822/T5.yaml
'CSV' :
nFiles: 2
blank: 0
comment: 0
code: 3
SUM:
blank: 0
comment: 0
code: 3
nFiles: 2
21 changes: 21 additions & 0 deletions tests/outputs/issues/822/T6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# github.com/AlDanial/cloc
header :
cloc_url : github.com/AlDanial/cloc
cloc_version : 2.01
elapsed_seconds : 0.0273749828338623
n_files : 2
n_lines : 3
files_per_second : 73.0594065442131
lines_per_second : 109.58910981632
report_file : ../outputs/issues/822/T6.yaml
'CSV' :
nFiles: 2
blank: 0
comment: 0
code: 3
SUM:
blank: 0
comment: 0
code: 3
nFiles: 2
21 changes: 21 additions & 0 deletions tests/outputs/issues/822/T7.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# github.com/AlDanial/cloc
header :
cloc_url : github.com/AlDanial/cloc
cloc_version : 2.01
elapsed_seconds : 0.00388598442077637
n_files : 1
n_lines : 1
files_per_second : 257.335051230137
lines_per_second : 257.335051230137
report_file : ../outputs/issues/822/T7.yaml
'CSV' :
nFiles: 1
blank: 0
comment: 0
code: 1
SUM:
blank: 0
comment: 0
code: 1
nFiles: 1
21 changes: 21 additions & 0 deletions tests/outputs/issues/822/T8.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# github.com/AlDanial/cloc
header :
cloc_url : github.com/AlDanial/cloc
cloc_version : 2.01
elapsed_seconds : 0.0281188488006592
n_files : 1
n_lines : 1
files_per_second : 35.5633335877021
lines_per_second : 35.5633335877021
report_file : ../outputs/issues/822/T8.yaml
'CSV' :
nFiles: 1
blank: 0
comment: 0
code: 1
SUM:
blank: 0
comment: 0
code: 1
nFiles: 1

0 comments on commit 97a71c4

Please sign in to comment.