Skip to content

Commit d938c3a

Browse files
author
Jenkins CI
committed
Merge branch 'branches/rudder/8.0'
2 parents 7d8d487 + 4d9e7ea commit d938c3a

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

policies/rudderc/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ pub mod action {
375375
),
376376
);
377377
// Run test checks
378-
let res = case.check(test_dir, target_dir);
378+
let res = case.check(test_dir, &report_file, target_dir);
379379
// Run anyway
380380
case.cleanup(test_dir, target_dir)?;
381381
res?;

policies/rudderc/src/test.rs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,20 @@ pub struct Step {
3131
}
3232

3333
impl Step {
34-
fn run(&self, target: Target, dir: &Path, target_dir: &Path) -> Result<()> {
34+
fn run(
35+
&self,
36+
target: Target,
37+
cwd: &Path,
38+
env: Vec<(&str, &str)>,
39+
target_dir: &Path,
40+
) -> Result<()> {
3541
ok_output("Running", format!("'{}'", &self.command));
3642
let output = match target {
3743
Target::Unix => Command::new("/bin/sh")
3844
.arg("-c")
3945
.arg(&self.command)
40-
.current_dir(dir)
46+
.envs(env.into_iter())
47+
.current_dir(cwd)
4148
.output()?,
4249
Target::Windows => {
4350
// Write the command into a script
@@ -49,7 +56,8 @@ impl Step {
4956
.args(POWERSHELL_OPTS)
5057
.arg("-Command")
5158
.arg(format!("&'{}'", &script.canonicalize()?.to_string_lossy()))
52-
.current_dir(dir)
59+
.envs(env.into_iter())
60+
.current_dir(cwd)
5361
.output()?
5462
}
5563
};
@@ -95,21 +103,29 @@ pub struct TestCase {
95103
impl TestCase {
96104
pub fn setup(&self, dir: &Path, target_dir: &Path) -> Result<()> {
97105
for s in &self.setup {
98-
s.run(self.target, dir, target_dir)?;
106+
s.run(self.target, dir, vec![], target_dir)?;
99107
}
100108
Ok(())
101109
}
102110

103-
pub fn check(&self, dir: &Path, target_dir: &Path) -> Result<()> {
111+
pub fn check(&self, dir: &Path, reports_file: &Path, target_dir: &Path) -> Result<()> {
104112
for s in &self.check {
105-
s.run(self.target, dir, target_dir)?;
113+
s.run(
114+
self.target,
115+
dir,
116+
vec![(
117+
"REPORTS_FILE",
118+
&reports_file.canonicalize().unwrap().to_string_lossy(),
119+
)],
120+
target_dir,
121+
)?;
106122
}
107123
Ok(())
108124
}
109125

110126
pub fn cleanup(&self, dir: &Path, target_dir: &Path) -> Result<()> {
111127
for s in &self.cleanup {
112-
s.run(self.target, dir, target_dir)?;
128+
s.run(self.target, dir, vec![], target_dir)?;
113129
}
114130
Ok(())
115131
}

policies/rudderc/tests/cases/test/one_param_unix/tests/case2.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ setup:
1212
check:
1313
# Commands to run to check
1414
- sh: "! test -f /tmp/rudderc_test_one"
15+
- sh: "echo $REPORTS_FILE && test -f ${REPORTS_FILE}"

0 commit comments

Comments
 (0)