test: HostFlatpak asks about projects in a directory of its own
In the Flatpak, HostFlatpak makes two projects in the sandbox's /tmp, one there and one through a link in the fixture's build/ that leads there, and asks whether the host sees them. They had fixed names, /tmp/crafter-build-host-flatpak and crafter-build-host-flatpak-linked beside it, and every sandbox of the app has the same /tmp, so two runs at once asked about, and removed, the same projects. Both are now in a directory the test makes there, a PrivateDirectory, which the link leads to, and which goes afterwards with the link, or, when the test is killed, when a later one is made, once it has not changed for a minute. The test still names /tmp rather than the TMPDIR it is given, since the sandbox's /tmp is what it asks the host about, and AGENTS.template.md's entry for it says it makes a directory of its own there now.
This commit is contained in:
parent
ab8935826d
commit
0602e282b2
2 changed files with 12 additions and 3 deletions
|
|
@ -79,11 +79,18 @@ int main() {
|
|||
}
|
||||
at = info.find("filesystems=", at + 1);
|
||||
}
|
||||
// Both in a directory of this run's own there, a PrivateDirectory,
|
||||
// removed at the end of this block: every sandbox of the app has the
|
||||
// same /tmp, so two runs at once would ask about, and remove, the
|
||||
// same projects, and what a run that is killed leaves goes when a
|
||||
// later one is made, once it has not changed for a minute.
|
||||
const PrivateDirectory own("/tmp", "crafter-build-host-flatpak-");
|
||||
const fs::path& scratch = own.path;
|
||||
const fs::path link = fixture / "build" / "to-tmp";
|
||||
fs::create_directories(link.parent_path(), ec);
|
||||
fs::remove(link, ec);
|
||||
fs::create_directory_symlink("/tmp", link, ec);
|
||||
const std::array<fs::path, 2> unseen = {"/tmp/crafter-build-host-flatpak", link / "crafter-build-host-flatpak-linked"};
|
||||
fs::create_directory_symlink(scratch, link, ec);
|
||||
const std::array<fs::path, 2> unseen = {scratch / "project", link / "linked"};
|
||||
for (const fs::path& project : unseen) {
|
||||
if (tmpShared) {
|
||||
std::println("an override shares the host's /tmp with the sandbox, so the host sees {}: left out", project.string());
|
||||
|
|
@ -100,6 +107,8 @@ int main() {
|
|||
Check(fs::is_empty(project, ec), std::format("and asking leaves nothing in {}", project.string()));
|
||||
fs::remove_all(fs::weakly_canonical(project, ec), ec);
|
||||
}
|
||||
// The link goes with the directory it leads to.
|
||||
fs::remove(link, ec);
|
||||
// From a working directory only the sandbox has, the host is reached
|
||||
// all the same, and sees the fixture.
|
||||
if (permitted) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue