[gnome-desktop-testing] Create a .testtmp file
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-desktop-testing] Create a .testtmp file
- Date: Fri, 18 Mar 2016 20:00:57 +0000 (UTC)
commit 35dd4dc068b0d884deead8e5195ea674dae50c0a
Author: Colin Walters <walters verbum org>
Date: Fri Mar 18 15:59:45 2016 -0400
Create a .testtmp file
See https://git.gnome.org/browse/ostree/commit/?id=d25212f04ac824afff9f45e61be3d8e63be174f2
for a chain of events that started this.
Basically it's a convenient way for tests to know they're being run
from a temporary directory.
src/gnome-desktop-testing-runner.c | 24 ++++++++++++++++++++++--
1 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/src/gnome-desktop-testing-runner.c b/src/gnome-desktop-testing-runner.c
index 11fcb26..acff742 100755
--- a/src/gnome-desktop-testing-runner.c
+++ b/src/gnome-desktop-testing-runner.c
@@ -371,8 +371,12 @@ on_test_exited (GObject *obj,
/* Keep around temporaries from failed tests */
if (!(failed && opt_report_directory))
{
- if (!gs_shutil_rm_rf (test->tmpdir, cancellable, error))
- goto out;
+ gs_unref_object GFile *test_tmpdir_stamp = g_file_get_child (test->tmpdir, ".testtmp");
+ if (g_file_query_exists (test_tmpdir_stamp, NULL))
+ {
+ if (!gs_shutil_rm_rf (test->tmpdir, cancellable, error))
+ goto out;
+ }
}
out:
@@ -466,6 +470,22 @@ run_test_async (Test *test,
goto out;
}
+ /* We create a .testtmp stamp file so that tests can *know* for sure
+ * they're in a temporary directory. This is used by at least the
+ * OSTree tests as protection against someone running a test script
+ * outside of the framework, as it might overwrite files in their
+ * source directory, etc.
+ *
+ * Also, when we do the rm -rf, we test for the file to be doubly
+ * sure that we're deleting the right tmpdir.
+ */
+ {
+ gs_unref_object GFile *test_tmpdir_stamp = g_file_get_child (test->tmpdir, ".testtmp");
+
+ if (!g_file_replace_contents (test_tmpdir_stamp, "", 0, NULL, FALSE, 0, NULL, cancellable, error))
+ goto out;
+ }
+
proc_context = gs_subprocess_context_new (test->argv);
gs_subprocess_context_set_cwd (proc_context, test_tmpdir);
gs_subprocess_context_set_environment (proc_context, test->envp);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]