]> git.lizzy.rs Git - rust.git/commitdiff
test: Fix run-make on windows
authorklutzy <klutzytheklutzy@gmail.com>
Sun, 27 Apr 2014 07:52:36 +0000 (16:52 +0900)
committerklutzy <klutzytheklutzy@gmail.com>
Mon, 28 Apr 2014 02:45:30 +0000 (11:45 +0900)
14 files changed:
src/etc/maketest.py
src/test/run-make/c-link-to-rust-staticlib/Makefile
src/test/run-make/dep-info-custom/Makefile
src/test/run-make/dep-info/Makefile
src/test/run-make/lto-smoke-c/Makefile
src/test/run-make/no-intermediate-extras/foo.rs
src/test/run-make/obey-crate-type-flag/Makefile
src/test/run-make/output-type-permutations/Makefile
src/test/run-make/prune-link-args/Makefile
src/test/run-make/rustdoc-hidden-line/Makefile
src/test/run-make/symlinked-libraries/Makefile
src/test/run-make/tools.mk
src/test/run-make/unicode-input/Makefile
src/test/run-make/weird-output-filenames/Makefile

index 9e8bee3abb6c0254bac1d2910c5afedf76296b5a..7646113560bbb07a8e71cd1a929a41f6e1cda54b 100644 (file)
@@ -12,26 +12,53 @@ import subprocess
 import os
 import sys
 
-# FIXME #12303 these tests are broken on windows
-if os.name == 'nt':
-    print 'ignoring make tests on windows'
-    sys.exit(0)
+# msys1/msys2 automatically converts `/abs/path1:/abs/path2` into
+# `c:\real\abs\path1;c:\real\abs\path2` (semicolons) if shell thinks
+# the value is list of paths.
+# this causes great confusion and error: shell and Makefile doesn't like
+# windows paths so it is really error-prone. revert it for peace.
+def normalize_path(v):
+    # c:\path -> /c/path
+    if ':\\' in v:
+        v = '/' + v.replace(':\\', '/')
+    v = v.replace('\\', '/')
+    return v
+
+
+def putenv(name, value):
+    if os.name == 'nt':
+        value = normalize_path(value)
+    os.putenv(name, value)
+
 
 make = sys.argv[2]
-os.putenv('RUSTC', os.path.abspath(sys.argv[3]))
-os.putenv('TMPDIR', os.path.abspath(sys.argv[4]))
-os.putenv('CC', sys.argv[5])
-os.putenv('RUSTDOC', os.path.abspath(sys.argv[6]))
+putenv('RUSTC', os.path.abspath(sys.argv[3]))
+putenv('TMPDIR', os.path.abspath(sys.argv[4]))
+putenv('CC', sys.argv[5])
+putenv('RUSTDOC', os.path.abspath(sys.argv[6]))
 filt = sys.argv[7]
 ldpath = sys.argv[8]
 if ldpath != '':
-    os.putenv(ldpath.split('=')[0], ldpath.split('=')[1])
+    name = ldpath.split('=')[0]
+    value = ldpath.split('=')[1]
+    if os.name == 'nt' and name != 'PATH':
+        value = ":".join(normalize_path(v) for v in value.split(";"))
+    os.putenv(name, value)
 
 if not filt in sys.argv[1]:
     sys.exit(0)
 print('maketest: ' + os.path.basename(os.path.dirname(sys.argv[1])))
 
-proc = subprocess.Popen([make, '-C', sys.argv[1]],
+path = sys.argv[1]
+if path[-1] == '/':
+    # msys1 has a bug that `make` fails to include `../tools.mk` (parent dir)
+    # if `-C path` option is given and `path` is absolute directory with
+    # trailing slash (`c:/path/to/test/`).
+    # the easist workaround is to remove the slash (`c:/path/to/test`).
+    # msys2 seems to fix this problem.
+    path = path[:-1]
+
+proc = subprocess.Popen([make, '-C', path],
                         stdout = subprocess.PIPE,
                         stderr = subprocess.PIPE)
 out, err = proc.communicate()
index 78ac1f66bfcbea1c5c602533f2610da95fe9a467..7312a65c81238cebb2b8858321d3eb4d85468ee0 100644 (file)
@@ -1,10 +1,12 @@
 -include ../tools.mk
 
+ifndef IS_WINDOWS
 ifneq ($(shell uname),Darwin)
        EXTRAFLAGS := -lm -lrt -ldl -lpthread
 endif
+endif
 
-# FIXME
+# FIXME: ignore freebsd
 ifneq ($(shell uname),FreeBSD)
 all:
        $(RUSTC) foo.rs
index ca70ccae3dae92ddfacf91c7c579032eff24d098..efa6dfe981bb6badc5c7cc67089d750322198e4d 100644 (file)
@@ -1,7 +1,9 @@
 -include ../tools.mk
 
-# FIXME
+# FIXME: ignore freebsd/windows
+# (windows: see `../dep-info/Makefile`)
 ifneq ($(shell uname),FreeBSD)
+ifndef IS_WINDOWS
 all:
        $(RUSTC) --dep-info $(TMPDIR)/custom-deps-file.d --crate-type=lib lib.rs
        sleep 1
@@ -16,3 +18,8 @@ else
 all:
 
 endif
+
+else
+all:
+
+endif
index 277e7ad62944834d29ac407cd2611210986bce5d..6835ef34b0b2031ed653cf20bc1511ad4328fc5f 100644 (file)
@@ -1,6 +1,11 @@
 -include ../tools.mk
 
+# FIXME: ignore freebsd/windows
+# on windows `rustc --dep-info` produces Makefile dependency with
+# windows native paths (e.g. `c:\path\to\libfoo.a`)
+# but msys make seems to fail to recognize such paths, so test fails.
 ifneq ($(shell uname),FreeBSD)
+ifndef IS_WINDOWS
 all:
        $(RUSTC) --dep-info --crate-type=lib lib.rs
        sleep 2
@@ -16,3 +21,8 @@ else
 all:
 
 endif
+
+else
+all:
+
+endif
index de8588bac9b7cd2917ebf1bb3eca690f9b0863dc..85b8d0e2dd82a62de798237d43116d064fab1a39 100644 (file)
@@ -1,5 +1,8 @@
 -include ../tools.mk
 
+ifdef IS_WINDOWS
+       EXTRAFLAGS :=
+else
 ifeq ($(shell uname),Darwin)
 else
 ifeq ($(shell uname),FreeBSD)
@@ -8,6 +11,7 @@ else
        EXTRAFLAGS := -lm -lrt -ldl -lpthread
 endif
 endif
+endif
 
 # Apparently older versions of GCC segfault if -g is passed...
 CC := $(CC:-g=)
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..60a7f067476b0fba25839e29e2a38968d1d7b3e1 100644 (file)
@@ -0,0 +1,14 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// FIXME #13793
+#[test]
+fn test_dummy() {
+}
index c28bc7c7b5e93b09807c78c4fb5859beba92fa3d..a3c58a6bf17fe276b66c179dae13366e7f1e4106 100644 (file)
@@ -7,7 +7,7 @@
 # fail if an rlib was built
 all:
        $(RUSTC) test.rs
-       rm $(TMPDIR)/libtest*.rlib
-       rm $(TMPDIR)/libtest*
+       rm $(TMPDIR)/$(call RLIB_GLOB,test)
+       rm $(TMPDIR)/$(call DYLIB_GLOB,test)
        $(RUSTC) --crate-type dylib test.rs
-       rm $(TMPDIR)/libtest*.rlib && exit 1 || exit 0
+       rm $(TMPDIR)/$(call RLIB_GLOB,test) && exit 1 || exit 0
index 94e0ce833438f1e72b22fa84da64ce61b402b4ed..5a309cddeb184b0f3326bb992b3e10b8f9458acd 100644 (file)
@@ -6,13 +6,13 @@ all:
        rm $(TMPDIR)/$(call DYLIB_GLOB,bar)
        rm $(TMPDIR)/$(call STATICLIB_GLOB,bar)
        $(RUSTC) foo.rs --crate-type=bin
-       rm $(TMPDIR)/bar
+       rm $(TMPDIR)/$(call BIN,bar)
        $(RUSTC) foo.rs --emit=asm,ir,bc,obj,link
        rm $(TMPDIR)/bar.ll
        rm $(TMPDIR)/bar.bc
        rm $(TMPDIR)/bar.s
        rm $(TMPDIR)/bar.o
-       rm $(TMPDIR)/bar
+       rm $(TMPDIR)/$(call BIN,bar)
        $(RUSTC) foo.rs --emit=asm,ir,bc,obj,link --crate-type=staticlib
        rm $(TMPDIR)/bar.ll
        rm $(TMPDIR)/bar.s
@@ -27,15 +27,15 @@ all:
        $(RUSTC) foo.rs --emit=obj -o $(TMPDIR)/foo
        rm $(TMPDIR)/foo
        $(RUSTC) foo.rs --emit=link -o $(TMPDIR)/foo
-       rm $(TMPDIR)/foo
+       rm $(TMPDIR)/$(call BIN,foo)
        $(RUSTC) foo.rs --crate-type=rlib -o $(TMPDIR)/foo
        rm $(TMPDIR)/foo
        $(RUSTC) foo.rs --crate-type=dylib -o $(TMPDIR)/foo
-       rm $(TMPDIR)/foo
+       rm $(TMPDIR)/$(call BIN,foo)  # FIXME 13794
        $(RUSTC) foo.rs --crate-type=staticlib -o $(TMPDIR)/foo
        rm $(TMPDIR)/foo
        $(RUSTC) foo.rs --crate-type=bin -o $(TMPDIR)/foo
-       rm $(TMPDIR)/foo
+       rm $(TMPDIR)/$(call BIN,foo)
        mv $(TMPDIR)/bar.bc $(TMPDIR)/foo.bc
        $(RUSTC) foo.rs --emit=bc,link --crate-type=rlib
        cmp $(TMPDIR)/foo.bc $(TMPDIR)/bar.bc
index ea7fa06f5ef19268c73b802862e413a8ec6b0563..a6e219873dfd28af4a5b42b269723e4752b37e17 100644 (file)
@@ -1,6 +1,11 @@
 -include ../tools.mk
+ifdef IS_WINDOWS
+# ignore windows
+RUSTC_FLAGS =
+else
 # Notice the space in the end, this emulates the output of pkg-config
 RUSTC_FLAGS = -C link-args="-lc "
+endif
 
 all:
        $(RUSTC) $(RUSTC_FLAGS) empty.rs
index 7e6f8fe105e922c3044ae1f3625c19b1509c8934..b67c1f66dd954a04f5556e8eb87e31544ff0f65c 100644 (file)
@@ -1,7 +1,15 @@
 -include ../tools.mk
 
+# FIXME ignore windows
+ifndef IS_WINDOWS
+
 all:
        $(RUSTDOC) --test foo.rs
        $(RUSTDOC) -w html -o $(TMPDIR)/doc foo.rs
        cp verify.sh $(TMPDIR)
        $(call RUN,verify.sh) $(TMPDIR)
+
+else
+all:
+
+endif
index 45ef241c28f7f5c621be37a2bea6e3db5a507343..9eb2c135230062ab418df7290b07331d0ab8576c 100644 (file)
@@ -1,7 +1,15 @@
 -include ../tools.mk
 
+# ignore windows: `ln` is actually `cp` on msys.
+ifndef IS_WINDOWS
+
 all:
        $(RUSTC) foo.rs
        mkdir -p $(TMPDIR)/other
        ln -nsf $(TMPDIR)/$(call DYLIB_GLOB,foo) $(TMPDIR)/other
        $(RUSTC) bar.rs -L $(TMPDIR)/other
+
+else
+all:
+
+endif
index 26e6e06c2ed8a007ddb58382a902af74846cdb4b..90274cdb3e7aab3eca9673368a48d8eea3dabb67 100644 (file)
@@ -10,14 +10,27 @@ FAILS = $(TMPDIR)/$(1) && exit 1 || exit 0
 RLIB_GLOB = lib$(1)*.rlib
 STATICLIB = $(TMPDIR)/lib$(1).a
 STATICLIB_GLOB = lib$(1)*.a
+BIN = $(1)
 
-ifeq ($(shell uname),Darwin)
+UNAME = $(shell uname)
+ifneq (,$(findstring MINGW,$(UNAME)))
+IS_WINDOWS=1
+endif
+
+ifeq ($(UNAME),Darwin)
 DYLIB_GLOB = lib$(1)*.dylib
 DYLIB = $(TMPDIR)/lib$(1).dylib
 else
+ifdef IS_WINDOWS
+DYLIB_GLOB = $(1)*.dll
+DYLIB = $(TMPDIR)/$(1).dll
+BIN = $(1).exe
+export PATH := $(PATH):$(LD_LIBRARY_PATH)
+else
 DYLIB_GLOB = lib$(1)*.so
 DYLIB = $(TMPDIR)/lib$(1).so
 endif
+endif
 
 %.a: %.o
        ar crus $@ $<
@@ -25,6 +38,9 @@ endif
        $(CC) -dynamiclib -Wl,-dylib -o $@ $<
 %.so: %.o
        $(CC) -o $@ $< -shared
+%.dll: lib%.o
+       $(CC) -o $@ $< -shared
+
 $(TMPDIR)/lib%.o: %.c
        $(CC) -c -o $@ $<
 
index 2d6ecd3c55efcf3b5da0d256e2f0c05ee87ff81a..529bfc24a400ac688a3995fc4b069cab6fcf0963 100644 (file)
@@ -1,5 +1,8 @@
 -include ../tools.mk
 
+# FIXME ignore windows
+ifndef IS_WINDOWS
+
 all:
        # check that we don't ICE on unicode input, issue #11178
        $(RUSTC) multiple_files.rs
@@ -9,3 +12,8 @@ all:
        # correct length. issue #8706
        $(RUSTC) span_length.rs
        $(call RUN,span_length) "$(RUSTC)" "$(TMPDIR)"
+
+else
+all:
+
+endif
index 9d852bce6f6a0c7088321ffed8e43d6d024983cf..debd89d9929b75784bf89d99ae547e876acca937 100644 (file)
@@ -6,4 +6,4 @@ all:
        $(RUSTC) foo.rs -o $(TMPDIR)/.foo.bar
        rm $(TMPDIR)/.foo.bar
        $(RUSTC) foo.rs -o $(TMPDIR)/+foo+bar
-       rm $(TMPDIR)/+foo+bar
+       rm $(TMPDIR)/$(call BIN,+foo+bar)