Skip to content

Commit fed2b09

Browse files
authored
Merge branch 'main' into perf/unify-build-features
2 parents ed46fd2 + f21d774 commit fed2b09

48 files changed

Lines changed: 1524 additions & 129 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎crates/sqlbuild-cli/src/argv/command_table.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2899,7 +2899,9 @@
28992899
"nargs": 0,
29002900
"const": true,
29012901
"default": false,
2902-
"help": "disable SQL syntax, binding, type inference, and semantic validation",
2902+
"help": {
2903+
"suppress": true
2904+
},
29032905
"group": 1
29042906
},
29052907
{

‎crates/sqlbuild-cli/src/argv/tests/test_parse_cli_arguments.rs‎

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::argv::models::{ArgvOutcome, Value};
22
use crate::argv::tests::helpers::{parse, strings};
3-
use crate::argv::tests::test_types::{ExitTestCase, ParsedValueTestCase};
3+
use crate::argv::tests::test_types::{ExitTestCase, HelpTextTestCase, ParsedValueTestCase};
44

55
#[test]
66
fn given_accepted_arguments_when_parsing_then_attributes_hold_the_parsed_values() {
@@ -29,6 +29,12 @@ fn given_accepted_arguments_when_parsing_then_attributes_hold_the_parsed_values(
2929
attribute: "dbt_args",
3030
expected_value: strings(&["--", "--no-color"]),
3131
},
32+
ParsedValueTestCase {
33+
description: "clone still accepts the hidden --no-sql-analysis flag",
34+
argv: &["clone", "--from", "prod", "--no-sql-analysis"],
35+
attribute: "no_sql_validation",
36+
expected_value: Value::Bool(true),
37+
},
3238
ParsedValueTestCase {
3339
description: "a nested sub-command's dest is set",
3440
argv: &["contract", "diff", "--from", "prod"],
@@ -100,3 +106,45 @@ fn given_help_version_or_rejected_arguments_when_parsing_then_exits_after_writin
100106
);
101107
}
102108
}
109+
110+
#[test]
111+
fn given_command_help_when_parsing_then_hidden_options_are_left_out() {
112+
let test_cases = [
113+
HelpTextTestCase {
114+
description: "clone help omits the no-op SQL analysis flag",
115+
argv: &["clone", "--help"],
116+
expected_present: &["--from FROM_TARGET", "--select"],
117+
expected_absent: &["--no-sql-analysis", "--no-sql-validation"],
118+
},
119+
HelpTextTestCase {
120+
description: "build help keeps the SQL analysis flag",
121+
argv: &["build", "--help"],
122+
expected_present: &["--no-sql-analysis"],
123+
expected_absent: &[],
124+
},
125+
];
126+
127+
for test_case in test_cases {
128+
let outcome: ArgvOutcome = parse(test_case.argv);
129+
let help: String = outcome
130+
.writes
131+
.iter()
132+
.map(|(_, text)| text.as_str())
133+
.collect();
134+
let present: Vec<&str> = test_case
135+
.expected_present
136+
.iter()
137+
.copied()
138+
.filter(|fragment| help.contains(fragment))
139+
.collect();
140+
let absent: Vec<&str> = test_case
141+
.expected_absent
142+
.iter()
143+
.copied()
144+
.filter(|fragment| !help.contains(fragment))
145+
.collect();
146+
assert_eq!(outcome.parsed, Err(0), "{}", test_case.description);
147+
assert_eq!(present, test_case.expected_present, "{help}");
148+
assert_eq!(absent, test_case.expected_absent, "{help}");
149+
}
150+
}

‎crates/sqlbuild-cli/src/argv/tests/test_types.rs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ pub(super) struct ExitTestCase {
4040
pub(super) expected_last_write: &'static str,
4141
}
4242

43+
/// A help request and fragments its text must and must not contain.
44+
pub(super) struct HelpTextTestCase {
45+
pub(super) description: &'static str,
46+
pub(super) argv: &'static [&'static str],
47+
pub(super) expected_present: &'static [&'static str],
48+
pub(super) expected_absent: &'static [&'static str],
49+
}
50+
4351
/// Text, width and indent for `textwrap.wrap`, and the expected lines.
4452
pub(super) struct WrapTestCase {
4553
pub(super) description: &'static str,

‎crates/sqlbuild-core/src/clone_text/main/render_clone_completion.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn render_clone_completion(
4242
label: "TOTAL".to_owned(),
4343
value: count(items, |_| true),
4444
});
45-
let elapsed: Option<String> = elapsed_seconds.map(|seconds| format!("({seconds:.2}s)"));
45+
let elapsed: Option<String> = elapsed_seconds.map(|seconds| format!("{seconds:.2}s"));
4646
let footer: String = format_summary_footer(style, &counts, elapsed.as_deref());
4747
let warnings: i64 = count(items, |item| item.status == CloneStatusKind::Warning);
4848
let failures: i64 = count(items, |item| item.status == CloneStatusKind::Failed);

‎crates/sqlbuild-core/src/clone_text/tests/test_clone_text.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,12 @@ fn given_items_when_completing_then_reports_messages_counts_and_exit_code() {
149149
expected_exit_code: 1,
150150
},
151151
CompletionTestCase {
152-
description: "success shows the doubly parenthesised elapsed time",
152+
description: "success shows the elapsed time in one pair of parentheses",
153153
items: vec![item("orders", "copied", CloneStatusKind::Success)],
154154
elapsed_seconds: Some(1.5),
155155
use_color: false,
156156
expected_text: "\n\u{2713} Completed successfully CLONED=0 COPIED=1 RECREATED_VIEWS=0 \
157-
RECREATED_FUNCTIONS=0 PASS=1 WARN=0 FAIL=0 TOTAL=1 ((1.50s))\n",
157+
RECREATED_FUNCTIONS=0 PASS=1 WARN=0 FAIL=0 TOTAL=1 (1.50s)\n",
158158
expected_exit_code: 0,
159159
},
160160
CompletionTestCase {

‎crates/sqlbuild-core/src/diagnostic_routing/constants.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,5 @@ pub const LEVEL_INFO: i64 = 20;
6262
pub const LEVEL_WARNING: i64 = 30;
6363
pub const LEVEL_ERROR: i64 = 40;
6464
pub const LEVEL_CRITICAL: i64 = 50;
65+
/// Directories that hold installed packages, even inside a project (a project `.venv`).
66+
pub const PACKAGE_DIRECTORIES: [&str; 2] = ["site-packages", "dist-packages"];
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//! `console_summary_line`: the one line a summarized console record shows.
2+
3+
/// The first line of `message`, without trailing whitespace.
4+
#[must_use]
5+
pub fn console_summary_line(message: &str) -> &str {
6+
message.lines().next().unwrap_or_default().trim_end()
7+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
pub mod compute_log_admits;
2+
pub mod console_summary_line;
23
pub mod diagnostic_severity;
34
pub mod internal_logger;
5+
pub mod project_source_path;
46
pub mod route_admits;
57
pub mod sql_digest;
8+
pub mod third_party_console_form;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//! `project_source_path`: whether a logging call came from the project's own Python.
2+
3+
use std::path::{Component, Path};
4+
5+
use crate::diagnostic_routing::constants::PACKAGE_DIRECTORIES;
6+
7+
/// Whether `pathname` lies under one of `project_roots` and outside installed packages.
8+
#[must_use]
9+
pub fn project_source_path(pathname: &str, project_roots: &[String]) -> bool {
10+
let path: &Path = Path::new(pathname);
11+
project_roots
12+
.iter()
13+
.any(|root| !root.is_empty() && path.starts_with(root))
14+
&& !path.components().any(|component| {
15+
matches!(component, Component::Normal(name)
16+
if PACKAGE_DIRECTORIES.iter().any(|package| name == *package))
17+
})
18+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//! `third_party_console_form`: how a non-debug console shows a third-party record.
2+
3+
use crate::diagnostic_routing::constants::{LEVEL_ERROR, LEVEL_WARNING};
4+
use crate::diagnostic_routing::models::ThirdPartyConsoleForm;
5+
6+
/// Errors in full, warnings as one line, and nothing below warning.
7+
#[must_use]
8+
pub fn third_party_console_form(level: i64) -> ThirdPartyConsoleForm {
9+
if level >= LEVEL_ERROR {
10+
ThirdPartyConsoleForm::Full
11+
} else if level >= LEVEL_WARNING {
12+
ThirdPartyConsoleForm::Summary
13+
} else {
14+
ThirdPartyConsoleForm::Hidden
15+
}
16+
}

0 commit comments

Comments
 (0)