| 1 | #~ Copyright 2006 Rene Rivera. |
|---|
| 2 | #~ Distributed under the Boost Software License, Version 1.0. |
|---|
| 3 | #~ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) |
|---|
| 4 | |
|---|
| 5 | ECHO --- Testing SHELL builtin... ; |
|---|
| 6 | |
|---|
| 7 | local result = 0 ; |
|---|
| 8 | local rule error ( message * ) |
|---|
| 9 | { |
|---|
| 10 | local b = [ BACKTRACE ] ; |
|---|
| 11 | ECHO "$(b[9]):$(b[10]): error:" $(message) ; |
|---|
| 12 | } |
|---|
| 13 | local rule assert ( expected + : test ? : obtained + ) |
|---|
| 14 | { |
|---|
| 15 | test ?= "(==)" ; |
|---|
| 16 | local r = 0 ; |
|---|
| 17 | if $(test) = "(==)" && $(expected) != $(obtained) |
|---|
| 18 | { |
|---|
| 19 | error [FAILED] '$(expected)' $(test) '$(obtained)' ; |
|---|
| 20 | r = 1 ; |
|---|
| 21 | } |
|---|
| 22 | else if $(test) = "(!=)" && $(expected) = $(obtained) |
|---|
| 23 | { |
|---|
| 24 | error [FAILED] '$(expected)' $(test) '$(obtained)' ; |
|---|
| 25 | r = 1 ; |
|---|
| 26 | } |
|---|
| 27 | result = [ CALC $(result) + $(r) ] ; |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | #~ --------------------------------------------------------------------- |
|---|
| 31 | |
|---|
| 32 | local c = "date" ; |
|---|
| 33 | if $(NT) { c = "PATH" ; } |
|---|
| 34 | |
|---|
| 35 | assert "" : (!=) : [ SHELL $(c) ] ; |
|---|
| 36 | assert "" : (==) : [ SHELL $(c) : no-output ] ; |
|---|
| 37 | assert "" 0 : (!=) : [ SHELL $(c) : exit-status ] ; |
|---|
| 38 | assert "" 0 : (==) : [ SHELL $(c) : no-output : exit-status ] ; |
|---|
| 39 | assert "" : (!=) : [ COMMAND $(c) ] ; |
|---|
| 40 | assert "" : (==) : [ COMMAND $(c) : no-output ] ; |
|---|
| 41 | assert "" 0 : (!=) : [ COMMAND $(c) : exit-status ] ; |
|---|
| 42 | assert "" 0 : (==) : [ COMMAND $(c) : no-output : exit-status ] ; |
|---|
| 43 | |
|---|
| 44 | #~ --------------------------------------------------------------------- |
|---|
| 45 | |
|---|
| 46 | EXIT --- Complete : $(result) ; |
|---|