Kokoro: Test that the _other.cc files also build

Change-Id: I908b9250de839435c3b355fb89b0bb72ab821a54
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48043
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 506755a..f172afc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -50,6 +50,7 @@
 option(TINT_BUILD_WGSL_WRITER "Build the WGSL output writer" ON)
 option(TINT_BUILD_FUZZERS "Build fuzzers" OFF)
 option(TINT_BUILD_TESTS "Build tests" ${TINT_BUILD_TESTS_DEFAULT})
+option(TINT_BUILD_AS_OTHER_OS "Override OS detection to force building of *_other.cc files" OFF)
 
 option(TINT_ENABLE_MSAN "Enable memory sanitizer" OFF)
 option(TINT_ENABLE_ASAN "Enable address sanitizer" OFF)
@@ -108,6 +109,17 @@
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
 endif()
 
+set(TINT_OS_CC_SUFFIX "other")
+if (NOT TINT_BUILD_AS_OTHER_OS)
+  if(UNIX OR APPLE)
+    set(TINT_OS_CC_SUFFIX "posix")
+    set(TINT_OS_CC_SUFFIX "posix")
+  elseif(WIN32)
+    set(TINT_OS_CC_SUFFIX "windows")
+    set(TINT_OS_CC_SUFFIX "windows")
+  endif()
+endif()
+
 if(${TINT_BUILD_DOCS})
   find_package(Doxygen)
   if(DOXYGEN_FOUND)
diff --git a/kokoro/linux/docker.sh b/kokoro/linux/docker.sh
index 48c842f..3796c9b 100755
--- a/kokoro/linux/docker.sh
+++ b/kokoro/linux/docker.sh
@@ -95,6 +95,11 @@
         ${SRC_DIR}/test/test-all.sh "${BUILD_DIR}/tint"
     hide_cmds
 
+    status "Checking _other.cc files also build"
+    show_cmds
+        cmake ${SRC_DIR} ${CMAKE_FLAGS} ${COMMON_CMAKE_FLAGS} -DTINT_BUILD_AS_OTHER_OS=1
+        make --jobs=$(nproc)
+    hide_cmds
 else
     status "Unsupported build system: $BUILD_SYSTEM"
     exit 1
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3625fdb..bc028a1 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -519,11 +519,13 @@
     type/type_manager_test.cc
     type/u32_type_test.cc
     type/vector_type_test.cc
+    utils/command_${TINT_OS_CC_SUFFIX}.cc
     utils/command_test.cc
     utils/command.h
     utils/get_or_create_test.cc
     utils/hash_test.cc
     utils/math_test.cc
+    utils/tmpfile_${TINT_OS_CC_SUFFIX}.cc
     utils/tmpfile_test.cc
     utils/tmpfile.h
     utils/unique_vector_test.cc
@@ -531,17 +533,6 @@
     writer/float_to_string_test.cc
   )
 
-  if(UNIX OR APPLE)
-    list(APPEND TINT_TEST_SRCS utils/tmpfile_posix.cc)
-    list(APPEND TINT_TEST_SRCS utils/command_posix.cc)
-  elseif(WIN32)
-    list(APPEND TINT_TEST_SRCS utils/command_windows.cc)
-    list(APPEND TINT_TEST_SRCS utils/tmpfile_windows.cc)
-  else()
-    list(APPEND TINT_TEST_SRCS utils/command_other.cc)
-    list(APPEND TINT_TEST_SRCS utils/tmpfile_other.cc)
-  endif()
-
   if(${TINT_BUILD_SPV_READER})
     list(APPEND TINT_TEST_SRCS
       reader/spirv/enum_converter_test.cc