Skip to content

Commit 562ade2

Browse files
committed
fix regex matching in cram
1 parent 518fa1c commit 562ade2

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

test/build_pkg/build-tarball.t

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ NOTE: this needs to have non-root user to be able to build
55

66
$ setup_git_test
77
> export to_install=( "$cache/downgrade/downgrade-2.0-1-any.pkg.tar.gz" "$cache/downgrade/downgrade-11.5.5-3c3182bb-any.gitpkg.tar.gz" "https://archive.archlinux.org/packages/x/xorg-twm/xorg-twm-1.0.7-1-x86_64.pkg.tar.xz" )
8-
> build_pkg
8+
> for item in "${to_install[@]}"; do build_pkg "$item"; done
9+
> mapfile -d '' to_install < new_to_install.downgrade
10+
> rm new_to_install.downgrade
911
> to_install_new=( "$cache/downgrade/downgrade-2.0-1-any.pkg.tar.gz" "$cache/downgrade/downgrade-11.5.5-1-any.pkg.tar.zst" "https://archive.archlinux.org/packages/x/xorg-twm/xorg-twm-1.0.7-1-x86_64.pkg.tar.xz" )
10-
> for i in $(seq ${#to_install[@]}); do if [[ "${to_install[i-1]}" != "${to_install_new[i-1]}" ]]; then echo "error"; fi; done
12+
> for i in $(seq ${#to_install[@]}); do if [[ "${to_install[i-1]}" != "${to_install_new[i-1]}" ]]; then echo "${to_install[i-1]} != ${to_install_new[i-1]}"; fi; done
1113
> echo "end"
1214
end

test/helper.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ setup_git_test() {
4646
if ! [[ -d "$cache/downgrade/.git" ]]; then
4747
git clone -q "https://aur.archlinux.org/downgrade.git" "$cache/downgrade"
4848
fi
49-
write_pacman_conf "[options]" "CacheDir = $cache/"
49+
write_pacman_conf "[options]" "CacheDir = $cache"
5050
}

test/search_git/search-remote.t

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
List remote files for chosen package
44

55

6+
because cram does not support multi-line regex matching we have to match this way
67
$ setup_git_test
78
> mkdir "$cache/downgrade-1"
89
> mkdir "$cache/downgrade-other"
9-
> DOWNGRADE_FROM_GIT=1 search_git 'downgrade'
10-
/tmp/.*/downgrade-([a-zA-Z0-9.]+)-.+-any.gitpkg.tar.gz (re)
10+
> DOWNGRADE_FROM_GIT=1 search_git 'downgrade' > file.matches
11+
> grep -vP '/tmp/.*/downgrade-([a-zA-Z0-9.]+)-.+-any.gitpkg.tar.gz' file.matches
12+
> echo end
13+
end
14+

test/search_git/specific-version.t

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,22 @@ With a version string included
1313
$ search_git 'downgrade' | filter_packages 'downgrade' '==' '5.1.3'
1414
/tmp/*/downgrade-5.1.3-0bdb507-any.gitpkg.tar.gz (glob)
1515

16-
$ search_git 'downgrade' | filter_packages 'downgrade' '>=' '6.0.0'
17-
/tmp/.*/downgrade-6.0.0-.*-any.gitpkg.tar.gz (re)
18-
/tmp/.*/downgrade-([6-9]|[1-9][0-9]+).[0-9.-]+-.*-any.gitpkg.tar.gz (re)
16+
because cram does not support multi-line regex matching we have to match this way
17+
$ search_git 'downgrade' | filter_packages 'downgrade' '>=' '6.0.0' > file.matches
18+
> grep -vP '/tmp/.*/downgrade-(6.0.0|([6-9]|[1-9][0-9]+).[0-9.-]+)-.*-any.gitpkg.tar.gz' file.matches
19+
> echo end
20+
end
1921

20-
$ search_git 'downgrade' | filter_packages 'downgrade' '<=' '5.2.0-1'
22+
$ search_git 'downgrade' | filter_packages 'downgrade' '<=' '5.2.0'
2123
/tmp/*/downgrade-5.1.3-0bdb507-any.gitpkg.tar.gz (glob)
2224
/tmp/*/downgrade-5.1.4-dee7bd9-any.gitpkg.tar.gz (glob)
2325
/tmp/*/downgrade-5.2.0-16b7466-any.gitpkg.tar.gz (glob)
2426
25-
$ search_git 'downgrade' | filter_packages 'downgrade' '>' '6.0.0'
26-
/tmp/.*/downgrade-(?!6\.0\.0)[0-9.]+-.*-any.gitpkg.tar.gz (re)
27-
/tmp/.*/downgrade-([6-9]|[1-9][0-9]+).[0-9.-]+-.*-any.gitpkg.tar.gz (re)
27+
because cram does not support multi-line regex matching we have to match this way
28+
$ search_git 'downgrade' | filter_packages 'downgrade' '>' '6.0.0' > file.matches
29+
> grep -vP '/tmp/.*/downgrade-((?!6\.0\.0)[0-9.]+|([6-9]|[1-9][0-9]+).[0-9.-]+)-.*-any.gitpkg.tar.gz' file.matches
30+
> echo end
31+
end
2832

2933
$ search_git 'downgrade' | filter_packages 'downgrade' '<' '5.2.0' | sort
3034
/tmp/*/downgrade-5.1.3-0bdb507-any.gitpkg.tar.gz (glob)

0 commit comments

Comments
 (0)