Source code for ramble.test.modifier_functionality.modifier_prepare_analysis

# Copyright 2022-2026 The Ramble Authors
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.

import os
import re

import pytest

import ramble.workspace
from ramble.main import RambleCommand
from ramble.test.dry_run_helpers import SCOPES, dry_run_config
from ramble.test.modifier_functionality import modifier_helpers

config = RambleCommand("config")
workspace = RambleCommand("workspace")
on_cmd = RambleCommand("on")


[docs] @pytest.mark.long @pytest.mark.parametrize( "scope", [ SCOPES.workspace, SCOPES.application, SCOPES.workload, SCOPES.experiment, ], ) def test_basic_dry_run_mock_prepare_analysis_mod( mutable_mock_workspace_path, mock_applications, mock_modifiers, scope, workspace_name ): test_modifiers = [(scope, modifier_helpers.named_modifier("prepare-analysis"))] with ramble.workspace.create(workspace_name) as ws1: ws1.write() config_path = os.path.join(ws1.config_dir, ramble.workspace.CONFIG_FILE_NAME) dry_run_config( "modifiers", test_modifiers, config_path, "basic", "working_wl", batch_cmd="" ) ws1._re_read() ws_args = ["-D", ws1.root] workspace("concretize", global_args=ws_args) workspace("setup", global_args=ws_args) on_cmd(global_args=ws_args) workspace("analyze", global_args=ws_args) expected_regex = re.compile(".*This test worked") found_str = False with open(os.path.join(ws1.results_dir, "results.latest.txt")) as f: for line in f: if expected_regex.match(line): found_str = True assert found_str