Assert
From NSIS Wiki
Jump to navigationJump to search
Assert
A runtime assertion library , built on top of LogicLib.
Usage
Binary assertions (works with all LogicLib operators):
${Assert} $R0 == "expected" "values match"
${Assert} $R0 != "" "not empty"
${Assert} $R0 ${StartsWith} "Hello" "starts with Hello"
${Assert} $R0 ${Contains} "world" "contains world"
Negated assertions:
${AssertNot} $R0 == "bad" "must not be bad"
${AssertNot} $R0 ${Contains} "error" "no errors"
Unary assertions (prefix-style LogicLib operators):
${Assert} ${FileExists} "$INSTDIR\app.exe" "app installed"
${AssertNot} ${FileExists} "$TEMP\leftover" "no leftovers"
Summary (prints totals, sets ErrorLevel 1 on failure):
${AssertSummary}
Compile-time assertions:
${AssertDefined} MY_VERSION
${AssertUndefined} DEPRECATED_FLAG
Verbosity:
Define __ASSERT_VERBOSITY__ before including Assert.nsh.
0 = silent, 1 = errors only, 2 = all results (default)
!define __ASSERT_VERBOSITY__ 1 !include "Assert.nsh"
Fail-fast:
Define __ASSERT_FAILFAST__ to abort the installer on the first
failure. Sets ErrorLevel 1 before calling Abort.
!define __ASSERT_FAILFAST__ !include "Assert.nsh"