From 5bb1e648cdaacfca330deed10a663606266604ea Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 4 Dec 2015 22:02:09 +0100 Subject: [PATCH 1/2] Change internal `getopts` so `--a=b=c` acts like `--a b=c` rather than `--a b`. This is an adaption of https://github.com/rust-lang-nursery/getopts/commit/8ec916b86afce0a2a9100b7327b12b5ffcb2cabb including its unit test. --- src/libgetopts/lib.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index f7544e3f5ea0..228ceb92da66 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -598,7 +598,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result { let mut i_arg = None; if cur.as_bytes()[1] == b'-' { let tail = &cur[2..curlen]; - let tail_eq: Vec<&str> = tail.split('=').collect(); + let tail_eq: Vec<&str> = tail.splitn(2, '=').collect(); if tail_eq.len() <= 1 { names = vec![Long(tail.to_owned())]; } else { @@ -1626,4 +1626,18 @@ Options: debug!("generated: <<{}>>", generated_usage); assert_eq!(generated_usage, expected); } + + #[test] + fn test_args_with_equals() { + let args = vec!("--one".to_string(), "A=B".to_string(), + "--two=C=D".to_string()); + let opts = vec![optopt("o", "one", "One", "INFO"), + optopt("t", "two", "Two", "INFO")]; + let matches = &match getopts(&args, &opts) { + result::Result::Ok(m) => m, + result::Result::Err(e) => panic!("{}", e) + }; + assert_eq!(matches.opts_str(&["o".to_string()]).unwrap(), "A=B"); + assert_eq!(matches.opts_str(&["t".to_string()]).unwrap(), "C=D"); + } } From 288034bda2e70e4de5cb6a01495916d3e88de34c Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 4 Dec 2015 22:02:48 +0100 Subject: [PATCH 2/2] Expand run-make test with regression tests for #30204 Fix #30204. --- .../output-type-permutations/Makefile | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/test/run-make/output-type-permutations/Makefile b/src/test/run-make/output-type-permutations/Makefile index b4b2e827e947..6cfa7043a2e3 100644 --- a/src/test/run-make/output-type-permutations/Makefile +++ b/src/test/run-make/output-type-permutations/Makefile @@ -27,30 +27,40 @@ all: rm $(TMPDIR)/foo $(RUSTC) foo.rs --emit asm=$(TMPDIR)/foo rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit=asm=$(TMPDIR)/foo + rm $(TMPDIR)/foo [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] $(RUSTC) foo.rs --emit llvm-bc -o $(TMPDIR)/foo rm $(TMPDIR)/foo $(RUSTC) foo.rs --emit llvm-bc=$(TMPDIR)/foo rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit=llvm-bc=$(TMPDIR)/foo + rm $(TMPDIR)/foo [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] $(RUSTC) foo.rs --emit llvm-ir -o $(TMPDIR)/foo rm $(TMPDIR)/foo $(RUSTC) foo.rs --emit llvm-ir=$(TMPDIR)/foo rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit=llvm-ir=$(TMPDIR)/foo + rm $(TMPDIR)/foo [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] $(RUSTC) foo.rs --emit obj -o $(TMPDIR)/foo rm $(TMPDIR)/foo $(RUSTC) foo.rs --emit obj=$(TMPDIR)/foo rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit=obj=$(TMPDIR)/foo + rm $(TMPDIR)/foo [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] $(RUSTC) foo.rs --emit link -o $(TMPDIR)/$(call BIN,foo) rm $(TMPDIR)/$(call BIN,foo) $(RUSTC) foo.rs --emit link=$(TMPDIR)/$(call BIN,foo) rm $(TMPDIR)/$(call BIN,foo) + $(RUSTC) foo.rs --emit=link=$(TMPDIR)/$(call BIN,foo) + rm $(TMPDIR)/$(call BIN,foo) rm -f $(TMPDIR)/foo.pdb [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] @@ -58,12 +68,16 @@ all: rm $(TMPDIR)/foo $(RUSTC) foo.rs --crate-type=rlib --emit link=$(TMPDIR)/foo rm $(TMPDIR)/foo + $(RUSTC) foo.rs --crate-type=rlib --emit=link=$(TMPDIR)/foo + rm $(TMPDIR)/foo [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] $(RUSTC) foo.rs --crate-type=dylib -o $(TMPDIR)/$(call BIN,foo) rm $(TMPDIR)/$(call BIN,foo) $(RUSTC) foo.rs --crate-type=dylib --emit link=$(TMPDIR)/$(call BIN,foo) rm $(TMPDIR)/$(call BIN,foo) + $(RUSTC) foo.rs --crate-type=dylib --emit=link=$(TMPDIR)/$(call BIN,foo) + rm $(TMPDIR)/$(call BIN,foo) rm -f $(TMPDIR)/foo.{exp,lib,pdb} [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] @@ -71,12 +85,16 @@ all: rm $(TMPDIR)/foo $(RUSTC) foo.rs --crate-type=staticlib --emit link=$(TMPDIR)/foo rm $(TMPDIR)/foo + $(RUSTC) foo.rs --crate-type=staticlib --emit=link=$(TMPDIR)/foo + rm $(TMPDIR)/foo [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] $(RUSTC) foo.rs --crate-type=bin -o $(TMPDIR)/$(call BIN,foo) rm $(TMPDIR)/$(call BIN,foo) $(RUSTC) foo.rs --crate-type=bin --emit link=$(TMPDIR)/$(call BIN,foo) rm $(TMPDIR)/$(call BIN,foo) + $(RUSTC) foo.rs --crate-type=bin --emit=link=$(TMPDIR)/$(call BIN,foo) + rm $(TMPDIR)/$(call BIN,foo) rm -f $(TMPDIR)/foo.pdb [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] @@ -98,6 +116,17 @@ all: rm $(TMPDIR)/bc rm $(TMPDIR)/obj rm $(TMPDIR)/link + $(RUSTC) foo.rs --emit=asm=$(TMPDIR)/asm \ + --emit llvm-ir=$(TMPDIR)/ir \ + --emit=llvm-bc=$(TMPDIR)/bc \ + --emit obj=$(TMPDIR)/obj \ + --emit=link=$(TMPDIR)/link \ + --crate-type=staticlib + rm $(TMPDIR)/asm + rm $(TMPDIR)/ir + rm $(TMPDIR)/bc + rm $(TMPDIR)/obj + rm $(TMPDIR)/link [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] $(RUSTC) foo.rs --emit=asm,llvm-ir,llvm-bc,obj,link --crate-type=staticlib