Vagrantfile 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. require 'date'
  2. Vagrant.configure(2) do |config|
  3. # We use Ubuntu instead of Debian because the image comes with two-way
  4. # shared folder support by default.
  5. UBUNTU = 'bento/ubuntu-16.04'
  6. # The main VM is the one used for development and testing.
  7. config.vm.define(:exa, primary: true) do |config|
  8. config.vm.provider :virtualbox do |v|
  9. v.name = 'exa'
  10. v.memory = 2048
  11. v.cpus = 2
  12. end
  13. config.vm.provider :vmware_desktop do |v|
  14. v.vmx['memsize'] = '2048'
  15. v.vmx['numvcpus'] = '2'
  16. end
  17. config.vm.box = UBUNTU
  18. config.vm.hostname = 'exa'
  19. # Make sure we know the VM image’s default user name. The ā€˜cassowary’ user
  20. # (specified later) is used for most of the test *output*, but we still
  21. # need to know where the ā€˜target’ and ā€˜.cargo’ directories go.
  22. developer = 'vagrant'
  23. # Install the dependencies needed for exa to build, as quietly as
  24. # apt can do.
  25. config.vm.provision :shell, privileged: true, inline: <<-EOF
  26. set -xe
  27. apt-get update
  28. apt-get install -qq -o=Dpkg::Use-Pty=0 -y \
  29. git cmake curl attr libgit2-dev zip \
  30. fish zsh bash bash-completion
  31. EOF
  32. # Guarantee that the timezone is UTC -- some of the tests
  33. # depend on this (for now).
  34. config.vm.provision :shell, privileged: true, inline:
  35. %[timedatectl set-timezone UTC]
  36. # Install Rust.
  37. # This is done as vagrant, not root, because it’s vagrant
  38. # who actually uses it. Sent to /dev/null because the progress
  39. # bar produces a ton of output.
  40. config.vm.provision :shell, privileged: false, inline: <<-EOF
  41. if hash rustc &>/dev/null; then
  42. echo "Rust is already installed"
  43. else
  44. set -xe
  45. curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
  46. fi
  47. EOF
  48. # Use a different ā€˜target’ directory on the VM than on the host.
  49. # By default it just uses the one in /vagrant/target, which can
  50. # cause problems if it has different permissions than the other
  51. # directories, or contains object files compiled for the host.
  52. config.vm.provision :shell, privileged: true, inline: <<-EOF
  53. echo 'PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/#{developer}/.cargo/bin"' > /etc/environment
  54. echo 'CARGO_TARGET_DIR="/home/#{developer}/target"' >> /etc/environment
  55. EOF
  56. # Create a variety of misc scripts.
  57. config.vm.provision :shell, privileged: true, inline: <<-EOF
  58. set -xe
  59. ln -sf /vagrant/devtools/dev-run-debug.sh /usr/bin/exa
  60. ln -sf /vagrant/devtools/dev-run-release.sh /usr/bin/rexa
  61. echo -e "#!/bin/sh\ncargo build --manifest-path /vagrant/Cargo.toml \\$@" > /usr/bin/build-exa
  62. ln -sf /usr/bin/build-exa /usr/bin/b
  63. echo -e "#!/bin/sh\ncargo test --manifest-path /vagrant/Cargo.toml --lib \\$@ -- --quiet" > /usr/bin/test-exa
  64. ln -sf /usr/bin/test-exa /usr/bin/t
  65. echo -e "#!/bin/sh\n/vagrant/xtests/run.sh" > /usr/bin/run-xtests
  66. ln -sf /usr/bin/run-xtests /usr/bin/x
  67. echo -e "#!/bin/sh\nbuild-exa && test-exa && run-xtests" > /usr/bin/compile-exa
  68. ln -sf /usr/bin/compile-exa /usr/bin/c
  69. echo -e "#!/bin/sh\nbash /vagrant/devtools/dev-package-for-linux.sh \\$@" > /usr/bin/package-exa
  70. echo -e "#!/bin/sh\ncat /etc/motd" > /usr/bin/halp
  71. chmod +x /usr/bin/{exa,rexa,b,t,x,c,build-exa,test-exa,run-xtests,compile-exa,package-exa,halp}
  72. EOF
  73. # This fix is applied by changing the VM rather than changing the
  74. # Cargo.toml file so it works for everyone because it’s such a niche
  75. # build issue, it’s not worth specifying a non-crates.io dependency
  76. # and losing the ability to `cargo publish` the exa crate there!
  77. # It also isolates the hackiness to the one place I can test it
  78. # actually works.
  79. # Configure the welcoming text that gets shown.
  80. config.vm.provision :shell, privileged: true, inline: <<-EOF
  81. rm -f /etc/update-motd.d/*
  82. # Capture the help text so it gets displayed first
  83. bash /vagrant/devtools/dev-help.sh > /etc/motd
  84. # Tell bash to execute a bunch of stuff when a session starts
  85. echo "source /vagrant/devtools/dev-bash.sh" > /home/#{developer}/.bash_profile
  86. chown #{developer} /home/#{developer}/.bash_profile
  87. # Disable last login date in sshd
  88. sed -i '/PrintLastLog yes/c\PrintLastLog no' /etc/ssh/sshd_config
  89. systemctl restart sshd
  90. EOF
  91. # Link the completion files so they’re ā€œinstalledā€.
  92. config.vm.provision :shell, privileged: true, inline: <<-EOF
  93. set -xe
  94. test -h /etc/bash_completion.d/exa \
  95. || ln -s /vagrant/contrib/completions.bash /etc/bash_completion.d/exa
  96. test -h /usr/share/zsh/vendor-completions/_exa \
  97. || ln -s /vagrant/contrib/completions.zsh /usr/share/zsh/vendor-completions/_exa
  98. test -h /usr/share/fish/completions/exa.fish \
  99. || ln -s /vagrant/contrib/completions.fish /usr/share/fish/completions/exa.fish
  100. EOF
  101. # We create two users that own the test files.
  102. # The first one just owns the ordinary ones, because we don’t want the
  103. # test outputs to depend on ā€œvagrantā€ or ā€œubuntuā€ existing.
  104. user = "cassowary"
  105. config.vm.provision :shell, privileged: true, inline:
  106. %[id -u #{user} &>/dev/null || useradd #{user}]
  107. # The second one has a long name, to test that the file owner column
  108. # widens correctly. The benefit of Vagrant is that we don’t need to
  109. # set this up on the *actual* system!
  110. longuser = "antidisestablishmentarienism"
  111. config.vm.provision :shell, privileged: true, inline:
  112. %[id -u #{longuser} &>/dev/null || useradd #{longuser}]
  113. # Because the timestamps are formatted differently depending on whether
  114. # they’re in the current year or not (see `details.rs`), we have to make
  115. # sure that the files are created in the current year, so they get shown
  116. # in the format we expect.
  117. current_year = Date.today.year
  118. some_date = "#{current_year}01011234.56" # 1st January, 12:34:56
  119. # We also need an UID and a GID that are guaranteed to not exist, to
  120. # test what happen when they don’t.
  121. invalid_uid = 666
  122. invalid_gid = 616
  123. # Delete old testcases if they exist already, then create a
  124. # directory to house new ones.
  125. test_dir = "/testcases"
  126. config.vm.provision :shell, privileged: true, inline: <<-EOF
  127. set -xe
  128. rm -rfv #{test_dir}
  129. mkdir #{test_dir}
  130. chmod 777 #{test_dir}
  131. EOF
  132. # Awkward file size testcases.
  133. # This needs sudo to set the files’ users at the very end.
  134. config.vm.provision :shell, privileged: false, inline: <<-EOF
  135. set -xe
  136. mkdir "#{test_dir}/files"
  137. for i in {1..13}; do
  138. fallocate -l "$i" "#{test_dir}/files/$i"_bytes
  139. fallocate -l "$i"KiB "#{test_dir}/files/$i"_KiB
  140. fallocate -l "$i"MiB "#{test_dir}/files/$i"_MiB
  141. done
  142. touch -t #{some_date} "#{test_dir}/files/"*
  143. chmod 644 "#{test_dir}/files/"*
  144. sudo chown #{user}:#{user} "#{test_dir}/files/"*
  145. EOF
  146. # File name extension testcases.
  147. # These aren’t tested in details view, but we set timestamps on them to
  148. # test that various sort options work.
  149. config.vm.provision :shell, privileged: false, inline: <<-EOF
  150. set -xe
  151. mkdir "#{test_dir}/file-names-exts"
  152. touch "#{test_dir}/file-names-exts/Makefile"
  153. touch "#{test_dir}/file-names-exts/IMAGE.PNG"
  154. touch "#{test_dir}/file-names-exts/image.svg"
  155. touch "#{test_dir}/file-names-exts/VIDEO.AVI"
  156. touch "#{test_dir}/file-names-exts/video.wmv"
  157. touch "#{test_dir}/file-names-exts/music.mp3"
  158. touch "#{test_dir}/file-names-exts/MUSIC.OGG"
  159. touch "#{test_dir}/file-names-exts/lossless.flac"
  160. touch "#{test_dir}/file-names-exts/lossless.wav"
  161. touch "#{test_dir}/file-names-exts/crypto.asc"
  162. touch "#{test_dir}/file-names-exts/crypto.signature"
  163. touch "#{test_dir}/file-names-exts/document.pdf"
  164. touch "#{test_dir}/file-names-exts/DOCUMENT.XLSX"
  165. touch "#{test_dir}/file-names-exts/COMPRESSED.ZIP"
  166. touch "#{test_dir}/file-names-exts/compressed.tar.gz"
  167. touch "#{test_dir}/file-names-exts/compressed.tgz"
  168. touch "#{test_dir}/file-names-exts/compressed.tar.xz"
  169. touch "#{test_dir}/file-names-exts/compressed.txz"
  170. touch "#{test_dir}/file-names-exts/compressed.deb"
  171. touch "#{test_dir}/file-names-exts/backup~"
  172. touch "#{test_dir}/file-names-exts/#SAVEFILE#"
  173. touch "#{test_dir}/file-names-exts/file.tmp"
  174. touch "#{test_dir}/file-names-exts/compiled.class"
  175. touch "#{test_dir}/file-names-exts/compiled.o"
  176. touch "#{test_dir}/file-names-exts/compiled.js"
  177. touch "#{test_dir}/file-names-exts/compiled.coffee"
  178. EOF
  179. # File name testcases.
  180. # bash really doesn’t want you to create a file with escaped characters
  181. # in its name, so we have to resort to the echo builtin and touch!
  182. #
  183. # The double backslashes are not strictly necessary; without them, Ruby
  184. # will interpolate them instead of bash, but because Vagrant prints out
  185. # each command it runs, your *own* terminal will go ā€œdingā€ from the alarm!
  186. config.vm.provision :shell, privileged: false, inline: <<-EOF
  187. set -xe
  188. mkdir "#{test_dir}/file-names"
  189. echo -ne "#{test_dir}/file-names/ascii: hello" | xargs -0 touch
  190. echo -ne "#{test_dir}/file-names/emoji: [šŸ†’]" | xargs -0 touch
  191. echo -ne "#{test_dir}/file-names/utf-8: pâté" | xargs -0 touch
  192. echo -ne "#{test_dir}/file-names/bell: [\\a]" | xargs -0 touch
  193. echo -ne "#{test_dir}/file-names/backspace: [\\b]" | xargs -0 touch
  194. echo -ne "#{test_dir}/file-names/form-feed: [\\f]" | xargs -0 touch
  195. echo -ne "#{test_dir}/file-names/new-line: [\\n]" | xargs -0 touch
  196. echo -ne "#{test_dir}/file-names/return: [\\r]" | xargs -0 touch
  197. echo -ne "#{test_dir}/file-names/tab: [\\t]" | xargs -0 touch
  198. echo -ne "#{test_dir}/file-names/vertical-tab: [\\v]" | xargs -0 touch
  199. echo -ne "#{test_dir}/file-names/escape: [\\033]" | xargs -0 touch
  200. echo -ne "#{test_dir}/file-names/ansi: [\\033[34mblue\\033[0m]" | xargs -0 touch
  201. echo -ne "#{test_dir}/file-names/invalid-utf8-1: [\\xFF]" | xargs -0 touch
  202. echo -ne "#{test_dir}/file-names/invalid-utf8-2: [\\xc3\\x28]" | xargs -0 touch
  203. echo -ne "#{test_dir}/file-names/invalid-utf8-3: [\\xe2\\x82\\x28]" | xargs -0 touch
  204. echo -ne "#{test_dir}/file-names/invalid-utf8-4: [\\xf0\\x28\\x8c\\x28]" | xargs -0 touch
  205. echo -ne "#{test_dir}/file-names/new-line-dir: [\\n]" | xargs -0 mkdir
  206. echo -ne "#{test_dir}/file-names/new-line-dir: [\\n]/subfile" | xargs -0 touch
  207. echo -ne "#{test_dir}/file-names/new-line-dir: [\\n]/another: [\\n]" | xargs -0 touch
  208. echo -ne "#{test_dir}/file-names/new-line-dir: [\\n]/broken" | xargs -0 touch
  209. mkdir "#{test_dir}/file-names/links"
  210. ln -s "#{test_dir}/file-names/new-line-dir"*/* "#{test_dir}/file-names/links"
  211. echo -ne "#{test_dir}/file-names/new-line-dir: [\\n]/broken" | xargs -0 rm
  212. EOF
  213. # Special file testcases.
  214. config.vm.provision :shell, privileged: false, inline: <<-EOF
  215. set -xe
  216. mkdir "#{test_dir}/specials"
  217. sudo mknod "#{test_dir}/specials/block-device" b 3 60
  218. sudo mknod "#{test_dir}/specials/char-device" c 14 40
  219. sudo mknod "#{test_dir}/specials/named-pipe" p
  220. sudo touch -t #{some_date} "#{test_dir}/specials/"*
  221. EOF
  222. # Awkward symlink testcases.
  223. config.vm.provision :shell, privileged: false, inline: <<-EOF
  224. set -xe
  225. mkdir "#{test_dir}/links"
  226. ln -s / "#{test_dir}/links/root"
  227. ln -s /usr "#{test_dir}/links/usr"
  228. ln -s nowhere "#{test_dir}/links/broken"
  229. ln -s /proc/1/root "#{test_dir}/links/forbidden"
  230. touch "#{test_dir}/links/some_file"
  231. ln -s "#{test_dir}/links/some_file" "#{test_dir}/links/some_file_absolute"
  232. (cd "#{test_dir}/links"; ln -s "some_file" "some_file_relative")
  233. (cd "#{test_dir}/links"; ln -s "." "current_dir")
  234. (cd "#{test_dir}/links"; ln -s ".." "parent_dir")
  235. (cd "#{test_dir}/links"; ln -s "itself" "itself")
  236. EOF
  237. # Awkward passwd testcases.
  238. # sudo is needed for these because we technically aren’t a member
  239. # of the groups (because they don’t exist), and chown and chgrp
  240. # are smart enough to disallow it!
  241. config.vm.provision :shell, privileged: false, inline: <<-EOF
  242. set -xe
  243. mkdir "#{test_dir}/passwd"
  244. touch -t #{some_date} "#{test_dir}/passwd/unknown-uid"
  245. chmod 644 "#{test_dir}/passwd/unknown-uid"
  246. sudo chown #{invalid_uid}:#{user} "#{test_dir}/passwd/unknown-uid"
  247. touch -t #{some_date} "#{test_dir}/passwd/unknown-gid"
  248. chmod 644 "#{test_dir}/passwd/unknown-gid"
  249. sudo chown #{user}:#{invalid_gid} "#{test_dir}/passwd/unknown-gid"
  250. EOF
  251. # Awkward permission testcases.
  252. # Differences in the way ā€˜chmod’ handles setting ā€˜setuid’ and ā€˜setgid’
  253. # when you don’t already own the file mean that we need to use ā€˜sudo’
  254. # to change permissions to those.
  255. config.vm.provision :shell, privileged: false, inline: <<-EOF
  256. set -xe
  257. mkdir "#{test_dir}/permissions"
  258. mkdir "#{test_dir}/permissions/forbidden-directory"
  259. chmod 000 "#{test_dir}/permissions/forbidden-directory"
  260. touch -t #{some_date} "#{test_dir}/permissions/forbidden-directory"
  261. sudo chown #{user}:#{user} "#{test_dir}/permissions/forbidden-directory"
  262. for perms in 000 001 002 004 010 020 040 100 200 400 644 755 777 1000 1001 2000 2010 4000 4100 7666 7777; do
  263. touch "#{test_dir}/permissions/$perms"
  264. sudo chown #{user}:#{user} "#{test_dir}/permissions/$perms"
  265. sudo chmod $perms "#{test_dir}/permissions/$perms"
  266. sudo touch -t #{some_date} "#{test_dir}/permissions/$perms"
  267. done
  268. EOF
  269. old = '200303030000.00'
  270. med = '200606152314.29' # the june gets used for fr_FR locale tests
  271. new = '200912221038.53' # and the december for ja_JP local tests
  272. # Awkward date and time testcases.
  273. config.vm.provision :shell, privileged: false, inline: <<-EOF
  274. set -xe
  275. mkdir "#{test_dir}/dates"
  276. # there's no way to touch the created date of a file...
  277. # so we have to do this the old-fashioned way!
  278. # (and make sure these don't actually get listed)
  279. touch -t #{old} "#{test_dir}/dates/peach"; sleep 1
  280. touch -t #{med} "#{test_dir}/dates/plum"; sleep 1
  281. touch -t #{new} "#{test_dir}/dates/pear"
  282. # modified dates
  283. touch -t #{old} -m "#{test_dir}/dates/pear"
  284. touch -t #{med} -m "#{test_dir}/dates/peach"
  285. touch -t #{new} -m "#{test_dir}/dates/plum"
  286. # accessed dates
  287. touch -t #{old} -a "#{test_dir}/dates/plum"
  288. touch -t #{med} -a "#{test_dir}/dates/pear"
  289. touch -t #{new} -a "#{test_dir}/dates/peach"
  290. sudo chown #{user}:#{user} -R "#{test_dir}/dates"
  291. EOF
  292. # Awkward extended attribute testcases.
  293. # We need to test combinations of various numbers of files *and*
  294. # extended attributes in directories. Turns out, the easiest way to
  295. # do this is to generate all combinations of files with ā€œone-xattrā€
  296. # or ā€œtwo-xattrsā€ in their name and directories with ā€œemptyā€ or
  297. # ā€œone-fileā€ in their name, then just give the right number of
  298. # xattrs and children to those.
  299. config.vm.provision :shell, privileged: false, inline: <<-EOF
  300. set -xe
  301. mkdir "#{test_dir}/attributes"
  302. mkdir "#{test_dir}/attributes/files"
  303. touch "#{test_dir}/attributes/files/"{no-xattrs,one-xattr,two-xattrs}{,_forbidden}
  304. mkdir "#{test_dir}/attributes/dirs"
  305. mkdir "#{test_dir}/attributes/dirs/"{no-xattrs,one-xattr,two-xattrs}_{empty,one-file,two-files}{,_forbidden}
  306. setfattr -n user.greeting -v hello "#{test_dir}/attributes"/**/*{one-xattr,two-xattrs}*
  307. setfattr -n user.another_greeting -v hi "#{test_dir}/attributes"/**/*two-xattrs*
  308. for dir in "#{test_dir}/attributes/dirs/"*one-file*; do
  309. touch $dir/file-in-question
  310. done
  311. for dir in "#{test_dir}/attributes/dirs/"*two-files*; do
  312. touch $dir/this-file
  313. touch $dir/that-file
  314. done
  315. find "#{test_dir}/attributes" -exec touch {} -t #{some_date} \\;
  316. # I want to use the following to test,
  317. # but it only works on macos:
  318. #chmod +a "#{user} deny readextattr" "#{test_dir}/attributes"/**/*_forbidden
  319. sudo chmod 000 "#{test_dir}/attributes"/**/*_forbidden
  320. sudo chown #{user}:#{user} -R "#{test_dir}/attributes"
  321. EOF
  322. # A sample Git repository
  323. # This uses cd because it's easier than telling Git where to go each time
  324. config.vm.provision :shell, privileged: false, inline: <<-EOF
  325. set -xe
  326. mkdir "#{test_dir}/git"
  327. cd "#{test_dir}/git"
  328. git init
  329. mkdir edits additions moves
  330. echo "original content" | tee edits/{staged,unstaged,both}
  331. echo "this file gets moved" > moves/hither
  332. git add edits moves
  333. git config --global user.email "exa@exa.exa"
  334. git config --global user.name "Exa Exa"
  335. git commit -m "Automated test commit"
  336. echo "modifications!" | tee edits/{staged,both}
  337. touch additions/{staged,edited}
  338. mv moves/{hither,thither}
  339. git add edits moves additions
  340. echo "more modifications!" | tee edits/unstaged edits/both additions/edited
  341. touch additions/unstaged
  342. find "#{test_dir}/git" -exec touch {} -t #{some_date} \\;
  343. sudo chown #{user}:#{user} -R "#{test_dir}/git"
  344. EOF
  345. # A second Git repository
  346. # for testing two at once
  347. config.vm.provision :shell, privileged: false, inline: <<-EOF
  348. set -xe
  349. mkdir -p "#{test_dir}/git2/deeply/nested/directory"
  350. cd "#{test_dir}/git2"
  351. git init
  352. touch "deeply/nested/directory/upd8d"
  353. git add "deeply/nested/directory/upd8d"
  354. git commit -m "Automated test commit"
  355. echo "Now with contents" > "deeply/nested/directory/upd8d"
  356. touch "deeply/nested/directory/l8st"
  357. echo -e "target\n*.mp3" > ".gitignore"
  358. mkdir "ignoreds"
  359. touch "ignoreds/music.mp3"
  360. touch "ignoreds/music.m4a"
  361. mkdir "ignoreds/nested"
  362. touch "ignoreds/nested/70s grove.mp3"
  363. touch "ignoreds/nested/funky chicken.m4a"
  364. mkdir "target"
  365. touch "target/another ignored file"
  366. mkdir "deeply/nested/repository"
  367. cd "deeply/nested/repository"
  368. git init
  369. touch subfile
  370. find "#{test_dir}/git2" -exec touch {} -t #{some_date} \\;
  371. sudo chown #{user}:#{user} -R "#{test_dir}/git2"
  372. EOF
  373. # A third Git repository
  374. # Regression test for https://github.com/ogham/exa/issues/526
  375. config.vm.provision :shell, privileged: false, inline: <<-EOF
  376. set -xe
  377. mkdir -p "#{test_dir}/git3"
  378. cd "#{test_dir}/git3"
  379. git init
  380. # Create a symbolic link pointing to a non-existing file
  381. ln -s aaa/aaa/a b
  382. find "#{test_dir}/git3" -exec touch {} -t #{some_date} \\;
  383. sudo chown #{user}:#{user} -R "#{test_dir}/git3"
  384. EOF
  385. # Hidden and dot file testcases.
  386. # We need to set the permissions of `.` and `..` because they actually
  387. # get displayed in the output here, so this has to come last.
  388. config.vm.provision :shell, privileged: false, inline: <<-EOF
  389. set -xe
  390. shopt -u dotglob
  391. GLOBIGNORE=".:.."
  392. mkdir "#{test_dir}/hiddens"
  393. touch "#{test_dir}/hiddens/visible"
  394. touch "#{test_dir}/hiddens/.hidden"
  395. touch "#{test_dir}/hiddens/..extra-hidden"
  396. # ./hiddens/
  397. touch -t #{some_date} "#{test_dir}/hiddens/"*
  398. chmod 644 "#{test_dir}/hiddens/"*
  399. sudo chown #{user}:#{user} "#{test_dir}/hiddens/"*
  400. # .
  401. touch -t #{some_date} "#{test_dir}/hiddens"
  402. chmod 755 "#{test_dir}/hiddens"
  403. sudo chown #{user}:#{user} "#{test_dir}/hiddens"
  404. # ..
  405. sudo touch -t #{some_date} "#{test_dir}"
  406. sudo chmod 755 "#{test_dir}"
  407. sudo chown #{user}:#{user} "#{test_dir}"
  408. EOF
  409. # Set up some locales
  410. config.vm.provision :shell, privileged: false, inline: <<-EOF
  411. set -xe
  412. # uncomment these from the config file
  413. sudo sed -i '/fr_FR.UTF-8/s/^# //g' /etc/locale.gen
  414. sudo sed -i '/ja_JP.UTF-8/s/^# //g' /etc/locale.gen
  415. sudo locale-gen
  416. EOF
  417. # Install kcov for test coverage
  418. # This doesn’t run coverage over the xtests so it’s less useful for now
  419. if ENV.key?('INSTALL_KCOV')
  420. config.vm.provision :shell, privileged: false, inline: <<-EOF
  421. set -xe
  422. test -e ~/.cargo/bin/cargo-kcov \
  423. || cargo install cargo-kcov
  424. sudo apt-get install -qq -o=Dpkg::Use-Pty=0 -y \
  425. cmake g++ pkg-config \
  426. libcurl4-openssl-dev libdw-dev binutils-dev libiberty-dev
  427. cargo kcov --print-install-kcov-sh | sudo sh
  428. EOF
  429. end
  430. end
  431. # Remember that problem that exa had where the binary wasn’t actually
  432. # self-contained? Or the problem where the Linux binary was actually the
  433. # macOS binary in disguise?
  434. #
  435. # This is a ā€œfreshā€ VM that intentionally downloads no dependencies and
  436. # installs nothing so that we can check that exa still runs!
  437. config.vm.define(:fresh) do |config|
  438. config.vm.box = UBUNTU
  439. config.vm.hostname = 'fresh'
  440. config.vm.provider :virtualbox do |v|
  441. v.name = 'exa-fresh'
  442. v.memory = 384
  443. v.cpus = 1
  444. end
  445. # Well, we do need *one* dependency...
  446. config.vm.provision :shell, privileged: true, inline: <<-EOF
  447. set -xe
  448. apt-get install -qq -o=Dpkg::Use-Pty=0 -y unzip
  449. EOF
  450. # This thing also has its own welcoming text.
  451. config.vm.provision :shell, privileged: true, inline: <<-EOF
  452. rm -f /etc/update-motd.d/*
  453. # Capture the help text so it gets displayed first
  454. bash /vagrant/devtools/dev-help-testvm.sh > /etc/motd
  455. # Disable last login date in sshd
  456. sed -i '/PrintLastLog yes/c\PrintLastLog no' /etc/ssh/sshd_config
  457. systemctl restart sshd
  458. EOF
  459. # Make the checker script a command.
  460. config.vm.provision :shell, privileged: true, inline: <<-EOF
  461. set -xe
  462. echo -e "#!/bin/sh\nbash /vagrant/devtools/dev-download-and-check-release.sh \"\\$*\"" > /usr/bin/check-release
  463. chmod +x /usr/bin/check-release
  464. EOF
  465. end
  466. end