Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
4cdc61e
test: add common.exposeInternals()
Trott Dec 19, 2018
104854c
test: add common.relaunchWithFlags()
Trott Dec 19, 2018
afdddac
test: use common.relaunchWithFlags() for --expose-gc
Trott Dec 19, 2018
510fe11
test: introduce common.experimentalWorker()
Trott Dec 19, 2018
98fabd8
test: use common.relaunchWithFlags() for --no-force-async-hooks-check
Trott Dec 19, 2018
648a7c4
test: use --experimental-modules automatically for es-module tests
Trott Dec 20, 2018
6021445
test: use common.relaunchWithFlags() for --inspect=0
Trott Dec 21, 2018
4329520
test: use common.relaunchWithFlags() for --trace-warnings
Trott Dec 21, 2018
169b43f
test: use common.relaunchWithFlags() for --no-warnings
Trott Dec 21, 2018
013dd61
test: use common.relaunchWithFlags() for --pending-deprecations
Trott Dec 21, 2018
50b7fa6
test: use common.relaunchWithFlags() for --zero-fill-buffers
Trott Dec 21, 2018
df816e3
test: use common.relaunchWithFlags() for '--debug-code'
Trott Dec 21, 2018
2078385
test: use common.relaunchWithFlags() for --expose-externalize-string
Trott Dec 21, 2018
ed8e54b
test: use common.relaunchWithFlags() for --allow-natives-syntax
Trott Dec 21, 2018
2429547
test: use common.relaunchWithFlags() for --tls-v1.* flags
Trott Dec 21, 2018
1dce939
test: remove unneeded use of --no-deprecation
Trott Dec 21, 2018
4817b2b
test: use common.relaunchWithFlags() for --preserve-symlinks
Trott Dec 21, 2018
3a5b5d7
test: use common.relaunchWithFlags() for special-case --expose-internals
Trott Dec 21, 2018
6eecd13
test: use common.relaunchWithFlags() for --abort-on-uncaught-exception
Trott Dec 21, 2018
35e141c
test: use common.relaunchWithFlags() for --title
Trott Dec 21, 2018
33a7f0f
test: use common.relaunchWithFlags for --experimental-repl-await
Trott Dec 21, 2018
3c5cd68
test: use common.relaunchWithFlags() for --use-bundled-ca
Trott Dec 21, 2018
e9ff344
test: use common.relaunchWithFlags() for --experimental-vm-modules
Trott Dec 21, 2018
c662003
test: use common.relaunchWithFlags() for --max-old-space-size
Trott Dec 21, 2018
482ef23
test: use common.relaunchWithFlags() for --require
Trott Dec 21, 2018
ad858a9
test: remove check for Flags: in common module
Trott Dec 19, 2018
97b2101
test: remove Flags: functionality from Python test runner
Trott Dec 21, 2018
2fbf88f
test: implement common.requireFlags()
Trott Dec 26, 2018
7bb8b47
test: wrap common.requireFlags() with common.exposeInternals()
Trott Dec 27, 2018
ec18dcd
test: remove common.exposeInternals()
Trott Dec 27, 2018
3c8c66e
test: remove common.experimentalWorker()
Trott Dec 27, 2018
f9a3f5d
test: remove common.relaunchWithFlags()
Trott Dec 27, 2018
d4eb09d
test: remove unnecessary logic around requireFlags() calls
Trott Dec 27, 2018
cec4d0e
test: revise signature for common.requireFlags()
Trott Dec 28, 2018
7b50eb6
fixup on experimental worker flag
Trott Jan 4, 2019
e716c0a
test: improve worker_threads handling in common.requireFlags()
Trott Dec 28, 2018
539d365
test: check for errors after in requireFlags()
Trott Dec 30, 2018
ac1913b
test: refactor test-inspector-overwrite-config.js
Trott Dec 30, 2018
bdcbdae
test: short-circuit requireFlags() when cluster worker
Trott Dec 31, 2018
146681b
test: simplify flags logic for esm tests
Trott Jan 1, 2019
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
Prev Previous commit
Next Next commit
test: remove Flags: functionality from Python test runner
Remove the processing of `Flags:` comments and associated documentation.
This is now handled by `common.relaunchWithFlags()`.
  • Loading branch information
Trott committed Jan 4, 2019
commit 97b210183b8b35c53591970ee346b17b21ce2bac
16 changes: 8 additions & 8 deletions doc/guides/writing-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,18 +248,15 @@ fs.readFile('test-file').then(
### Flags

Some tests will require running Node.js with specific command line flags set. To
accomplish this, add a `// Flags: ` comment in the preamble of the
test followed by the flags. For example, to allow a test to require some of the
`internal/*` modules, add the `--expose-internals` flag.
A test that would require `internal/freelist` could start like this:
accomplish this, use [`common.relaunchWithFlags()`][] or the more specific
helper functions [`common.exposeInternals()`][] or
[`common.experimentalWorker()`][]:

```javascript
'use strict';

// Flags: --expose-internals

require('../common');
const assert = require('assert');
const common = require('../common');
common.exposeInternals();
const freelist = require('internal/freelist');
```

Expand Down Expand Up @@ -399,6 +396,9 @@ To generate a test coverage report, see the
[ASCII]: http://man7.org/linux/man-pages/man7/ascii.7.html
[Google Test]: https://github.com/google/googletest
[`common` module]: https://github.com/nodejs/node/blob/master/test/common/README.md
[`common.experimentalWorker()`]: https://github.com/nodejs/node/blob/master/test/common/README.md#experimentalworker
[`common.exposeInternals()`]: https://github.com/nodejs/node/blob/master/test/common/README.md#exposeinternals
[`common.relaunchWithFlags()`]: https://github.com/nodejs/node/blob/master/test/common/README.md#relaunchwithflagsflags
[all maintained branches]: https://github.com/nodejs/lts
[node.green]: http://node.green/
[test fixture]: https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#test-fixtures-using-the-same-data-configuration-for-multiple-tests
Expand Down
6 changes: 6 additions & 0 deletions test/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,12 @@ spawn(...common.pwdCommand, { stdio: ['pipe'] });

Relaunches the test adding the specified command-line flags.

```js
const common = require('../common');
if (process.argv.includes('--preserve-symlinks'))
common.relaunchWithFlags(['--preserve-symlinks']);
```

### rootDir
* [<string>]

Expand Down
6 changes: 0 additions & 6 deletions test/message/testcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
except NameError:
xrange = range # Python 3

FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")

class MessageTestCase(test.TestCase):

def __init__(self, path, file, expected, arch, mode, context, config):
Expand Down Expand Up @@ -105,10 +103,6 @@ def GetName(self):

def GetCommand(self):
result = [self.config.context.GetVm(self.arch, self.mode)]
source = open(self.file).read()
flags_match = FLAGS_PATTERN.search(source)
if flags_match:
result += flags_match.group(1).strip().split()
if self.file.endswith('.mjs'):
result += ['--experimental-modules']
result.append(self.file)
Expand Down
6 changes: 0 additions & 6 deletions test/pseudo-tty/testcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
except NameError:
xrange = range # Python 3

FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")

class TTYTestCase(test.TestCase):

def __init__(self, path, file, expected, input, arch, mode, context, config):
Expand Down Expand Up @@ -104,10 +102,6 @@ def GetName(self):

def GetCommand(self):
result = [self.config.context.GetVm(self.arch, self.mode)]
source = open(self.file).read()
flags_match = FLAGS_PATTERN.search(source)
if flags_match:
result += flags_match.group(1).strip().split()
result.append(self.file)
return result

Expand Down
27 changes: 0 additions & 27 deletions test/testpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
from functools import reduce


FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")


class SimpleTestCase(test.TestCase):

def __init__(self, path, file, arch, mode, context, config, additional=None):
Expand All @@ -62,30 +59,6 @@ def GetName(self):

def GetCommand(self):
result = [self.config.context.GetVm(self.arch, self.mode)]
source = open(self.file).read()
flags_match = FLAGS_PATTERN.search(source)
if flags_match:
flags = flags_match.group(1).strip().split()
# The following block reads config.gypi to extract the v8_enable_inspector
# value. This is done to check if the inspector is disabled in which case
# the '--inspect' flag cannot be passed to the node process as it will
# cause node to exit and report the test as failed. The use case
# is currently when Node is configured --without-ssl and the tests should
# still be runnable but skip any tests that require ssl (which includes the
# inspector related tests). Also, if there is no ssl support the options
# '--use-bundled-ca' and '--use-openssl-ca' will also cause a similar
# failure so such tests are also skipped.
if (any(flag.startswith('--inspect') for flag in flags) and
not self.context.v8_enable_inspector):
print(': Skipping as node was compiled without inspector support')
elif (('--use-bundled-ca' in flags or
'--use-openssl-ca' in flags or
'--tls-v1.0' in flags or
'--tls-v1.1' in flags) and
not self.context.node_has_crypto):
print(': Skipping as node was compiled without crypto support')
else:
result += flags

if self.additional_flags:
result += self.additional_flags
Expand Down