Patchwork [STABLE,V2] makefile: run Rust tests if cargo is installed

login
register
mail settings
Submitter Raphaël Gomès
Date Aug. 22, 2019, 12:57 p.m.
Message ID <450f65349bbe7c7a840f.1566478624@alphare-carbon.lan>
Download mbox | patch
Permalink /patch/41382/
State Accepted
Headers show

Comments

Raphaël Gomès - Aug. 22, 2019, 12:57 p.m.
# HG changeset patch
# User Raphaël Gomès <rgomes@octobus.net>
# Date 1566403010 -7200
#      Wed Aug 21 17:56:50 2019 +0200
# Branch stable
# Node ID 450f65349bbe7c7a840f7ddd275defbd9f413775
# Parent  302dbc9d52beeb2ef677aa18b3fa005bbce2134e
makefile: run Rust tests if cargo is installed

While no particular minimum toolchain version is targeted as of yet, this
serves as a first step to make more people/machines run the Rust tests.
Joerg Sonnenberger - Aug. 22, 2019, 1:53 p.m.
On Thu, Aug 22, 2019 at 02:57:04PM +0200, Raphaël Gomès wrote:
> diff -r 302dbc9d52be -r 450f65349bbe Makefile
> --- a/Makefile	Fri Aug 16 15:41:53 2019 +0300
> +++ b/Makefile	Wed Aug 21 17:56:50 2019 +0200
> @@ -16,6 +16,7 @@
>  export LC_ALL=C
>  TESTFLAGS ?= $(shell echo $$HGTESTFLAGS)
>  OSXVERSIONFLAGS ?= $(shell echo $$OSXVERSIONFLAGS)
> +CARGO=cargo
>  
>  # Set this to e.g. "mingw32" to use a non-default compiler.
>  COMPILER=

Please use ?= for CARGO too, makes it easier to override from the
command line.

Joerg
Yuya Nishihara - Aug. 22, 2019, 11:11 p.m.
On Thu, 22 Aug 2019 14:57:04 +0200, Raphaël Gomès wrote:
> # HG changeset patch
> # User Raphaël Gomès <rgomes@octobus.net>
> # Date 1566403010 -7200
> #      Wed Aug 21 17:56:50 2019 +0200
> # Branch stable
> # Node ID 450f65349bbe7c7a840f7ddd275defbd9f413775
> # Parent  302dbc9d52beeb2ef677aa18b3fa005bbce2134e
> makefile: run Rust tests if cargo is installed

Queued, thanks.

> diff -r 302dbc9d52be -r 450f65349bbe Makefile
> --- a/Makefile	Fri Aug 16 15:41:53 2019 +0300
> +++ b/Makefile	Wed Aug 21 17:56:50 2019 +0200
> @@ -16,6 +16,7 @@
>  export LC_ALL=C
>  TESTFLAGS ?= $(shell echo $$HGTESTFLAGS)
>  OSXVERSIONFLAGS ?= $(shell echo $$OSXVERSIONFLAGS)
> +CARGO=cargo
>  
>  # Set this to e.g. "mingw32" to use a non-default compiler.
>  COMPILER=
> @@ -110,7 +111,11 @@
>  check: tests
>  
>  tests:
> -	cd tests && $(PYTHON) run-tests.py $(TESTFLAGS)
> +	# Run Rust tests if cargo is installed

Replaced tab with spaces for the comment line.

> +	if command -v $(CARGO) >/dev/null 2>&1; then \
> +		cd $(HGROOT)/rust/hg-cpython && $(CARGO) test --quiet --all; \
> +	fi;
> +	cd tests && $(PYTHON) run-tests.py $(TESTFLAGS);

Dropped useless ;
Yuya Nishihara - Aug. 22, 2019, 11:15 p.m.
On Thu, 22 Aug 2019 15:53:01 +0200, Joerg Sonnenberger wrote:
> On Thu, Aug 22, 2019 at 02:57:04PM +0200, Raphaël Gomès wrote:
> > diff -r 302dbc9d52be -r 450f65349bbe Makefile
> > --- a/Makefile	Fri Aug 16 15:41:53 2019 +0300
> > +++ b/Makefile	Wed Aug 21 17:56:50 2019 +0200
> > @@ -16,6 +16,7 @@
> >  export LC_ALL=C
> >  TESTFLAGS ?= $(shell echo $$HGTESTFLAGS)
> >  OSXVERSIONFLAGS ?= $(shell echo $$OSXVERSIONFLAGS)
> > +CARGO=cargo
> >  
> >  # Set this to e.g. "mingw32" to use a non-default compiler.
> >  COMPILER=
> 
> Please use ?= for CARGO too, makes it easier to override from the
> command line.

Command-line arguments supersedes ordinary make variables.
Joerg Sonnenberger - Aug. 23, 2019, 9:13 a.m.
On Fri, Aug 23, 2019 at 08:15:05AM +0900, Yuya Nishihara wrote:
> On Thu, 22 Aug 2019 15:53:01 +0200, Joerg Sonnenberger wrote:
> > On Thu, Aug 22, 2019 at 02:57:04PM +0200, Raphaël Gomès wrote:
> > > diff -r 302dbc9d52be -r 450f65349bbe Makefile
> > > --- a/Makefile	Fri Aug 16 15:41:53 2019 +0300
> > > +++ b/Makefile	Wed Aug 21 17:56:50 2019 +0200
> > > @@ -16,6 +16,7 @@
> > >  export LC_ALL=C
> > >  TESTFLAGS ?= $(shell echo $$HGTESTFLAGS)
> > >  OSXVERSIONFLAGS ?= $(shell echo $$OSXVERSIONFLAGS)
> > > +CARGO=cargo
> > >  
> > >  # Set this to e.g. "mingw32" to use a non-default compiler.
> > >  COMPILER=
> > 
> > Please use ?= for CARGO too, makes it easier to override from the
> > command line.
> 
> Command-line arguments supersedes ordinary make variables.

...but environment variables don't.

Joerg
Yuya Nishihara - Aug. 23, 2019, 11:03 a.m.
On Fri, 23 Aug 2019 11:13:59 +0200, Joerg Sonnenberger wrote:
> On Fri, Aug 23, 2019 at 08:15:05AM +0900, Yuya Nishihara wrote:
> > On Thu, 22 Aug 2019 15:53:01 +0200, Joerg Sonnenberger wrote:
> > > On Thu, Aug 22, 2019 at 02:57:04PM +0200, Raphaël Gomès wrote:
> > > > diff -r 302dbc9d52be -r 450f65349bbe Makefile
> > > > --- a/Makefile	Fri Aug 16 15:41:53 2019 +0300
> > > > +++ b/Makefile	Wed Aug 21 17:56:50 2019 +0200
> > > > @@ -16,6 +16,7 @@
> > > >  export LC_ALL=C
> > > >  TESTFLAGS ?= $(shell echo $$HGTESTFLAGS)
> > > >  OSXVERSIONFLAGS ?= $(shell echo $$OSXVERSIONFLAGS)
> > > > +CARGO=cargo
> > > >  
> > > >  # Set this to e.g. "mingw32" to use a non-default compiler.
> > > >  COMPILER=
> > > 
> > > Please use ?= for CARGO too, makes it easier to override from the
> > > command line.
> > 
> > Command-line arguments supersedes ordinary make variables.
> 
> ...but environment variables don't.

That's good thing IMO. Better to not take arbitrary environment variables
unless -e|--environment-overrides is specified.

Patch

diff -r 302dbc9d52be -r 450f65349bbe Makefile
--- a/Makefile	Fri Aug 16 15:41:53 2019 +0300
+++ b/Makefile	Wed Aug 21 17:56:50 2019 +0200
@@ -16,6 +16,7 @@ 
 export LC_ALL=C
 TESTFLAGS ?= $(shell echo $$HGTESTFLAGS)
 OSXVERSIONFLAGS ?= $(shell echo $$OSXVERSIONFLAGS)
+CARGO=cargo
 
 # Set this to e.g. "mingw32" to use a non-default compiler.
 COMPILER=
@@ -110,7 +111,11 @@ 
 check: tests
 
 tests:
-	cd tests && $(PYTHON) run-tests.py $(TESTFLAGS)
+	# Run Rust tests if cargo is installed
+	if command -v $(CARGO) >/dev/null 2>&1; then \
+		cd $(HGROOT)/rust/hg-cpython && $(CARGO) test --quiet --all; \
+	fi;
+	cd tests && $(PYTHON) run-tests.py $(TESTFLAGS);
 
 test-%:
 	cd tests && $(PYTHON) run-tests.py $(TESTFLAGS) $@