Browse Source

delete txt and add TestData.kt

xmakeVersion and xmakeFHelp is got from local xmake
Seedking 1 year ago
parent
commit
7805a32122

+ 44 - 0
src/test/kotlin/io/xmake/TestData.kt

@@ -0,0 +1,44 @@
+package io.xmake
+
+import java.io.BufferedReader
+import java.io.File
+import java.io.IOException
+import java.io.InputStreamReader
+
+object TestData {
+    // get from local xmake
+    val xmakeVersion: String = testIORunv(listOf("xmake", "--version"))
+    val xmakeFHelp: String= testIORunv(listOf("xmake", "f", "-h"))
+
+    private fun testIORunv(argv: List<String>, workDir: String? = null): String {
+        var result = ""
+        var bufferReader: BufferedReader? = null
+        try {
+            val processBuilder = ProcessBuilder(argv)
+            if (workDir !== null) {
+                processBuilder.directory(File(workDir))
+            }
+            processBuilder.environment().put("COLORTERM", "nocolor")
+            val process = processBuilder.start()
+            bufferReader = BufferedReader(InputStreamReader(process.getInputStream()))
+            var line: String? = bufferReader.readLine()
+            while (line != null) {
+                result += line + "\n"
+                line = bufferReader.readLine()
+            }
+            if (process.waitFor() != 0)
+                result = ""
+        } catch (e: IOException) {
+            e.printStackTrace()
+        } finally {
+            if (bufferReader != null) {
+                try {
+                    bufferReader.close()
+                } catch (e: Exception) {
+                    e.printStackTrace()
+                }
+            }
+        }
+        return result
+    }
+}

+ 3 - 4
src/test/kotlin/io/xmake/utils/interact/InteractTest.kt

@@ -2,10 +2,9 @@ package io.xmake.utils.interact
 
 import com.intellij.testFramework.fixtures.BasePlatformTestCase
 import io.mockk.every
-import io.mockk.impl.annotations.MockK
 import io.mockk.junit4.MockKRule
-import io.mockk.mockk
 import io.mockk.mockkStatic
+import io.xmake.TestData
 import io.xmake.utils.ioRunv
 import org.junit.Before
 import org.junit.Rule
@@ -15,7 +14,7 @@ import org.junit.runners.JUnit4
 
 @RunWith(JUnit4::class)
 class XMakeVersion:BasePlatformTestCase(){
-    val xmakeVersion = this::class.java.classLoader.getResource("utils/xmake --version.txt").readText()
+    val xmakeVersion = TestData.xmakeVersion
 
     @get:Rule
     val mockkRule = MockKRule(this)
@@ -44,7 +43,7 @@ class XMakeVersion:BasePlatformTestCase(){
 
 @RunWith(JUnit4::class)
 class XMakeFH:BasePlatformTestCase() {
-    val xmakeFHelp = this::class.java.classLoader.getResource("utils/xmake f -h.txt").readText()
+    val xmakeFHelp = TestData.xmakeFHelp
 
     @get:Rule
     val mockkRule = MockKRule(this)

+ 0 - 11
src/test/resources/utils/xmake --version.txt

@@ -1,11 +0,0 @@
-xmake v2.8.6+HEAD.211710b67, A cross-platform build utility based on Lua
-Copyright (C) 2015-present Ruki Wang, tboox.org, xmake.io
-                         _
-    __  ___ __  __  __ _| | ______
-    \ \/ / |  \/  |/ _  | |/ / __ \
-     >  <  | \__/ | /_| |   <  ___/
-    /_/\_\_|_|  |_|\__ \|_|\_\____|
-                         by ruki, xmake.io
-
-    👉  Manual: https://xmake.io/#/getting_started
-    🙏  Donate: https://xmake.io/#/sponsor

+ 0 - 262
src/test/resources/utils/xmake f -h.txt

@@ -1,262 +0,0 @@
-xmake v2.8.6+HEAD.211710b67, A cross-platform build utility based on Lua
-Copyright (C) 2015-present Ruki Wang, tboox.org, xmake.io
-                         _
-    __  ___ __  __  __ _| | ______
-    \ \/ / |  \/  |/ _  | |/ / __ \
-     >  <  | \__/ | /_| |   <  ___/
-    /_/\_\_|_|  |_|\__ \|_|\_\____|
-                         by ruki, xmake.io
-
-    👉  Manual: https://xmake.io/#/getting_started
-    🙏  Donate: https://xmake.io/#/sponsor
-
-
-Usage: $xmake config|f [options] [target]
-
-Configure the project.
-
-Common options:
-    -q, --quiet                            Quiet operation.
-    -y, --yes                              Input yes by default if need user confirm.
-        --confirm=CONFIRM                  Input the given result if need user confirm.
-                                               - yes
-                                               - no
-                                               - def
-    -v, --verbose                          Print lots of verbose information for users.
-        --root                             Allow to run xmake as root.
-    -D, --diagnosis                        Print lots of diagnosis information (backtrace, check info ..) only for developers.
-                                           And we can append -v to get more whole information.
-                                               e.g. $ xmake -vD
-        --version                          Print the version number and exit.
-    -h, --help                             Print this help message and exit.
-
-    -F FILE, --file=FILE                   Read a given xmake.lua file.
-    -P PROJECT, --project=PROJECT          Change to the given project directory.
-                                           Search priority:
-                                               1. The Given Command Argument
-                                               2. The Envirnoment Variable: XMAKE_PROJECT_DIR
-                                               3. The Current Directory
-
-Command options (config):
-    -c, --clean                            Clean the cached user configs and detection cache.
-        --check                            Just ignore detection cache and force to check all, it will reserve the cached user configs.
-        --export=EXPORT                    Export the current configuration to the given file.
-                                               e.g.
-                                               - xmake f -m debug -xxx=y --export=build/config.txt
-        --import=IMPORT                    Import configs from the given file.
-                                               e.g.
-                                               - xmake f -import=build/config.txt
-        --menu                             Configure project with a menu-driven user interface.
-
-    -p PLAT, --plat=PLAT                   Compile for the given platform. (default: auto)
-                                               - android
-                                               - appletvos
-                                               - applexros
-                                               - bsd
-                                               - cross
-                                               - cygwin
-                                               - haiku
-                                               - iphoneos
-                                               - linux
-                                               - macosx
-                                               - mingw
-                                               - msys
-                                               - wasm
-                                               - watchos
-                                               - windows
-    -a ARCH, --arch=ARCH                   Compile for the given architecture. (default: auto)
-                                               - android: armeabi armeabi-v7a arm64-v8a x86 x86_64 mips mip64
-                                               - appletvos: arm64 armv7 armv7s i386 x86_64
-                                               - applexros: arm64 armv7 armv7s i386 x86_64
-                                               - bsd: i386 x86_64
-                                               - cross: i386 x86_64 arm arm64 mips mips64 riscv riscv64 s390x ppc ppc64 sh4
-                                               - cygwin: i386 x86_64
-                                               - haiku: i386 x86_64
-                                               - iphoneos: arm64 x86_64
-                                               - linux: i386 x86_64 armv7 armv7s arm64-v8a mips mips64 mipsel mips64el loongarch64
-                                               - macosx: x86_64 arm64
-                                               - mingw: i386 x86_64 arm arm64
-                                               - msys: i386 x86_64
-                                               - wasm: wasm32 wasm64
-                                               - watchos: armv7k i386
-                                               - windows: x86 x64 arm64
-    -m MODE, --mode=MODE                   Compile for the given mode. (default: auto)
-                                               - debug
-                                               - release
-    -k KIND, --kind=KIND                   Compile for the given target kind. (default: static)
-                                               - static
-                                               - shared
-                                               - binary
-        --host=HOST                        Set the current host environment. (default: windows)
-        --policies=POLICIES                Set the project policies.
-                                               e.g.
-                                               - xmake f --policies=package.fetch_only
-                                               - xmake f --policies=package.precompiled:n,package.install_only
-
-Command options (Package Configuration):
-        --require=REQUIRE                  Require all dependent packages?
-                                               - yes
-                                               - no
-        --pkg_searchdirs=PKG_SEARCHDIRS    The search directories of the remote package.
-                                               e.g.
-                                               - xmake f --pkg_searchdirs=/dir1;/dir2
-
-Command options (Cross Complation Configuration):
-        --cross=CROSS                      Set cross toolchains prefix
-                                           e.g.
-                                               - i386-mingw32-
-                                               - arm-linux-androideabi-
-        --target_os=TARGET_OS              Set target os only for cross-complation
-        --bin=BIN                          Set cross toolchains bin directory
-                                           e.g.
-                                               - sdk/bin (/arm-linux-gcc ..)
-        --sdk=SDK                          Set cross SDK directory
-                                           e.g.
-                                               - sdk/bin
-                                               - sdk/lib
-                                               - sdk/include
-        --toolchain=TOOLCHAIN              Set toolchain name
-                                           e.g.
-                                               - xmake f --toolchain=clang
-                                               - xmake f --toolchain=[cross|llvm|sdcc ..] --sdk=/xxx
-                                               - run `xmake show -l toolchains` to get all toolchains
-        --nc=NC                            The Nim Compiler
-        --ncld=NCLD                        The Nim Linker
-        --ncar=NCAR                        The Nim Static Library Archiver
-        --ncsh=NCSH                        The Nim Shared Library Linker
-        --linkdirs=LINKDIRS                The Link Search Directories
-        --rc=RC                            The Rust Compiler
-        --rcld=RCLD                        The Rust Linker
-        --rcar=RCAR                        The Rust Static Library Archiver
-        --rcsh=RCSH                        The Rust Shared Library Linker
-        --cc=CC                            The C Compiler
-        --cxx=CXX                          The C++ Compiler
-        --cpp=CPP                          The C Preprocessor
-        --ld=LD                            The Linker
-        --ar=AR                            The Static Library Linker
-        --sh=SH                            The Shared Library Linker
-        --ranlib=RANLIB                    The Static Library Index Generator
-        --cflags=CFLAGS                    The C Compiler Flags
-        --cxflags=CXFLAGS                  The C/C++ compiler Flags
-        --cxxflags=CXXFLAGS                The C++ Compiler Flags
-        --ldflags=LDFLAGS                  The Binary Linker Flags
-        --arflags=ARFLAGS                  The Static Library Linker Flags
-        --shflags=SHFLAGS                  The Shared Library Linker Flags
-        --links=LINKS                      The Link Libraries
-        --syslinks=SYSLINKS                The System Link Libraries
-        --includedirs=INCLUDEDIRS          The Include Search Directories
-        --frameworks=FRAMEWORKS            The Frameworks
-        --frameworkdirs=FRAMEWORKDIRS      The Frameworks Search Directories
-        --cu=CU                            The Cuda Compiler
-        --cu-ccbin=CU-CCBIN                The Cuda Host C++ Compiler
-        --culd=CULD                        The Cuda Linker
-        --cuflags=CUFLAGS                  The Cuda Compiler Flags
-        --culdflags=CULDFLAGS              The Cuda Linker Flags
-        --go=GO                            The Golang Compiler
-        --gcld=GCLD                        The Golang Linker
-        --go-ar=GO-AR                      The Golang Static Library Linker
-        --mm=MM                            The Objc Compiler
-        --mxx=MXX                          The Objc++ Compiler
-        --mflags=MFLAGS                    The Objc Compiler Flags
-        --mxflags=MXFLAGS                  The Objc/c++ Compiler Flags
-        --mxxflags=MXXFLAGS                The Objc++ Compiler Flags
-        --mrc=MRC                          The Microsoft Resource Compiler
-        --mrcflags=MRCFLAGS                The Microsoft Resource Flags
-        --zc=ZC                            The Zig Compiler
-        --zcld=ZCLD                        The Zig Linker
-        --zcar=ZCAR                        The Zig Static Library Archiver
-        --zcsh=ZCSH                        The Zig Shared Library Linker
-        --sc=SC                            The Swift Compiler
-        --scld=SCLD                        The Swift Linker
-        --scsh=SCSH                        The Swift Shared Library Linker
-        --dc=DC                            The Dlang Compiler
-        --dcld=DCLD                        The Dlang Linker
-        --dcar=DCAR                        The Dlang Static Library Archiver
-        --dcsh=DCSH                        The Dlang Shared Library Linker
-        --pc=PC                            The Pascal Compiler
-        --pcld=PCLD                        The Pascal Linker
-        --pcsh=PCSH                        The Pascal Shared Library Linker
-        --fc=FC                            The Fortran Compiler
-        --fcld=FCLD                        The Fortran Linker
-        --fcsh=FCSH                        The Fortran Shared Library Linker
-        --as=AS                            The Assembler
-        --asflags=ASFLAGS                  The Assembler Flags
-
-Command options (Android Configuration):
-        --ndk=NDK                          The NDK Directory
-        --ndk_sdkver=NDK_SDKVER            The SDK Version for NDK (default: auto)
-        --android_sdk=ANDROID_SDK          The Android SDK Directory
-        --build_toolver=BUILD_TOOLVER      The Build Tool Version of Android SDK
-        --ndk_stdcxx=[y|n]                 Use stdc++ library for NDK (default: y)
-        --ndk_cxxstl=NDK_CXXSTL            The stdc++ stl library for NDK
-                                               - c++_static
-                                               - c++_shared
-                                               - gnustl_static
-                                               - gnustl_shared
-                                               - stlport_shared
-                                               - stlport_static
-
-Command options (Cuda SDK Configuration):
-        --cuda=CUDA                        The Cuda SDK Directory (default: auto)
-
-Command options (Qt SDK Configuration):
-        --qt=QT                            The Qt SDK Directory (default: auto)
-        --qt_sdkver=QT_SDKVER              The Qt SDK Version (default: auto)
-
-Command options (Vcpkg Configuration):
-        --vcpkg=VCPKG                      The Vcpkg Directory (default: auto)
-
-Command options (MingW Configuration):
-        --mingw=MINGW                      The MingW SDK Directory
-
-Command options (Emscripten Configuration):
-        --emsdk=EMSDK                      The emsdk directory
-
-Command options (Visual Studio SDK Configuration):
-        --vs=VS                            The Microsoft Visual Studio (default: auto)
-                                             e.g. --vs=2017
-        --vs_toolset=VS_TOOLSET            The Microsoft Visual Studio Toolset Version
-                                             e.g. --vs_toolset=14.0
-        --vs_sdkver=VS_SDKVER              The Windows SDK Version of Visual Studio
-                                             e.g. --vs_sdkver=10.0.15063.0
-        --vs_runtime=VS_RUNTIME            The Runtime library of Visual Studio
-                                               - MT
-                                               - MTd
-                                               - MD
-                                               - MDd
-
-Command options (WDK Configuration):
-        --wdk=WDK                          The WDK Directory (default: auto)
-        --wdk_sdkver=WDK_SDKVER            The WDK Version (default: auto)
-        --wdk_winver=WDK_WINVER            The WDK Windows Version (default: auto)
-                                               - win10[|_rs3]
-                                               - win81
-                                               - win8
-                                               - win7[|_sp1|_sp2|_sp3]
-
-Command options (Other Configuration):
-        --debugger=DEBUGGER                Set debugger (default: auto)
-        --ccache=[y|n]                     Enable or disable the c/c++ compiler cache. (default: y)
-        --ccachedir=CCACHEDIR              Set the ccache directory.
-        --trybuild=TRYBUILD                Enable try-build mode and set the third-party buildsystem tool.
-                                           e.g.
-                                               - xmake f --trybuild=auto; xmake
-                                               - xmake f --trybuild=autoconf -p android --ndk=xxx; xmake
-
-                                           the third-party buildsystems:
-                                               - auto
-                                               - make
-                                               - autoconf
-                                               - cmake
-                                               - scons
-                                               - meson
-                                               - bazel
-                                               - ninja
-                                               - msbuild
-                                               - xcodebuild
-                                               - ndkbuild
-                                               - xrepo
-        --tryconfigs=TRYCONFIGS            Set the extra configurations of the third-party buildsystem for the try-build mode.
-                                           e.g.
-                                               - xmake f --trybuild=autoconf --tryconfigs='--enable-shared=no'
-    -o BUILDIR, --buildir=BUILDIR          Set build directory. (default: build)