Skip to content

Commit ae8502d

Browse files
authored
Use tags on windows/unix and allow failures on appveyor (#7320)
1 parent 0bed0d0 commit ae8502d

File tree

9 files changed

+111
-93
lines changed

9 files changed

+111
-93
lines changed

.appveyor.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ test_script:
1111
environment:
1212
ELIXIR_ASSERT_TIMEOUT: 2000
1313

14-
configuration: Test
15-
1614
matrix:
1715
allow_failures:
18-
- configuration: Test
16+
- platform: x86
17+
- platform: x64
18+
- platform: Any CPU

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
=========
33
[![Travis build](https://secure.travis-ci.org/elixir-lang/elixir.svg?branch=master
44
"Build Status")](https://travis-ci.org/elixir-lang/elixir)
5-
[![Windows build](https://ci.appveyor.com/api/projects/status/macwuxq7aiiv61g1?svg=true)](https://ci.appveyor.com/project/josevalim/elixir)
6-
75

86
Elixir is a dynamic, functional language designed for building scalable and maintainable applications.
97

lib/elixir/test/elixir/node_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ defmodule NodeTest do
55

66
doctest Node
77

8+
@tag :unix
89
test "start/3 and stop/0" do
910
assert Node.stop() == {:error, :not_found}
1011
assert {:ok, _} = Node.start(:hello, :shortnames, 15000)

lib/elixir/test/elixir/path_test.exs

Lines changed: 62 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -36,67 +36,69 @@ defmodule PathTest do
3636
assert_raise ArgumentError, ~r/null byte/, fn -> Path.wildcard("foo\0bar") end
3737
end
3838

39-
if windows?() do
40-
describe "Windows" do
41-
test "relative/1" do
42-
assert Path.relative("C:/usr/local/bin") == "usr/local/bin"
43-
assert Path.relative("C:\\usr\\local\\bin") == "usr\\local\\bin"
44-
assert Path.relative("C:usr\\local\\bin") == "usr\\local\\bin"
45-
46-
assert Path.relative("/usr/local/bin") == "usr/local/bin"
47-
assert Path.relative("usr/local/bin") == "usr/local/bin"
48-
assert Path.relative("../usr/local/bin") == "../usr/local/bin"
49-
end
50-
51-
test "relative_to/2" do
52-
assert Path.relative_to("D:/usr/local/foo", "D:/usr/") == "local/foo"
53-
assert Path.relative_to("D:/usr/local/foo", "d:/usr/") == "local/foo"
54-
assert Path.relative_to("d:/usr/local/foo", "D:/usr/") == "local/foo"
55-
assert Path.relative_to("D:/usr/local/foo", "d:/") == "usr/local/foo"
56-
assert Path.relative_to("D:/usr/local/foo", "D:/") == "usr/local/foo"
57-
assert Path.relative_to("D:/usr/local/foo", "d:") == "D:/usr/local/foo"
58-
assert Path.relative_to("D:/usr/local/foo", "D:") == "D:/usr/local/foo"
59-
end
60-
61-
test "type/1" do
62-
assert Path.type("C:/usr/local/bin") == :absolute
63-
assert Path.type('C:\\usr\\local\\bin') == :absolute
64-
assert Path.type("C:usr\\local\\bin") == :volumerelative
65-
66-
assert Path.type("/usr/local/bin") == :volumerelative
67-
assert Path.type('usr/local/bin') == :relative
68-
assert Path.type("../usr/local/bin") == :relative
69-
end
70-
71-
test "split/1" do
72-
assert Path.split("C:\\foo\\bar") == ["c:/", "foo", "bar"]
73-
assert Path.split("C:/foo/bar") == ["c:/", "foo", "bar"]
74-
end
39+
describe "Windows" do
40+
@describetag :windows
41+
42+
test "relative/1" do
43+
assert Path.relative("C:/usr/local/bin") == "usr/local/bin"
44+
assert Path.relative("C:\\usr\\local\\bin") == "usr\\local\\bin"
45+
assert Path.relative("C:usr\\local\\bin") == "usr\\local\\bin"
46+
47+
assert Path.relative("/usr/local/bin") == "usr/local/bin"
48+
assert Path.relative("usr/local/bin") == "usr/local/bin"
49+
assert Path.relative("../usr/local/bin") == "../usr/local/bin"
7550
end
76-
else
77-
describe "Unix" do
78-
test "relative/1" do
79-
assert Path.relative("/usr/local/bin") == "usr/local/bin"
80-
assert Path.relative("usr/local/bin") == "usr/local/bin"
81-
assert Path.relative("../usr/local/bin") == "../usr/local/bin"
82-
assert Path.relative("/") == "."
83-
assert Path.relative('/') == "."
84-
assert Path.relative(['/usr', ?/, "local/bin"]) == "usr/local/bin"
85-
end
86-
87-
test "type/1" do
88-
assert Path.type("/usr/local/bin") == :absolute
89-
assert Path.type("usr/local/bin") == :relative
90-
assert Path.type("../usr/local/bin") == :relative
91-
92-
assert Path.type('/usr/local/bin') == :absolute
93-
assert Path.type('usr/local/bin') == :relative
94-
assert Path.type('../usr/local/bin') == :relative
95-
96-
assert Path.type(['/usr/', 'local/bin']) == :absolute
97-
assert Path.type(['usr/', 'local/bin']) == :relative
98-
assert Path.type(['../usr', '/local/bin']) == :relative
99-
end
51+
52+
test "relative_to/2" do
53+
assert Path.relative_to("D:/usr/local/foo", "D:/usr/") == "local/foo"
54+
assert Path.relative_to("D:/usr/local/foo", "d:/usr/") == "local/foo"
55+
assert Path.relative_to("d:/usr/local/foo", "D:/usr/") == "local/foo"
56+
assert Path.relative_to("D:/usr/local/foo", "d:/") == "usr/local/foo"
57+
assert Path.relative_to("D:/usr/local/foo", "D:/") == "usr/local/foo"
58+
assert Path.relative_to("D:/usr/local/foo", "d:") == "D:/usr/local/foo"
59+
assert Path.relative_to("D:/usr/local/foo", "D:") == "D:/usr/local/foo"
60+
end
61+
62+
test "type/1" do
63+
assert Path.type("C:/usr/local/bin") == :absolute
64+
assert Path.type('C:\\usr\\local\\bin') == :absolute
65+
assert Path.type("C:usr\\local\\bin") == :volumerelative
66+
67+
assert Path.type("/usr/local/bin") == :volumerelative
68+
assert Path.type('usr/local/bin') == :relative
69+
assert Path.type("../usr/local/bin") == :relative
70+
end
71+
72+
test "split/1" do
73+
assert Path.split("C:\\foo\\bar") == ["c:/", "foo", "bar"]
74+
assert Path.split("C:/foo/bar") == ["c:/", "foo", "bar"]
75+
end
76+
end
77+
78+
describe "Unix" do
79+
@describetag :unix
80+
81+
test "relative/1" do
82+
assert Path.relative("/usr/local/bin") == "usr/local/bin"
83+
assert Path.relative("usr/local/bin") == "usr/local/bin"
84+
assert Path.relative("../usr/local/bin") == "../usr/local/bin"
85+
assert Path.relative("/") == "."
86+
assert Path.relative('/') == "."
87+
assert Path.relative(['/usr', ?/, "local/bin"]) == "usr/local/bin"
88+
end
89+
90+
test "type/1" do
91+
assert Path.type("/usr/local/bin") == :absolute
92+
assert Path.type("usr/local/bin") == :relative
93+
assert Path.type("../usr/local/bin") == :relative
94+
95+
assert Path.type('/usr/local/bin') == :absolute
96+
assert Path.type('usr/local/bin') == :relative
97+
assert Path.type('../usr/local/bin') == :relative
98+
99+
assert Path.type(['/usr/', 'local/bin']) == :absolute
100+
assert Path.type(['usr/', 'local/bin']) == :relative
101+
assert Path.type(['../usr', '/local/bin']) == :relative
100102
end
101103
end
102104

lib/elixir/test/elixir/system_test.exs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,14 @@ defmodule SystemTest do
9292
end
9393
end
9494

95-
if windows?() do
96-
test "cmd/2 win" do
95+
describe "Windows" do
96+
@describetag :windows
97+
98+
test "cmd/2" do
9799
assert {"hello\r\n", 0} = System.cmd("cmd", ~w[/c echo hello])
98100
end
99101

100-
test "cmd/3 (with options) win" do
102+
test "cmd/3 (with options)" do
101103
assert {["hello\r\n"], 0} =
102104
System.cmd(
103105
"cmd",
@@ -113,7 +115,7 @@ defmodule SystemTest do
113115

114116
@echo "echo-elixir-test"
115117

116-
test "cmd/2 with absolute and relative Windows paths" do
118+
test "cmd/2 with absolute and relative paths" do
117119
echo = tmp_path(@echo)
118120
File.mkdir_p!(Path.dirname(echo))
119121
File.cp!(System.find_executable("cmd"), echo)
@@ -132,12 +134,16 @@ defmodule SystemTest do
132134
after
133135
File.rm_rf!(Path.dirname(tmp_path(@echo)))
134136
end
135-
else
136-
test "cmd/2 unix" do
137+
end
138+
139+
describe "Unix" do
140+
@describetag :unix
141+
142+
test "cmd/2" do
137143
assert {"hello\n", 0} = System.cmd("echo", ["hello"])
138144
end
139145

140-
test "cmd/3 (with options) unix" do
146+
test "cmd/3 (with options)" do
141147
opts = [
142148
into: [],
143149
cd: System.cwd!(),
@@ -152,7 +158,7 @@ defmodule SystemTest do
152158

153159
@echo "echo-elixir-test"
154160

155-
test "cmd/2 with absolute and relative Unix paths" do
161+
test "cmd/2 with absolute and relative paths" do
156162
echo = tmp_path(@echo)
157163
File.mkdir_p!(Path.dirname(echo))
158164
File.cp!(System.find_executable("echo"), echo)

lib/elixir/test/elixir/test_helper.exs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
assert_timeout = String.to_integer(System.get_env("ELIXIR_ASSERT_TIMEOUT") || "500")
2-
ExUnit.start(trace: "--trace" in System.argv(), assert_receive_timeout: assert_timeout)
3-
41
# Beam files compiled on demand
52
path = Path.expand("../../tmp/beams", __DIR__)
63
File.rm_rf!(path)
@@ -87,3 +84,12 @@ defmodule CodeFormatterHelpers do
8784
end
8885
end
8986
end
87+
88+
assert_timeout = String.to_integer(System.get_env("ELIXIR_ASSERT_TIMEOUT") || "500")
89+
exclude = if PathHelpers.windows?(), do: [unix: true], else: [windows: true]
90+
91+
ExUnit.start(
92+
trace: "--trace" in System.argv(),
93+
assert_receive_timeout: assert_timeout,
94+
exclude: exclude
95+
)

lib/mix/test/mix/rebar_test.exs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ defmodule Mix.RebarTest do
249249
end
250250
end
251251

252+
# We run only on Unix because Windows has a hard time
253+
# removing the rebar executable after executed.
254+
@tag [unix: true]
252255
test "applies variables from :system_env option when compiling dependencies for Rebar" do
253256
Mix.Project.push(RebarAsDepWithEnv)
254257

@@ -294,6 +297,9 @@ defmodule Mix.RebarTest do
294297
end
295298
end
296299

300+
# We run only on Unix because Windows has a hard time
301+
# removing the rebar executable after executed.
302+
@tag [unix: true]
297303
test "applies variables from :system_env option when compiling dependencies for rebar3" do
298304
Mix.Project.push(Rebar3AsDep)
299305

lib/mix/test/mix/utils_test.exs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,34 +50,31 @@ defmodule Mix.UtilsTest do
5050
end
5151

5252
test "symlink or copy" do
53-
in_fixture "archive", fn ->
53+
in_fixture("archive", fn ->
5454
File.mkdir_p!("_build/archive")
5555
result = Mix.Utils.symlink_or_copy(Path.expand("ebin"), Path.expand("_build/archive/ebin"))
5656
assert_ebin_symlinked_or_copied(result)
57-
end
57+
end)
5858
end
5959

6060
test "symlink or copy removes previous directories" do
61-
in_fixture "archive", fn ->
61+
in_fixture("archive", fn ->
6262
File.mkdir_p!("_build/archive/ebin")
6363
result = Mix.Utils.symlink_or_copy(Path.expand("ebin"), Path.expand("_build/archive/ebin"))
6464
assert_ebin_symlinked_or_copied(result)
65-
end
65+
end)
6666
end
6767

68-
@windows? match?({:win32, _}, :os.type())
69-
unless @windows? do
70-
test "symlink or copy erases wrong symlinks" do
71-
in_fixture "archive", fn ->
72-
File.mkdir_p!("_build/archive")
73-
Mix.Utils.symlink_or_copy(Path.expand("priv"), Path.expand("_build/archive/ebin"))
74-
75-
result =
76-
Mix.Utils.symlink_or_copy(Path.expand("ebin"), Path.expand("_build/archive/ebin"))
68+
@tag unix: true
69+
test "symlink or copy erases wrong symlinks" do
70+
in_fixture("archive", fn ->
71+
File.mkdir_p!("_build/archive")
72+
build_ebin = Path.expand("_build/archive/ebin")
73+
Mix.Utils.symlink_or_copy(Path.expand("priv"), build_ebin)
7774

78-
assert_ebin_symlinked_or_copied(result)
79-
end
80-
end
75+
result = Mix.Utils.symlink_or_copy(Path.expand("ebin"), build_ebin)
76+
assert_ebin_symlinked_or_copied(result)
77+
end)
8178
end
8279

8380
test "proxy_config reads from env and returns credentials" do

lib/mix/test/test_helper.exs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
Mix.start()
22
Mix.shell(Mix.Shell.Process)
33
Application.put_env(:mix, :colors, enabled: false)
4-
ExUnit.start(trace: "--trace" in System.argv())
4+
5+
exclude = if match?({:win32, _}, :os.type()), do: [unix: true], else: [windows: true]
6+
ExUnit.start(trace: "--trace" in System.argv(), exclude: exclude)
57

68
unless {1, 7, 4} <= Mix.SCM.Git.git_version() do
79
IO.puts(:stderr, "Skipping tests with git sparse checkouts...")

0 commit comments

Comments
 (0)