Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testament now checks OS, CPU, endianess, bitsizes 8-64 in discard statements #19137

Merged
merged 2 commits into from
Nov 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 50 additions & 20 deletions testament/specs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import sequtils, parseutils, strutils, os, streams, parsecfg,
tables, hashes, sets
import compiler/platform

type TestamentData* = ref object
# better to group globals under 1 object; could group the other ones here too
Expand Down Expand Up @@ -329,42 +330,71 @@ proc parseSpec*(filename: string): TSpec =
# Valgrind only supports OSX <= 17.x
result.useValgrind = disabled
of "disabled":
case e.value.normalize
let value = e.value.normalize
case value
of "y", "yes", "true", "1", "on": result.err = reDisabled
of "n", "no", "false", "0", "off": discard
of "win", "windows":
# These values are defined in `compiler/options.isDefined`
of "win":
when defined(windows): result.err = reDisabled
of "linux":
when defined(linux): result.err = reDisabled
of "bsd":
when defined(bsd): result.err = reDisabled
of "osx", "macosx": # xxx remove `macosx` alias?
of "osx":
when defined(osx): result.err = reDisabled
of "unix":
when defined(unix): result.err = reDisabled
of "posix":
of "unix", "posix":
when defined(posix): result.err = reDisabled
of "freebsd":
when defined(freebsd): result.err = reDisabled
of "littleendian":
when defined(littleendian): result.err = reDisabled
of "bigendian":
when defined(bigendian): result.err = reDisabled
of "cpu8", "8bit":
when defined(cpu8): result.err = reDisabled
of "cpu16", "16bit":
when defined(cpu16): result.err = reDisabled
of "cpu32", "32bit":
when defined(cpu32): result.err = reDisabled
of "cpu64", "64bit":
when defined(cpu64): result.err = reDisabled
# These values are for CI environments
of "travis": # deprecated
if isTravis: result.err = reDisabled
of "appveyor": # deprecated
if isAppVeyor: result.err = reDisabled
of "azure":
if isAzure: result.err = reDisabled
of "32bit":
if sizeof(int) == 4:
result.err = reDisabled
of "freebsd":
when defined(freebsd): result.err = reDisabled
of "arm64":
when defined(arm64): result.err = reDisabled
of "i386":
when defined(i386): result.err = reDisabled
of "openbsd":
when defined(openbsd): result.err = reDisabled
of "netbsd":
when defined(netbsd): result.err = reDisabled
else:
result.parseErrors.addLine "cannot interpret as a bool: ", e.value
# Check whether the value exists as an OS or CPU that is
# defined in `compiler/platform`.
block checkHost:
for os in platform.OS:
# Check if the value exists as OS.
if value == os.name.normalize:
# The value exists; is it the same as the current host?
if value == hostOS.normalize:
quantimnot marked this conversation as resolved.
Show resolved Hide resolved
# The value exists and is the same as the current host,
# so disable the test.
result.err = reDisabled
# The value was defined, so there is no need to check further
# values or raise an error.
break checkHost
for cpu in platform.CPU:
# Check if the value exists as CPU.
if value == cpu.name.normalize:
# The value exists; is it the same as the current host?
if value == hostCPU.normalize:
# The value exists and is the same as the current host,
# so disable the test.
result.err = reDisabled
# The value was defined, so there is no need to check further
# values or raise an error.
break checkHost
# The value doesn't exist as an OS, CPU, or any previous value
# defined in this case statement, so raise an error.
result.parseErrors.addLine "cannot interpret as a bool: ", e.value
of "cmd":
if e.value.startsWith("nim "):
result.cmd = compilerPrefix & e.value[3..^1]
Expand Down