From cc0f9fd9560de024f013b3bdab4dda304b384b17 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Tue, 6 Mar 2018 09:31:18 -0500 Subject: [PATCH] linux support for ram disk Signed-off-by: Kenneth Reitz --- run-tests.sh | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/run-tests.sh b/run-tests.sh index bfeab3d2..7b1d44ed 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -27,14 +27,32 @@ if [[ ! -z "$CI" ]]; then else # Otherwise, assume MacOS… - # TODO: Improve this for Linux users (e.g. Nick). - echo "Using RAM disk (assuming MacOS)…" - if [[ ! -d "/Volumes/RamDisk" ]]; then - diskutil erasevolume HFS+ 'RAMDisk' $(hdiutil attach -nomount ram://8388608) + OS=$(python -c "import sys; print(sys.platform)") + if [[ OS == "darwin" ]]; then + echo "Using RAM disk (assuming MacOS)…" + + RAM_DISK="/Volumes/RAMDisk" + export RAM_DISK + + if [[ ! -d "$RAM_DISK" ]]; then + echo "Creating RAM Disk ($RAM_DISK)…" + diskutil erasevolume HFS+ 'RAMDisk' $(hdiutil attach -nomount ram://8388608) + fi + + + else + echo "Using RAM disk (assuming Linux)…" + + RAM_DISK="/media/ramdisk" + export RAM_DISK + + if [[ ! -d "$RAM_DISK" ]]; then + echo "Creating RAM Disk ($RAM_DISK)…" + sudo mkdir -p "$RAM_DISK" + sudo mount -t tmpfs -o size=4096M tmpfs "$RAM_DISK" + fi fi - RAM_DISK="/Volumes/RAMDisk" - export RAM_DISK if [[ ! -d "$RAM_DISK/.venv" ]]; then echo "Creating a new venv on RAM Disk…"