Skip to content

Commit

Permalink
test: Fix run-make on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
klutzy committed Apr 28, 2014
1 parent 1efb668 commit 405861e
Show file tree
Hide file tree
Showing 14 changed files with 131 additions and 22 deletions.
47 changes: 37 additions & 10 deletions src/etc/maketest.py
Expand Up @@ -12,26 +12,53 @@
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()
Expand Down
4 changes: 3 additions & 1 deletion 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
Expand Down
9 changes: 8 additions & 1 deletion 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
Expand All @@ -16,3 +18,8 @@ else
all:

endif

else
all:

endif
10 changes: 10 additions & 0 deletions 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
Expand All @@ -16,3 +21,8 @@ else
all:

endif

else
all:

endif
4 changes: 4 additions & 0 deletions 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)
Expand All @@ -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=)
Expand Down
14 changes: 14 additions & 0 deletions 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 <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() {
}
6 changes: 3 additions & 3 deletions src/test/run-make/obey-crate-type-flag/Makefile
Expand Up @@ -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
10 changes: 5 additions & 5 deletions src/test/run-make/output-type-permutations/Makefile
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions 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
8 changes: 8 additions & 0 deletions 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
8 changes: 8 additions & 0 deletions 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
18 changes: 17 additions & 1 deletion src/test/run-make/tools.mk
Expand Up @@ -10,21 +10,37 @@ 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 $@ $<
%.dylib: %.o
$(CC) -dynamiclib -Wl,-dylib -o $@ $<
%.so: %.o
$(CC) -o $@ $< -shared
%.dll: lib%.o
$(CC) -o $@ $< -shared

$(TMPDIR)/lib%.o: %.c
$(CC) -c -o $@ $<

8 changes: 8 additions & 0 deletions 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
Expand All @@ -9,3 +12,8 @@ all:
# correct length. issue #8706
$(RUSTC) span_length.rs
$(call RUN,span_length) "$(RUSTC)" "$(TMPDIR)"

else
all:

endif
2 changes: 1 addition & 1 deletion src/test/run-make/weird-output-filenames/Makefile
Expand Up @@ -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)

5 comments on commit 405861e

@bors
Copy link
Contributor

@bors bors commented on 405861e Apr 28, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at klutzy@405861e

@bors
Copy link
Contributor

@bors bors commented on 405861e Apr 28, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging klutzy/rust/win-make-check = 405861e into auto

@bors
Copy link
Contributor

@bors bors commented on 405861e Apr 28, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

klutzy/rust/win-make-check = 405861e merged ok, testing candidate = 4e55bc7

@bors
Copy link
Contributor

@bors bors commented on 405861e Apr 28, 2014

@bors
Copy link
Contributor

@bors bors commented on 405861e Apr 28, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 4e55bc7

Please sign in to comment.