xref: /llvm-project/llvm/utils/lit/tests/use-llvm-tool.py (revision 2ae58431873d449f63fa6dd20dbd280fa43b3ac2)
1## Show that lit reports the path of tools found via use_llvm_tool.
2## Additionally show that use_llvm_tool uses in order of preference:
3## 1) The path specified in an environment variable,
4## 2) The LLVM tools build directory,
5## 3) The PATH, if requested.
6
7# RUN: %{lit} %{inputs}/use-llvm-tool 2>&1 | \
8# RUN:   FileCheck %s -DDIR=%p
9
10## The exact breakdown of cases is:
11## Case | Env | Build Dir | PATH |
12##   1  |  /  |     X     |  N/S | <- Can be found via env
13##   2  |  X  |     /     |  N/S | <- Can be found via build dir if env specified
14##   3  | N/S |     /     |  N/S | <- Can be found via build dir
15##   4  | N/S |     X     |   /  | <- Can be found via PATH, if requested
16##   5  | N/S |     X     |  N/S | <- Cannot be found via PATH, if not requested
17##   6  |  /  |     /     |   /  | <- Env is preferred over build, PATH
18##   7  | N/S |     /     |   /  | <- Build dir is preferred over PATH
19##   8  |  X  |     X     |   X  | <- Say nothing if cannot be found if not required
20
21## Check the exact path reported for the first case, but don't bother for the
22## others.
23# CHECK:      note: using case1: [[DIR]]{{[\\/]}}Inputs{{[\\/]}}use-llvm-tool{{[\\/]}}env-case1
24# CHECK-NEXT: note: using case2: {{.*}}build{{[\\/]}}case2
25# CHECK-NEXT: note: using case3: {{.*}}build{{[\\/]}}case3
26# CHECK-NEXT: note: using case4: {{.*}}path{{[\\/]}}case4
27# CHECK-NOT:  case5
28# CHECK-NEXT: note: using case6: {{.*}}env-case6
29# CHECK-NEXT: note: using case7: {{.*}}build{{[\\/]}}case7
30# CHECK-NOT:  case8
31
32## Test that if required is True, lit errors if the tool is not found.
33# RUN: not %{lit} %{inputs}/use-llvm-tool-required 2>&1 | \
34# RUN:   FileCheck %s --check-prefix=ERROR
35# ERROR:      note: using found: {{.*}}found
36# ERROR-NEXT: fatal: couldn't find 'not-found' program
37