Skip to content

Commit 8d392a7

Browse files
authored
Fix: --target option should only run the desired target (#1038)
2 parents 4c34457 + cb157c4 commit 8d392a7

File tree

14 files changed

+105
-3
lines changed

14 files changed

+105
-3
lines changed

ci/run_tests.sh

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,36 @@ pushd with_examples
5959
popd
6060

6161
pushd many_examples
62-
"$fpm" build
62+
6363
"$fpm" run --example --all
6464
test -e demo1.txt
6565
test -e demo2.txt
6666
popd
6767

68+
# Test building individual targets
69+
pushd many_targets
70+
cases=( "1" "2" "3" )
71+
targets=( "run" "example" "test" )
72+
cmdrun=( "run --target" "run --example" "test --target" )
73+
for j in {0..2}
74+
do
75+
for i in {0..2}
76+
do
77+
rm -f *.txt
78+
this=${cases[$i]}
79+
others=${cases[@]/$this}
80+
filename=${targets[$j]}$this
81+
echo "$filename"
82+
"$fpm" ${cmdrun[$j]} $filename
83+
test -e $filename.txt
84+
for k in ${others[@]}
85+
do
86+
test ! -e ${targets[$k]}$k.txt
87+
done
88+
done
89+
done
90+
popd
91+
6892
pushd auto_discovery_off
6993
"$fpm" build
7094
"$fpm" run --target auto_discovery_off
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/*
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
program run1
2+
use file_mod
3+
implicit none
4+
call print_file("run",1)
5+
stop 0
6+
end program run1
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
program run2
2+
use file_mod
3+
implicit none
4+
call print_file("run",2)
5+
stop 0
6+
end program run2
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
program run3
2+
use file_mod
3+
implicit none
4+
call print_file("run",3)
5+
stop 0
6+
end program run3
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
program example1
2+
use file_mod
3+
implicit none
4+
call print_file("example",1)
5+
stop 0
6+
end program example1
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
program example2
2+
use file_mod
3+
implicit none
4+
call print_file("example",2)
5+
stop 0
6+
end program example2
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
program example3
2+
use file_mod
3+
implicit none
4+
call print_file("example",3)
5+
stop 0
6+
end program example3
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
name = "many_targets"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module file_mod
2+
implicit none
3+
public
4+
contains
5+
subroutine print_file(name,id)
6+
character(*), intent(in) :: name
7+
integer, intent(in) :: id
8+
integer :: i
9+
character(len(name)+1) :: nm
10+
write(nm,1)name,id
11+
open(newunit=i,file=nm//'.txt',form="formatted",action="write")
12+
write(i, '(a)') nm
13+
close(i)
14+
1 format(a,i1)
15+
end subroutine print_file
16+
end module file_mod
17+

0 commit comments

Comments
 (0)