Merge topic 'ctest-j-default' into release-3.29

5de1e21659 ctest: Allow passing -j without value to choose a contextual default
bbcbcff7d9 cmCTestMultiProcessHandler: Modernize member initialization
7457b474a1 Tests: Remove unnecessary parallel suppression from CTestCoverageCollectGCOV
ae69801d96 Tests: Convert CTestTestSkipReturnCode to RunCMake.ctest_test case
30dda49416 Tests: Convert CTestTestSerialOrder to RunCMake.ctest_test case

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Acked-by: scivision <michael@scivision.dev>
Merge-request: !9315
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index a6a2082..81f26f5 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -14,7 +14,7 @@
 Please post to the ``Development`` category of the `CMake Forum`_ to raise
 discussion of development topics.
 
-.. _`Kitware`: http://www.kitware.com/cmake
+.. _`Kitware`: https://www.kitware.com/cmake
 .. _`CMake Forum`: https://discourse.cmake.org
 
 Patches
diff --git a/Help/dev/documentation.rst b/Help/dev/documentation.rst
index 65c0ccf..00413e1 100644
--- a/Help/dev/documentation.rst
+++ b/Help/dev/documentation.rst
@@ -13,8 +13,8 @@
 They are written using the `reStructuredText`_ markup syntax and
 processed by `Sphinx`_ to generate the CMake help manuals.
 
-.. _`reStructuredText`: http://docutils.sourceforge.net/docs/ref/rst/introduction.html
-.. _`Sphinx`: http://sphinx-doc.org
+.. _`reStructuredText`: https://docutils.sourceforge.net/docs/ref/rst/introduction.html
+.. _`Sphinx`: https://sphinx-doc.org
 
 Markup Constructs
 -----------------
@@ -338,7 +338,7 @@
 
 The directive requires a single argument, the variable name.
 
-.. _`Sphinx Domain`: http://sphinx-doc.org/domains.html
+.. _`Sphinx Domain`: https://sphinx-doc.org/domains.html
 .. _`cmake(1)`: https://cmake.org/cmake/help/latest/manual/cmake.1.html
 .. _`cmake-env-variables(7)`: https://cmake.org/cmake/help/latest/manual/cmake-env-variables.7.html
 .. _`cmake-generator-expressions(7)`: https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html
@@ -520,7 +520,7 @@
 
 Mark up linkable references as links, including repeats.
 An alternative, which is used by wikipedia
-(`<http://en.wikipedia.org/wiki/WP:REPEATLINK>`_),
+(`<https://en.wikipedia.org/wiki/WP:REPEATLINK>`_),
 is to link to a reference only once per article. That style is not used
 in CMake documentation.
 
diff --git a/Help/dev/source.rst b/Help/dev/source.rst
index 68ca743..fa7d620 100644
--- a/Help/dev/source.rst
+++ b/Help/dev/source.rst
@@ -16,7 +16,7 @@
 source files for which we enforce style.  The script also has options to
 format only a subset of files, such as those that are locally modified.
 
-.. _`clang-format`: http://clang.llvm.org/docs/ClangFormat.html
+.. _`clang-format`: https://clang.llvm.org/docs/ClangFormat.html
 .. _`.clang-format`: ../../.clang-format
 .. _`Utilities/Scripts/clang-format.bash`: ../../Utilities/Scripts/clang-format.bash
 
diff --git a/Help/manual/ctest.1.rst b/Help/manual/ctest.1.rst
index edbd5a4..0e90ab6 100644
--- a/Help/manual/ctest.1.rst
+++ b/Help/manual/ctest.1.rst
@@ -250,9 +250,9 @@
 
  Run tests listed in the given file.
 
- This option tells CTest to run the tests which are listed in the given
- file. The file must contain one exact test name per line.
- Lines can be commented out using a ``#``.
+ This option tells CTest to run tests that are listed in the given file.
+ The file must contain one exact test name per line.
+ Lines that do not exactly match any test names are ignored.
  This option can be combined with the other options like
  ``-R``, ``-E``, ``-L`` or ``-LE``.
 
@@ -262,9 +262,9 @@
 
  Exclude tests listed in the given file.
 
- This option tells CTest to NOT run the tests which are listed in the given
- file. The file must contain one exact test name per line.
- Lines can be commented out using a ``#``.
+ This option tells CTest to NOT run tests that are listed in the given file.
+ The file must contain one exact test name per line.
+ Lines that do not exactly match any test names are ignored.
  This option can be combined with the other options like
  ``-R``, ``-E``, ``-L`` or ``-LE``.
 
diff --git a/Help/prop_inst/CPACK_WIX_ACL.rst b/Help/prop_inst/CPACK_WIX_ACL.rst
index 8b4fb5c..a82191a 100644
--- a/Help/prop_inst/CPACK_WIX_ACL.rst
+++ b/Help/prop_inst/CPACK_WIX_ACL.rst
@@ -18,6 +18,6 @@
 
 ``<permission>`` is any of the YesNoType attributes listed here::
 
- http://wixtoolset.org/documentation/manual/v3/xsd/wix/permission.html
+ https://wixtoolset.org/documentation/manual/v3/xsd/wix/permission.html
 
 The property is currently only supported by the :cpack_gen:`CPack WIX Generator`.
diff --git a/Help/release/3.6.rst b/Help/release/3.6.rst
index cc0d5da..63e3134 100644
--- a/Help/release/3.6.rst
+++ b/Help/release/3.6.rst
@@ -122,7 +122,7 @@
   from git repositories.
 
 * The :module:`FindBLAS` and :module:`FindLAPACK` modules learned to
-  support `OpenBLAS <http://www.openblas.net>`__.
+  support `OpenBLAS <https://www.openblas.net>`__.
 
 * The :module:`FindCUDA` module learned to find the ``cublas_device`` library.
 
diff --git a/Help/variable/CMAKE_PROJECT_HOMEPAGE_URL.rst b/Help/variable/CMAKE_PROJECT_HOMEPAGE_URL.rst
index 4c5debe..f82df2f 100644
--- a/Help/variable/CMAKE_PROJECT_HOMEPAGE_URL.rst
+++ b/Help/variable/CMAKE_PROJECT_HOMEPAGE_URL.rst
@@ -15,22 +15,22 @@
 .. code-block:: cmake
 
   cmake_minimum_required(VERSION 3.0)
-  project(First HOMEPAGE_URL "http://first.example.com")
-  project(Second HOMEPAGE_URL "http://second.example.com")
+  project(First HOMEPAGE_URL "https://first.example.com")
+  project(Second HOMEPAGE_URL "https://second.example.com")
   add_subdirectory(sub)
-  project(Third HOMEPAGE_URL "http://third.example.com")
+  project(Third HOMEPAGE_URL "https://third.example.com")
 
 And ``sub/CMakeLists.txt`` with the following contents:
 
 .. code-block:: cmake
 
-  project(SubProj HOMEPAGE_URL "http://subproj.example.com")
+  project(SubProj HOMEPAGE_URL "https://subproj.example.com")
   message("CMAKE_PROJECT_HOMEPAGE_URL = ${CMAKE_PROJECT_HOMEPAGE_URL}")
 
 The most recently seen :command:`project` command from the top level
 CMakeLists.txt would be ``project(Second ...)``, so this will print::
 
-  CMAKE_PROJECT_HOMEPAGE_URL = http://second.example.com
+  CMAKE_PROJECT_HOMEPAGE_URL = https://second.example.com
 
 To obtain the homepage URL from the most recent call to :command:`project` in
 the current directory scope or above, see the :variable:`PROJECT_HOMEPAGE_URL`
diff --git a/Help/variable/CTEST_COVERAGE_COMMAND.rst b/Help/variable/CTEST_COVERAGE_COMMAND.rst
index f5425cb..3df2262 100644
--- a/Help/variable/CTEST_COVERAGE_COMMAND.rst
+++ b/Help/variable/CTEST_COVERAGE_COMMAND.rst
@@ -59,4 +59,4 @@
 ``/src/main/java`` directories of each module within the source tree. These
 directories are needed and should not be forgotten.
 
-.. _`Cobertura`: http://cobertura.github.io/cobertura/
+.. _`Cobertura`: https://cobertura.github.io/cobertura/
diff --git a/Modules/CMakeASM_MARMASMInformation.cmake b/Modules/CMakeASM_MARMASMInformation.cmake
index 2026c17..a47f7c2 100644
--- a/Modules/CMakeASM_MARMASMInformation.cmake
+++ b/Modules/CMakeASM_MARMASMInformation.cmake
@@ -8,7 +8,7 @@
 
 set(CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS asm)
 
-set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> <SOURCE>")
+set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <INCLUDES> <FLAGS> -o <OBJECT> <SOURCE>")
 
 # The ASM_MARMASM compiler id for this compiler is "MSVC", so fill out the runtime library table.
 set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded         "")
diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake
index d55c4ca..b77f650 100644
--- a/Modules/GetPrerequisites.cmake
+++ b/Modules/GetPrerequisites.cmake
@@ -748,7 +748,7 @@
     set(gp_regex_cmp_count 1)
   elseif(gp_tool MATCHES "objdump(\\.exe)?$")
     set(gp_cmd_args "-p")
-    set(gp_regex "^\t*DLL Name: (.*\\.[Dd][Ll][Ll])${eol_char}$")
+    set(gp_regex "^[\t ]*DLL Name: (.*\\.[Dd][Ll][Ll])${eol_char}$")
     set(gp_regex_error "")
     set(gp_regex_fallback "")
     set(gp_regex_cmp_count 1)
diff --git a/README.rst b/README.rst
index d885740..6ada17f 100644
--- a/README.rst
+++ b/README.rst
@@ -16,7 +16,7 @@
 CMake is maintained and supported by `Kitware`_ and developed in
 collaboration with a productive community of contributors.
 
-.. _`Kitware`: http://www.kitware.com/cmake
+.. _`Kitware`: https://www.kitware.com/cmake
 
 License
 =======
@@ -106,7 +106,7 @@
 "man" builder.  Add ``-DSPHINX_EXECUTABLE=/path/to/sphinx-build`` if the
 tool is not found automatically.
 
-.. _`Sphinx`: http://sphinx-doc.org
+.. _`Sphinx`: https://sphinx-doc.org
 
 Reporting Bugs
 ==============
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index 61a18a2..9184c4a 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -347,6 +347,8 @@
   this->ExcludeFixtureCleanupRegExp.clear();
   this->TestListFile.clear();
   this->ExcludeTestListFile.clear();
+  this->TestsToRunByName.reset();
+  this->TestsToExcludeByName.reset();
 
   this->TestsToRunString.clear();
   this->UseUnion = false;
@@ -956,16 +958,16 @@
       }
     }
 
-    if (!this->TestsToRunByName.empty()) {
-      if (this->TestsToRunByName.find(tp.Name) ==
-          this->TestsToRunByName.end()) {
+    if (this->TestsToRunByName) {
+      if (this->TestsToRunByName->find(tp.Name) ==
+          this->TestsToRunByName->end()) {
         continue;
       }
     }
 
-    if (!this->TestsToExcludeByName.empty()) {
-      if (this->TestsToExcludeByName.find(tp.Name) !=
-          this->TestsToExcludeByName.end()) {
+    if (this->TestsToExcludeByName) {
+      if (this->TestsToExcludeByName->find(tp.Name) !=
+          this->TestsToExcludeByName->end()) {
         continue;
       }
     }
@@ -1857,10 +1859,16 @@
 
   if (!this->TestListFile.empty()) {
     this->TestsToRunByName = this->ReadTestListFile(this->TestListFile);
+    if (!this->TestsToRunByName) {
+      return false;
+    }
   }
   if (!this->ExcludeTestListFile.empty()) {
     this->TestsToExcludeByName =
       this->ReadTestListFile(this->ExcludeTestListFile);
+    if (!this->TestsToExcludeByName) {
+      return false;
+    }
   }
 
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
@@ -2031,32 +2039,27 @@
   }
 }
 
-std::set<std::string> cmCTestTestHandler::ReadTestListFile(
-  const std::string& testListFileName) const
+cm::optional<std::set<std::string>> cmCTestTestHandler::ReadTestListFile(
+  std::string const& testListFileName) const
 {
-  std::set<std::string> testNames;
-
+  cm::optional<std::set<std::string>> result;
   cmsys::ifstream ifs(testListFileName.c_str());
   if (ifs) {
+    std::set<std::string> testNames;
     std::string line;
     while (cmSystemTools::GetLineFromStream(ifs, line)) {
-      std::string trimmed = cmTrimWhitespace(line);
-      if (trimmed.empty() || (trimmed[0] == '#')) {
-        continue;
+      if (!line.empty()) {
+        testNames.insert(line);
       }
-
-      testNames.insert(trimmed);
     }
-    ifs.close();
-  } else if (!this->CTest->GetShowOnly() &&
-             !this->CTest->ShouldPrintLabels()) {
+    result = std::move(testNames);
+  } else {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
                "Problem reading test list file: "
                  << testListFileName
                  << " while generating list of tests to run." << std::endl);
   }
-
-  return testNames;
+  return result;
 }
 
 void cmCTestTestHandler::RecordCustomTestMeasurements(cmXMLWriter& xml,
diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h
index 84e6098..6932800 100644
--- a/Source/CTest/cmCTestTestHandler.h
+++ b/Source/CTest/cmCTestTestHandler.h
@@ -341,8 +341,8 @@
   std::string GetTestStatus(cmCTestTestResult const&);
   void ExpandTestsToRunInformation(size_t numPossibleTests);
   void ExpandTestsToRunInformationForRerunFailed();
-  std::set<std::string> ReadTestListFile(
-    const std::string& testListFileName) const;
+  cm::optional<std::set<std::string>> ReadTestListFile(
+    std::string const& testListFileName) const;
 
   std::vector<std::string> CustomPreTest;
   std::vector<std::string> CustomPostTest;
@@ -363,8 +363,8 @@
   cmsys::RegularExpression ExcludeTestsRegularExpression;
   std::string TestListFile;
   std::string ExcludeTestListFile;
-  std::set<std::string> TestsToRunByName;
-  std::set<std::string> TestsToExcludeByName;
+  cm::optional<std::set<std::string>> TestsToRunByName;
+  cm::optional<std::set<std::string>> TestsToExcludeByName;
 
   std::string ResourceSpecFile;
 
diff --git a/Source/cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.cxx b/Source/cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.cxx
index d95da95..d54aa7d 100644
--- a/Source/cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.cxx
+++ b/Source/cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.cxx
@@ -44,7 +44,7 @@
 
   std::string line;
   static const cmsys::RegularExpression regex(
-    "^\t*DLL Name: ([^\n]*\\.[Dd][Ll][Ll])$");
+    "^[\t ]*DLL Name: ([^\n]*\\.[Dd][Ll][Ll])$");
   cmUVPipeIStream output(process.GetLoop(), process.OutputStream());
   while (cmSystemTools::GetLineFromStream(output, line)) {
     cmsys::RegularExpressionMatch match;
diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
index 724c5e4..a9f392b 100644
--- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
@@ -208,8 +208,8 @@
 run_SkipRegexFoundTest()
 
 
-function(run_TestsFromFileTest arg)
-  set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TestsFromFile)
+function(run_TestsFromFileTest case)
+  set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TestsFromFile-${case})
   set(RunCMake_TEST_NO_CLEAN 1)
   file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
   file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
@@ -219,10 +219,14 @@
 add_test(Test2 \"${CMAKE_COMMAND}\" -E echo \"test2\")
 add_test(Test11 \"${CMAKE_COMMAND}\" -E echo \"test11\")
 ")
-  run_cmake_command(TestsFromFile-${arg} ${CMAKE_CTEST_COMMAND} --${arg} ${RunCMake_SOURCE_DIR}/TestsFromFile-TestList.txt )
+  run_cmake_command(TestsFromFile-${case} ${CMAKE_CTEST_COMMAND} ${ARGN})
 endfunction()
-run_TestsFromFileTest(tests-from-file)
-run_TestsFromFileTest(exclude-from-file)
+run_TestsFromFileTest(include --tests-from-file ${RunCMake_SOURCE_DIR}/TestsFromFile-TestList.txt)
+run_TestsFromFileTest(exclude --exclude-from-file ${RunCMake_SOURCE_DIR}/TestsFromFile-TestList.txt)
+run_TestsFromFileTest(include-empty --tests-from-file ${RunCMake_SOURCE_DIR}/TestsFromFile-TestList-empty.txt)
+run_TestsFromFileTest(exclude-empty --exclude-from-file ${RunCMake_SOURCE_DIR}/TestsFromFile-TestList-empty.txt)
+run_TestsFromFileTest(include-missing --tests-from-file ${RunCMake_SOURCE_DIR}/TestsFromFile-TestList-missing.txt)
+run_TestsFromFileTest(exclude-missing --exclude-from-file ${RunCMake_SOURCE_DIR}/TestsFromFile-TestList-missing.txt)
 
 
 function(run_SerialFailed)
diff --git a/Tests/RunCMake/CTestCommandLine/TestsFromFile-TestList-empty.txt b/Tests/RunCMake/CTestCommandLine/TestsFromFile-TestList-empty.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/TestsFromFile-TestList-empty.txt
diff --git a/Tests/RunCMake/CTestCommandLine/TestsFromFile-TestList.txt b/Tests/RunCMake/CTestCommandLine/TestsFromFile-TestList.txt
index 91f6504..975a21c 100644
--- a/Tests/RunCMake/CTestCommandLine/TestsFromFile-TestList.txt
+++ b/Tests/RunCMake/CTestCommandLine/TestsFromFile-TestList.txt
@@ -1,2 +1,5 @@
 Test1
+
+est
+  Test11
 # Test11
diff --git a/Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude-empty-stdout.txt b/Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude-empty-stdout.txt
new file mode 100644
index 0000000..64a5473
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude-empty-stdout.txt
@@ -0,0 +1,10 @@
+Test project [^
+]*/Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude-empty
+ +Start 1: Test1
+1/3 Test #1: Test1 ............................   Passed +[0-9.]+ sec
+ +Start 2: Test2
+2/3 Test #2: Test2 ............................   Passed +[0-9.]+ sec
+ +Start 3: Test11
+3/3 Test #3: Test11 ...........................   Passed +[0-9.]+ sec
++
+100% tests passed, 0 tests failed out of 3
diff --git a/Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude-missing-result.txt b/Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude-missing-result.txt
new file mode 100644
index 0000000..d197c91
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude-missing-result.txt
@@ -0,0 +1 @@
+[^0]
diff --git a/Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude-missing-stderr.txt b/Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude-missing-stderr.txt
new file mode 100644
index 0000000..1d22abc
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude-missing-stderr.txt
@@ -0,0 +1,2 @@
+Problem reading test list file: [^
+]*/Tests/RunCMake/CTestCommandLine/TestsFromFile-TestList-missing\.txt while generating list of tests to run\.
diff --git a/Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude-missing-stdout.txt b/Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude-missing-stdout.txt
new file mode 100644
index 0000000..2448284
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude-missing-stdout.txt
@@ -0,0 +1,2 @@
+Test project [^
+]*/Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude-missing$
diff --git a/Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude-from-file-stdout.txt b/Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude-stdout.txt
similarity index 75%
rename from Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude-from-file-stdout.txt
rename to Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude-stdout.txt
index 96d8c3b..6db9b50 100644
--- a/Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude-from-file-stdout.txt
+++ b/Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude-stdout.txt
@@ -1,3 +1,5 @@
+Test project [^
+]*/Tests/RunCMake/CTestCommandLine/TestsFromFile-exclude
  +Start 2: Test2
 1/2 Test #2: Test2 ............................   Passed +[0-9.]+ sec
  +Start 3: Test11
diff --git a/Tests/RunCMake/CTestCommandLine/TestsFromFile-include-empty-stderr.txt b/Tests/RunCMake/CTestCommandLine/TestsFromFile-include-empty-stderr.txt
new file mode 100644
index 0000000..a7c4b11
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/TestsFromFile-include-empty-stderr.txt
@@ -0,0 +1 @@
+^No tests were found!!!$
diff --git a/Tests/RunCMake/CTestCommandLine/TestsFromFile-include-missing-result.txt b/Tests/RunCMake/CTestCommandLine/TestsFromFile-include-missing-result.txt
new file mode 100644
index 0000000..d197c91
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/TestsFromFile-include-missing-result.txt
@@ -0,0 +1 @@
+[^0]
diff --git a/Tests/RunCMake/CTestCommandLine/TestsFromFile-include-missing-stderr.txt b/Tests/RunCMake/CTestCommandLine/TestsFromFile-include-missing-stderr.txt
new file mode 100644
index 0000000..1d22abc
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/TestsFromFile-include-missing-stderr.txt
@@ -0,0 +1,2 @@
+Problem reading test list file: [^
+]*/Tests/RunCMake/CTestCommandLine/TestsFromFile-TestList-missing\.txt while generating list of tests to run\.
diff --git a/Tests/RunCMake/CTestCommandLine/TestsFromFile-include-missing-stdout.txt b/Tests/RunCMake/CTestCommandLine/TestsFromFile-include-missing-stdout.txt
new file mode 100644
index 0000000..1f87a44
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/TestsFromFile-include-missing-stdout.txt
@@ -0,0 +1,2 @@
+Test project [^
+]*/Tests/RunCMake/CTestCommandLine/TestsFromFile-include-missing$
diff --git a/Tests/RunCMake/CTestCommandLine/TestsFromFile-tests-from-file-stdout.txt b/Tests/RunCMake/CTestCommandLine/TestsFromFile-include-stdout.txt
similarity index 64%
rename from Tests/RunCMake/CTestCommandLine/TestsFromFile-tests-from-file-stdout.txt
rename to Tests/RunCMake/CTestCommandLine/TestsFromFile-include-stdout.txt
index 653d56c..d07400d 100644
--- a/Tests/RunCMake/CTestCommandLine/TestsFromFile-tests-from-file-stdout.txt
+++ b/Tests/RunCMake/CTestCommandLine/TestsFromFile-include-stdout.txt
@@ -1,3 +1,5 @@
+Test project [^
+]*/Tests/RunCMake/CTestCommandLine/TestsFromFile-include
  +Start 1: Test1
 1/1 Test #1: Test1 ............................   Passed +[0-9.]+ sec
 +
diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
index c2c00d2..14829a1 100644
--- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
@@ -220,6 +220,7 @@
   unset(RunCMake_CXXModules_NO_TEST)
   run_cxx_module_test(same-src-name)
   run_cxx_module_test(scan_properties)
+  run_cxx_module_test(target-objects)
 endif ()
 
 # Tests which require compile commands support.
diff --git a/Tests/RunCMake/CXXModules/examples/target-objects/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/target-objects/CMakeLists.txt
new file mode 100644
index 0000000..4f2f4a2
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/target-objects/CMakeLists.txt
@@ -0,0 +1,22 @@
+cmake_minimum_required(VERSION 3.28)
+project(cxx_modules_target_objects CXX)
+
+include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
+
+add_library(target_objects)
+target_sources(target_objects
+  PRIVATE
+    FILE_SET CXX_MODULES
+      BASE_DIRS
+        "${CMAKE_CURRENT_SOURCE_DIR}"
+      FILES
+        importable.cxx)
+target_compile_features(target_objects PRIVATE cxx_std_20)
+
+add_executable(main)
+target_sources(main
+  PRIVATE
+    main.cxx
+    "$<TARGET_OBJECTS:target_objects>")
+
+add_test(NAME main COMMAND main)
diff --git a/Tests/RunCMake/CXXModules/examples/target-objects/importable.cxx b/Tests/RunCMake/CXXModules/examples/target-objects/importable.cxx
new file mode 100644
index 0000000..1aee1a6
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/target-objects/importable.cxx
@@ -0,0 +1,13 @@
+export module importable;
+
+export int from_import()
+{
+  return 0;
+}
+
+extern "C++" {
+int f()
+{
+  return from_import();
+}
+}
diff --git a/Tests/RunCMake/CXXModules/examples/target-objects/main.cxx b/Tests/RunCMake/CXXModules/examples/target-objects/main.cxx
new file mode 100644
index 0000000..a652ccf
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/target-objects/main.cxx
@@ -0,0 +1,6 @@
+int f();
+
+int main(int argc, char* argv[])
+{
+  return f();
+}
diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
index ee7114b..3c9a80d 100644
--- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
@@ -221,18 +221,22 @@
 
 
 # test include/exclude tests from file
-function(run_tests_from_file mode)
-  set(CASE_CTEST_TEST_ARGS ${mode} ${RunCMake_SOURCE_DIR}/TestsFromFile-TestList.txt)
+function(run_tests_from_file case)
+  set(CASE_CTEST_TEST_ARGS ${ARGN})
   set(CASE_CMAKELISTS_SUFFIX_CODE [[
 add_test(NAME Test1 COMMAND ${CMAKE_COMMAND} -E true)
 add_test(NAME Test2 COMMAND ${CMAKE_COMMAND} -E true)
 add_test(NAME Test11 COMMAND ${CMAKE_COMMAND} -E true)
   ]])
 
-  run_ctest(TestsFromFile-${mode})
+  run_ctest(TestsFromFile-${case})
 endfunction()
-run_tests_from_file(INCLUDE_FROM_FILE)
-run_tests_from_file(EXCLUDE_FROM_FILE)
+run_tests_from_file(include INCLUDE_FROM_FILE ${RunCMake_SOURCE_DIR}/TestsFromFile-TestList.txt)
+run_tests_from_file(exclude EXCLUDE_FROM_FILE ${RunCMake_SOURCE_DIR}/TestsFromFile-TestList.txt)
+run_tests_from_file(include-empty INCLUDE_FROM_FILE ${RunCMake_SOURCE_DIR}/TestsFromFile-TestList-empty.txt)
+run_tests_from_file(exclude-empty EXCLUDE_FROM_FILE ${RunCMake_SOURCE_DIR}/TestsFromFile-TestList-empty.txt)
+run_tests_from_file(include-missing INCLUDE_FROM_FILE ${RunCMake_SOURCE_DIR}/TestsFromFile-TestList-missing.txt)
+run_tests_from_file(exclude-missing EXCLUDE_FROM_FILE ${RunCMake_SOURCE_DIR}/TestsFromFile-TestList-missing.txt)
 
 
 # Make sure environment gets logged
diff --git a/Tests/RunCMake/ctest_test/TestsFromFile-EXCLUDE_FROM_FILE-stdout.txt b/Tests/RunCMake/ctest_test/TestsFromFile-EXCLUDE_FROM_FILE-stdout.txt
deleted file mode 100644
index 29c2b7f..0000000
--- a/Tests/RunCMake/ctest_test/TestsFromFile-EXCLUDE_FROM_FILE-stdout.txt
+++ /dev/null
@@ -1,7 +0,0 @@
- +Start 3: Test2
-2/3 Test #3: Test2 ............................   Passed +[0-9.]+ sec
- +Start 4: Test11
-3/3 Test #4: Test11 ...........................   Passed +[0-9.]+ sec
-+
-100% tests passed, 0 tests failed out of 3
-+
diff --git a/Tests/RunCMake/ctest_test/TestsFromFile-TestList-empty.txt b/Tests/RunCMake/ctest_test/TestsFromFile-TestList-empty.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/ctest_test/TestsFromFile-TestList-empty.txt
diff --git a/Tests/RunCMake/ctest_test/TestsFromFile-TestList.txt b/Tests/RunCMake/ctest_test/TestsFromFile-TestList.txt
index 91f6504..975a21c 100644
--- a/Tests/RunCMake/ctest_test/TestsFromFile-TestList.txt
+++ b/Tests/RunCMake/ctest_test/TestsFromFile-TestList.txt
@@ -1,2 +1,5 @@
 Test1
+
+est
+  Test11
 # Test11
diff --git a/Tests/RunCMake/ctest_test/TestsFromFile-exclude-empty-stdout.txt b/Tests/RunCMake/ctest_test/TestsFromFile-exclude-empty-stdout.txt
new file mode 100644
index 0000000..a0faf57
--- /dev/null
+++ b/Tests/RunCMake/ctest_test/TestsFromFile-exclude-empty-stdout.txt
@@ -0,0 +1,12 @@
+Test project [^
+]*/Tests/RunCMake/ctest_test/TestsFromFile-exclude-empty-build
+ +Start 1: RunCMakeVersion
+1/4 Test #1: RunCMakeVersion ..................   Passed +[0-9.]+ sec
+ +Start 2: Test1
+2/4 Test #2: Test1 ............................   Passed +[0-9.]+ sec
+ +Start 3: Test2
+3/4 Test #3: Test2 ............................   Passed +[0-9.]+ sec
+ +Start 4: Test11
+4/4 Test #4: Test11 ...........................   Passed +[0-9.]+ sec
++
+100% tests passed, 0 tests failed out of 4
diff --git a/Tests/RunCMake/ctest_test/TestsFromFile-exclude-missing-result.txt b/Tests/RunCMake/ctest_test/TestsFromFile-exclude-missing-result.txt
new file mode 100644
index 0000000..b57e2de
--- /dev/null
+++ b/Tests/RunCMake/ctest_test/TestsFromFile-exclude-missing-result.txt
@@ -0,0 +1 @@
+(-1|255)
diff --git a/Tests/RunCMake/ctest_test/TestsFromFile-exclude-missing-stderr.txt b/Tests/RunCMake/ctest_test/TestsFromFile-exclude-missing-stderr.txt
new file mode 100644
index 0000000..a5b3e46
--- /dev/null
+++ b/Tests/RunCMake/ctest_test/TestsFromFile-exclude-missing-stderr.txt
@@ -0,0 +1,2 @@
+Problem reading test list file: [^
+]*/Tests/RunCMake/ctest_test/TestsFromFile-TestList-missing\.txt while generating list of tests to run\.
diff --git a/Tests/RunCMake/ctest_test/TestsFromFile-exclude-missing-stdout.txt b/Tests/RunCMake/ctest_test/TestsFromFile-exclude-missing-stdout.txt
new file mode 100644
index 0000000..ac5a727
--- /dev/null
+++ b/Tests/RunCMake/ctest_test/TestsFromFile-exclude-missing-stdout.txt
@@ -0,0 +1,2 @@
+Test project [^
+]*/Tests/RunCMake/ctest_test/TestsFromFile-exclude-missing-build$
diff --git a/Tests/RunCMake/ctest_test/TestsFromFile-exclude-stdout.txt b/Tests/RunCMake/ctest_test/TestsFromFile-exclude-stdout.txt
new file mode 100644
index 0000000..f401861
--- /dev/null
+++ b/Tests/RunCMake/ctest_test/TestsFromFile-exclude-stdout.txt
@@ -0,0 +1,11 @@
+Test project [^
+]*/Tests/RunCMake/ctest_test/TestsFromFile-exclude-build
+ +Start 1: RunCMakeVersion
+1/3 Test #1: RunCMakeVersion ..................   Passed +[0-9.]+ sec
+ +Start 3: Test2
+2/3 Test #3: Test2 ............................   Passed +[0-9.]+ sec
+ +Start 4: Test11
+3/3 Test #4: Test11 ...........................   Passed +[0-9.]+ sec
++
+100% tests passed, 0 tests failed out of 3
++
diff --git a/Tests/RunCMake/ctest_test/TestsFromFile-include-empty-result.txt b/Tests/RunCMake/ctest_test/TestsFromFile-include-empty-result.txt
new file mode 100644
index 0000000..b57e2de
--- /dev/null
+++ b/Tests/RunCMake/ctest_test/TestsFromFile-include-empty-result.txt
@@ -0,0 +1 @@
+(-1|255)
diff --git a/Tests/RunCMake/ctest_test/TestsFromFile-include-empty-stderr.txt b/Tests/RunCMake/ctest_test/TestsFromFile-include-empty-stderr.txt
new file mode 100644
index 0000000..a7c4b11
--- /dev/null
+++ b/Tests/RunCMake/ctest_test/TestsFromFile-include-empty-stderr.txt
@@ -0,0 +1 @@
+^No tests were found!!!$
diff --git a/Tests/RunCMake/ctest_test/TestsFromFile-include-missing-result.txt b/Tests/RunCMake/ctest_test/TestsFromFile-include-missing-result.txt
new file mode 100644
index 0000000..b57e2de
--- /dev/null
+++ b/Tests/RunCMake/ctest_test/TestsFromFile-include-missing-result.txt
@@ -0,0 +1 @@
+(-1|255)
diff --git a/Tests/RunCMake/ctest_test/TestsFromFile-include-missing-stderr.txt b/Tests/RunCMake/ctest_test/TestsFromFile-include-missing-stderr.txt
new file mode 100644
index 0000000..a5b3e46
--- /dev/null
+++ b/Tests/RunCMake/ctest_test/TestsFromFile-include-missing-stderr.txt
@@ -0,0 +1,2 @@
+Problem reading test list file: [^
+]*/Tests/RunCMake/ctest_test/TestsFromFile-TestList-missing\.txt while generating list of tests to run\.
diff --git a/Tests/RunCMake/ctest_test/TestsFromFile-include-missing-stdout.txt b/Tests/RunCMake/ctest_test/TestsFromFile-include-missing-stdout.txt
new file mode 100644
index 0000000..4a9447c
--- /dev/null
+++ b/Tests/RunCMake/ctest_test/TestsFromFile-include-missing-stdout.txt
@@ -0,0 +1,2 @@
+Test project [^
+]*/Tests/RunCMake/ctest_test/TestsFromFile-include-missing-build$
diff --git a/Tests/RunCMake/ctest_test/TestsFromFile-INCLUDE_FROM_FILE-stdout.txt b/Tests/RunCMake/ctest_test/TestsFromFile-include-stdout.txt
similarity index 64%
rename from Tests/RunCMake/ctest_test/TestsFromFile-INCLUDE_FROM_FILE-stdout.txt
rename to Tests/RunCMake/ctest_test/TestsFromFile-include-stdout.txt
index e3ca719..8e7093b 100644
--- a/Tests/RunCMake/ctest_test/TestsFromFile-INCLUDE_FROM_FILE-stdout.txt
+++ b/Tests/RunCMake/ctest_test/TestsFromFile-include-stdout.txt
@@ -1,3 +1,5 @@
+Test project [^
+]*/Tests/RunCMake/ctest_test/TestsFromFile-include-build
  +Start 2: Test1
 1/1 Test #2: Test1 ............................   Passed +[0-9.]+ sec
 +