1## Test moving files after a file.
2
3RUN: touch %t1.txt
4RUN: touch %t2.txt
5RUN: touch %t3.txt
6RUN: touch %t4.txt
7
8# Move one file:
9RUN: rm -f %t-one.a
10RUN: llvm-ar rc %t-one.a %t1.txt %t2.txt %t3.txt
11RUN: llvm-ar ma %t1.txt %t-one.a %t3.txt
12RUN: llvm-ar t %t-one.a | FileCheck %s --check-prefix=ONE
13
14ONE:      1.txt
15ONE-NEXT: 3.txt
16ONE-NEXT: 2.txt
17
18# Move file to back:
19RUN: rm -f %t-back.a
20RUN: llvm-ar rc %t-back.a %t1.txt %t2.txt %t3.txt
21RUN: llvm-ar ma %t2.txt %t-back.a %t1.txt
22RUN: llvm-ar t %t-back.a | FileCheck %s --check-prefix=BACK
23
24BACK:      2.txt
25BACK-NEXT: 1.txt
26BACK-NEXT: 3.txt
27
28# Move multiple files:
29RUN: rm -f %t-multiple.a
30RUN: llvm-ar rc %t-multiple.a %t1.txt %t2.txt %t3.txt %t4.txt
31RUN: llvm-ar ma %t1.txt %t-multiple.a  %t4.txt %t3.txt
32RUN: llvm-ar t %t-multiple.a | FileCheck %s --check-prefix=MULTIPLE
33
34MULTIPLE:      1.txt
35MULTIPLE-NEXT: 3.txt
36MULTIPLE-NEXT: 4.txt
37MULTIPLE-NEXT: 2.txt
38
39# Move after invalid file:
40RUN: rm -f %t-invalid.a
41RUN: llvm-ar rc %t-invalid.a %t1.txt %t2.txt %t3.txt
42RUN: not llvm-ar ma invalid.txt %t-invalid.a %t2.txt 2>&1 \
43RUN:   | FileCheck %s --check-prefix=ERROR
44RUN: llvm-ar t %t-invalid.a | FileCheck %s --check-prefix=INVALID
45
46ERROR: error: insertion point not found
47INVALID:      1.txt
48INVALID-NEXT: 2.txt
49INVALID-NEXT: 3.txt
50
51# Move file to the same position:
52RUN: rm -f %t-position.a
53RUN: llvm-ar rc %t-position.a %t1.txt %t2.txt %t3.txt
54RUN: llvm-ar ma %t1.txt %t-position.a %t2.txt
55RUN: llvm-ar t %t-position.a | FileCheck %s --check-prefix=POSITION
56
57POSITION:      1.txt
58POSITION-NEXT: 2.txt
59POSITION-NEXT: 3.txt
60