Avoid slow test setup if seed flag is set to -1
This commit is contained in:
parent
f620843591
commit
8300f24fec
4 changed files with 12 additions and 5 deletions
|
|
@ -20,6 +20,8 @@ static void assert_correct_tree_size(TSDocument *document, string content) {
|
|||
|
||||
START_TEST
|
||||
|
||||
if (TREE_SITTER_SEED == -1) return;
|
||||
|
||||
vector<string> test_languages({
|
||||
"javascript",
|
||||
"json",
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
START_TEST
|
||||
|
||||
if (TREE_SITTER_SEED == -1) return;
|
||||
|
||||
string grammars_dir_path = join_path({"test", "fixtures", "test_grammars"});
|
||||
vector<string> test_languages = list_directory(grammars_dir_path);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
#include "tree_sitter/compiler.h"
|
||||
#include "tree_sitter/runtime.h"
|
||||
|
||||
extern int TREE_SITTER_SEED;
|
||||
|
||||
namespace tree_sitter {}
|
||||
|
||||
using namespace std;
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
#include "test_helper.h"
|
||||
#include "helpers/random_helpers.h"
|
||||
|
||||
int TREE_SITTER_SEED = 0;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int seed;
|
||||
const char *seed_env = getenv("TREE_SITTER_SEED");
|
||||
if (seed_env) {
|
||||
seed = atoi(seed_env);
|
||||
TREE_SITTER_SEED = atoi(seed_env);
|
||||
} else {
|
||||
seed = get_time_as_seed();
|
||||
TREE_SITTER_SEED = get_time_as_seed();
|
||||
}
|
||||
|
||||
printf("Random seed: %d\n", seed);
|
||||
random_reseed(seed);
|
||||
printf("Random seed: %d\n", TREE_SITTER_SEED);
|
||||
random_reseed(TREE_SITTER_SEED);
|
||||
|
||||
return bandit::run(argc, argv);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue