xref: /llvm-project/clang/test/ClangScanDeps/modules-full-output-tu-order.c (revision a26ec542371652e1d774696e90016fd5b0b1c191)
186405450SJan Svoboda // This test checks that ordering of TUs in the input CDB is preserved in the full output.
286405450SJan Svoboda 
386405450SJan Svoboda // RUN: rm -rf %t
486405450SJan Svoboda // RUN: split-file %s %t
586405450SJan Svoboda 
686405450SJan Svoboda //--- cdb.json.template
786405450SJan Svoboda [
886405450SJan Svoboda   {
986405450SJan Svoboda     "directory": "DIR",
1086405450SJan Svoboda     "file": "DIR/tu.c",
113ac8d322SJan Svoboda     "command": "clang -fmodules -fmodules-cache-path=DIR/cache -c DIR/tu.c -DONE -o DIR/tu1.o"
1286405450SJan Svoboda   },
1386405450SJan Svoboda   {
1486405450SJan Svoboda     "directory": "DIR",
1586405450SJan Svoboda     "file": "DIR/tu.c",
163ac8d322SJan Svoboda     "command": "clang -fmodules -fmodules-cache-path=DIR/cache -c DIR/tu.c -DTWO -o DIR/tu2.o"
1786405450SJan Svoboda   }
1886405450SJan Svoboda ]
1986405450SJan Svoboda 
2086405450SJan Svoboda //--- tu.c
2186405450SJan Svoboda 
2286405450SJan Svoboda // RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
2386405450SJan Svoboda // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full > %t/result.json
2486405450SJan Svoboda // RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck -DPREFIX=%/t %s
2586405450SJan Svoboda 
2686405450SJan Svoboda // CHECK:      {
2786405450SJan Svoboda // CHECK-NEXT:   "modules": [],
2886405450SJan Svoboda // CHECK-NEXT:   "translation-units": [
2986405450SJan Svoboda // CHECK-NEXT:     {
3086405450SJan Svoboda // CHECK-NEXT:       "commands": [
3186405450SJan Svoboda // CHECK-NEXT:         {
3286405450SJan Svoboda // CHECK-NEXT:           "clang-context-hash": "{{.*}}",
3386405450SJan Svoboda // CHECK-NEXT:           "clang-module-deps": [],
3486405450SJan Svoboda // CHECK-NEXT:           "command-line": [
353ac8d322SJan Svoboda // CHECK:                  "-D"
363ac8d322SJan Svoboda // CHECK-NEXT:             "ONE"
3786405450SJan Svoboda // CHECK:                ],
38*a26ec542SMartin Storsjö // CHECK:                "file-deps": [
3986405450SJan Svoboda // CHECK-NEXT:             "[[PREFIX]]/tu.c"
4086405450SJan Svoboda // CHECK-NEXT:           ],
4186405450SJan Svoboda // CHECK-NEXT:           "input-file": "[[PREFIX]]/tu.c"
4286405450SJan Svoboda // CHECK-NEXT:         }
4386405450SJan Svoboda // CHECK:            ]
44c4de9b9cSJan Svoboda // CHECK:          },
4586405450SJan Svoboda // CHECK-NEXT:     {
4686405450SJan Svoboda // CHECK-NEXT:       "commands": [
4786405450SJan Svoboda // CHECK-NEXT:         {
4886405450SJan Svoboda // CHECK-NEXT:           "clang-context-hash": "{{.*}}",
4986405450SJan Svoboda // CHECK-NEXT:           "clang-module-deps": [],
5086405450SJan Svoboda // CHECK-NEXT:           "command-line": [
513ac8d322SJan Svoboda // CHECK:                  "-D"
523ac8d322SJan Svoboda // CHECK-NEXT:             "TWO"
5386405450SJan Svoboda // CHECK:                ],
54*a26ec542SMartin Storsjö // CHECK:                "file-deps": [
5586405450SJan Svoboda // CHECK-NEXT:             "[[PREFIX]]/tu.c"
5686405450SJan Svoboda // CHECK-NEXT:           ],
5786405450SJan Svoboda // CHECK-NEXT:           "input-file": "[[PREFIX]]/tu.c"
58c4de9b9cSJan Svoboda // CHECK:              }
5986405450SJan Svoboda // CHECK:            ]
60c4de9b9cSJan Svoboda // CHECK:          }
61c4de9b9cSJan Svoboda // CHECK:        ]
62c4de9b9cSJan Svoboda // CHECK:      }
63