From 405861ed0a87ca67e34882d8c444c4cb2f34ab7c Mon Sep 17 00:00:00 2001 From: klutzy Date: Sun, 27 Apr 2014 16:52:36 +0900 Subject: [PATCH] test: Fix run-make on windows --- src/etc/maketest.py | 47 +++++++++++++++---- .../c-link-to-rust-staticlib/Makefile | 4 +- src/test/run-make/dep-info-custom/Makefile | 9 +++- src/test/run-make/dep-info/Makefile | 10 ++++ src/test/run-make/lto-smoke-c/Makefile | 4 ++ .../run-make/no-intermediate-extras/foo.rs | 14 ++++++ .../run-make/obey-crate-type-flag/Makefile | 6 +-- .../output-type-permutations/Makefile | 10 ++-- src/test/run-make/prune-link-args/Makefile | 5 ++ .../run-make/rustdoc-hidden-line/Makefile | 8 ++++ .../run-make/symlinked-libraries/Makefile | 8 ++++ src/test/run-make/tools.mk | 18 ++++++- src/test/run-make/unicode-input/Makefile | 8 ++++ .../run-make/weird-output-filenames/Makefile | 2 +- 14 files changed, 131 insertions(+), 22 deletions(-) diff --git a/src/etc/maketest.py b/src/etc/maketest.py index 9e8bee3abb6..7646113560b 100644 --- a/src/etc/maketest.py +++ b/src/etc/maketest.py @@ -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() diff --git a/src/test/run-make/c-link-to-rust-staticlib/Makefile b/src/test/run-make/c-link-to-rust-staticlib/Makefile index 78ac1f66bfc..7312a65c812 100644 --- a/src/test/run-make/c-link-to-rust-staticlib/Makefile +++ b/src/test/run-make/c-link-to-rust-staticlib/Makefile @@ -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 diff --git a/src/test/run-make/dep-info-custom/Makefile b/src/test/run-make/dep-info-custom/Makefile index ca70ccae3da..efa6dfe981b 100644 --- a/src/test/run-make/dep-info-custom/Makefile +++ b/src/test/run-make/dep-info-custom/Makefile @@ -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 diff --git a/src/test/run-make/dep-info/Makefile b/src/test/run-make/dep-info/Makefile index 277e7ad6294..6835ef34b0b 100644 --- a/src/test/run-make/dep-info/Makefile +++ b/src/test/run-make/dep-info/Makefile @@ -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 diff --git a/src/test/run-make/lto-smoke-c/Makefile b/src/test/run-make/lto-smoke-c/Makefile index de8588bac9b..85b8d0e2dd8 100644 --- a/src/test/run-make/lto-smoke-c/Makefile +++ b/src/test/run-make/lto-smoke-c/Makefile @@ -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=) diff --git a/src/test/run-make/no-intermediate-extras/foo.rs b/src/test/run-make/no-intermediate-extras/foo.rs index e69de29bb2d..60a7f067476 100644 --- a/src/test/run-make/no-intermediate-extras/foo.rs +++ b/src/test/run-make/no-intermediate-extras/foo.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// FIXME #13793 +#[test] +fn test_dummy() { +} diff --git a/src/test/run-make/obey-crate-type-flag/Makefile b/src/test/run-make/obey-crate-type-flag/Makefile index c28bc7c7b5e..a3c58a6bf17 100644 --- a/src/test/run-make/obey-crate-type-flag/Makefile +++ b/src/test/run-make/obey-crate-type-flag/Makefile @@ -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 diff --git a/src/test/run-make/output-type-permutations/Makefile b/src/test/run-make/output-type-permutations/Makefile index 94e0ce83343..5a309cddeb1 100644 --- a/src/test/run-make/output-type-permutations/Makefile +++ b/src/test/run-make/output-type-permutations/Makefile @@ -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 diff --git a/src/test/run-make/prune-link-args/Makefile b/src/test/run-make/prune-link-args/Makefile index ea7fa06f5ef..a6e219873df 100644 --- a/src/test/run-make/prune-link-args/Makefile +++ b/src/test/run-make/prune-link-args/Makefile @@ -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 diff --git a/src/test/run-make/rustdoc-hidden-line/Makefile b/src/test/run-make/rustdoc-hidden-line/Makefile index 7e6f8fe105e..b67c1f66dd9 100644 --- a/src/test/run-make/rustdoc-hidden-line/Makefile +++ b/src/test/run-make/rustdoc-hidden-line/Makefile @@ -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 diff --git a/src/test/run-make/symlinked-libraries/Makefile b/src/test/run-make/symlinked-libraries/Makefile index 45ef241c28f..9eb2c135230 100644 --- a/src/test/run-make/symlinked-libraries/Makefile +++ b/src/test/run-make/symlinked-libraries/Makefile @@ -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 diff --git a/src/test/run-make/tools.mk b/src/test/run-make/tools.mk index 26e6e06c2ed..90274cdb3e7 100644 --- a/src/test/run-make/tools.mk +++ b/src/test/run-make/tools.mk @@ -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 $@ $< diff --git a/src/test/run-make/unicode-input/Makefile b/src/test/run-make/unicode-input/Makefile index 2d6ecd3c55e..529bfc24a40 100644 --- a/src/test/run-make/unicode-input/Makefile +++ b/src/test/run-make/unicode-input/Makefile @@ -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 diff --git a/src/test/run-make/weird-output-filenames/Makefile b/src/test/run-make/weird-output-filenames/Makefile index 9d852bce6f6..debd89d9929 100644 --- a/src/test/run-make/weird-output-filenames/Makefile +++ b/src/test/run-make/weird-output-filenames/Makefile @@ -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)