浏览代码

add restart integration test to cargo workspace (#3675)

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
chip 3 年之前
父节点
当前提交
55c8680590

+ 5 - 1
Cargo.toml

@@ -7,8 +7,12 @@ members = [
   "core/tauri-macros",
   "core/tauri-utils",
   "core/tauri-build",
-  "core/tauri-codegen"
+  "core/tauri-codegen",
+  
+  # integration tests
+  "core/tests/restart"
 ]
+
 exclude = [
   # examples that can be compiled with the tauri CLI
   "examples/api/src-tauri",

+ 0 - 0
core/tauri/tests/restart/.license_template → core/tests/restart/.license_template


+ 0 - 0
core/tauri/tests/restart/Cargo.lock → core/tests/restart/Cargo.lock


+ 4 - 2
core/tauri/tests/restart/Cargo.toml → core/tests/restart/Cargo.toml

@@ -1,4 +1,3 @@
-[workspace]
 [package]
 name = "restart"
 version = "0.1.0"
@@ -7,4 +6,7 @@ license = "Apache-2.0 OR MIT"
 edition = "2021"
 
 [dependencies.tauri]
-path = "../.."
+path = "../../tauri"
+
+[dev-dependencies]
+tempfile = "3"

+ 0 - 0
core/tauri/tests/restart/LICENSE.spdx → core/tests/restart/LICENSE.spdx


+ 0 - 0
core/tauri/tests/restart/LICENSE_APACHE-2.0 → core/tests/restart/LICENSE_APACHE-2.0


+ 0 - 0
core/tauri/tests/restart/LICENSE_MIT → core/tests/restart/LICENSE_MIT


+ 5 - 0
core/tests/restart/build.rs

@@ -0,0 +1,5 @@
+// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-License-Identifier: MIT
+
+fn main() {}

+ 0 - 0
core/tauri/tests/restart/src/main.rs → core/tests/restart/src/main.rs


+ 5 - 46
core/tauri/tests/restart.rs → core/tests/restart/tests/restart.rs

@@ -23,57 +23,16 @@ enum Symlink {
   Privilege,
 }
 
-/// Compile the nested restart binary so that we have access to it during the test.
-///
-/// This is compiled inside of this test so that we always have a literal binary file we can use
-/// for some filesystem related tests. Because of how integration tests work, the current working
-/// directory should be the same as the manifest of the crate (not workspace) this integration test
-/// is a part of.
-fn compile_restart_test_binary() -> io::Result<PathBuf> {
-  let project = PathBuf::from("tests").join("restart");
-
-  let mut cargo = Command::new("cargo");
-  cargo.arg("build");
-  cargo.arg("--manifest-path");
-  cargo.arg(project.join("Cargo.toml"));
-
-  // enable the dangerous macos flag on tauri if the test runner has the feature enabled
-  if cfg!(feature = "process-relaunch-dangerous-allow-symlink-macos") {
-    cargo.args([
-      "--features",
-      "tauri/process-relaunch-dangerous-allow-symlink-macos",
-    ]);
-  }
-
-  let status = cargo.status()?;
-  if !status.success() {
-    return Err(io::Error::new(
-      io::ErrorKind::Other,
-      "Unable to compile restart test cargo project inside restart integration test",
-    ));
-  }
-
-  let profile = if cfg!(debug_assertions) {
-    "debug"
-  } else {
-    "release"
-  };
-
-  let bin = if cfg!(windows) {
-    "restart.exe"
-  } else {
-    "restart"
-  };
-
-  Ok(project.join("target").join(profile).join(bin))
-}
-
 /// Compile the test binary, run it, and compare it with expected output.
 ///
 /// Failing to create a symlink due to permissions issues is also a success
 /// for the purpose of this runner.
 fn symlink_runner(create_symlinks: impl Fn(&Path) -> io::Result<Symlink>) -> Result {
-  let compiled_binary = compile_restart_test_binary()?;
+  let mut compiled_binary = PathBuf::from(env!("OUT_DIR")).join("../../../restart");
+  if cfg!(windows) {
+    compiled_binary.set_extension("exe");
+  }
+  println!("{:?}", compiled_binary);
 
   // set up all the temporary file paths
   let temp = tempfile::TempDir::new()?;