Skip to content

Commit e70328e

Browse files
authored
Merge branch 'main' into reference-doc-psscript
2 parents d8eb02f + 18fd542 commit e70328e

Some content is hidden

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

78 files changed

+2306
-1301
lines changed

archive/registry/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ lto = true
1414
lto = true
1515

1616
[dependencies]
17-
atty = { version = "0.2" }
1817
clap = { version = "4.1", features = ["derive"] }
19-
crossterm = { version = "0.26" }
18+
crossterm = { version = "0.29" }
2019
ntreg = { path = "../ntreg" }
2120
ntstatuserror = { path = "../ntstatuserror" }
2221
schemars = { version = "1.0" }

archive/registry/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use crossterm::event;
77
use std::env;
88

99
use args::Arguments;
10-
use atty::Stream;
1110
use clap::Parser;
11+
use crossterm::tty::{is_tty, Stream};
1212
use schemars::schema_for;
1313
use std::{io::{self, Read}, process::exit};
1414

@@ -32,7 +32,7 @@ fn main() {
3232
check_debug();
3333

3434
let args = Arguments::parse();
35-
let input: Option<String> = if atty::is(Stream::Stdin) {
35+
let input: Option<String> = if is_tty(Stream::Stdin) {
3636
None
3737
} else {
3838
let mut buffer: Vec<u8> = Vec::new();

build.ps1

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ param(
2626
$env:RUSTC_LOG=$null
2727
$env:RUSTFLAGS='-Dwarnings'
2828

29+
trap {
30+
Write-Error "An error occurred: $($_ | Out-String)"
31+
exit 1
32+
}
33+
2934
if ($Verbose) {
3035
$env:RUSTC_LOG='rustc_codegen_ssa::back::link=info'
3136
}
@@ -569,11 +574,7 @@ if ($Test) {
569574
(Get-Module -Name Pester -ListAvailable).Path
570575
}
571576

572-
try {
573-
Invoke-Pester -ErrorAction Stop
574-
} catch {
575-
throw "Pester had unexpected error: $($_.Exception.Message)"
576-
}
577+
Invoke-Pester -Output Detailed -ErrorAction Stop
577578
}
578579

579580
function Find-MakeAppx() {

dsc/Cargo.lock

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dsc/locales/en-us.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ tableHeader_functionName = "Function"
115115
tableHeader_functionCategory = "Category"
116116
tableHeader_minArgs = "MinArgs"
117117
tableHeader_maxArgs = "MaxArgs"
118-
tableHeader_argTypes = "ArgTypes"
118+
tableHeader_argTypes = "ReturnTypes"
119119
invalidFunctionFilter = "Invalid function filter"
120120
maxInt = "maxInt"
121121
invalidManifest = "Error in manifest for"

dsc/src/subcommand.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::resolve::{get_contents, Include};
66
use crate::resource_command::{get_resource, self};
77
use crate::tablewriter::Table;
88
use crate::util::{get_input, get_schema, in_desired_state, set_dscconfigroot, validate_json, write_object, DSC_CONFIG_ROOT, EXIT_DSC_ASSERTION_FAILED, EXIT_DSC_ERROR, EXIT_INVALID_ARGS, EXIT_INVALID_INPUT, EXIT_JSON_ERROR};
9-
use dsc_lib::functions::AcceptedArgKind;
9+
use dsc_lib::functions::FunctionArgKind;
1010
use dsc_lib::{
1111
configure::{
1212
config_doc::{
@@ -697,12 +697,12 @@ fn list_functions(functions: &FunctionDispatcher, function_name: Option<&String>
697697
write_table = true;
698698
}
699699
let mut include_separator = false;
700-
let accepted_arg_types= [
701-
(AcceptedArgKind::Array, "a"),
702-
(AcceptedArgKind::Boolean, "b"),
703-
(AcceptedArgKind::Number, "n"),
704-
(AcceptedArgKind::String, "s"),
705-
(AcceptedArgKind::Object, "o"),
700+
let returned_types= [
701+
(FunctionArgKind::Array, "a"),
702+
(FunctionArgKind::Boolean, "b"),
703+
(FunctionArgKind::Number, "n"),
704+
(FunctionArgKind::String, "s"),
705+
(FunctionArgKind::Object, "o"),
706706
];
707707

708708
let asterisks = String::from("*");
@@ -724,9 +724,9 @@ fn list_functions(functions: &FunctionDispatcher, function_name: Option<&String>
724724

725725
if write_table {
726726
// construct arg_types from '-' times number of accepted_arg_types
727-
let mut arg_types = "-".repeat(accepted_arg_types.len());
728-
for (i, (arg_type, letter)) in accepted_arg_types.iter().enumerate() {
729-
if function.accepted_arg_types.contains(arg_type) {
727+
let mut arg_types = "-".repeat(returned_types.len());
728+
for (i, (arg_type, letter)) in returned_types.iter().enumerate() {
729+
if function.return_types.contains(arg_type) {
730730
arg_types.replace_range(i..=i, letter);
731731
}
732732
}

dsc/tests/dsc_config_test.tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,6 @@ Describe 'dsc config test tests' {
8383
$null = dsc config test -i $configYaml 2> "$TestDrive/trace.log"
8484
$LASTEXITCODE | Should -Be 2
8585
$log = Get-Content "$TestDrive/trace.log" -Raw
86-
$log | Should -Match ".*Resource named 'MyTest' is specified more than once.*" -Because ($log | Out-String)
86+
$log | Should -Match ".*Resource named 'MyTest' for type 'Microsoft.DSC.Debug/Echo' is specified more than once.*" -Because ($log | Out-String)
8787
}
8888
}

dsc/tests/dsc_extension_discover.tests.ps1

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT License.
33

4+
BeforeDiscovery {
5+
try {
6+
$windowWidth = [Console]::WindowWidth
7+
} catch {
8+
$consoleUnavailable = $true
9+
}
10+
}
11+
412
Describe 'Discover extension tests' {
513
BeforeAll {
614
$oldPath = $env:PATH
@@ -15,15 +23,31 @@ Describe 'Discover extension tests' {
1523
It 'Discover extensions' {
1624
$out = dsc extension list | ConvertFrom-Json
1725
$LASTEXITCODE | Should -Be 0
18-
$out.Count | Should -Be 2 -Because ($out | Out-String)
19-
$out[0].type | Should -Be 'Microsoft.DSC.Extension/Bicep'
20-
$out[0].version | Should -Be '0.1.0'
21-
$out[0].capabilities | Should -BeExactly @('import')
22-
$out[0].manifest | Should -Not -BeNullOrEmpty
23-
$out[1].type | Should -BeExactly 'Test/Discover'
24-
$out[1].version | Should -BeExactly '0.1.0'
25-
$out[1].capabilities | Should -BeExactly @('discover')
26-
$out[1].manifest | Should -Not -BeNullOrEmpty
26+
if ($IsWindows) {
27+
$out.Count | Should -Be 3 -Because ($out | Out-String)
28+
$out[0].type | Should -Be 'Microsoft.DSC.Extension/Bicep'
29+
$out[0].version | Should -Be '0.1.0'
30+
$out[0].capabilities | Should -BeExactly @('import')
31+
$out[0].manifest | Should -Not -BeNullOrEmpty
32+
$out[1].type | Should -Be 'Microsoft.Windows.Appx/Discover'
33+
$out[1].version | Should -Be '0.1.0'
34+
$out[1].capabilities | Should -BeExactly @('discover')
35+
$out[1].manifest | Should -Not -BeNullOrEmpty
36+
$out[2].type | Should -BeExactly 'Test/Discover'
37+
$out[2].version | Should -BeExactly '0.1.0'
38+
$out[2].capabilities | Should -BeExactly @('discover')
39+
$out[2].manifest | Should -Not -BeNullOrEmpty
40+
} else {
41+
$out.Count | Should -Be 2 -Because ($out | Out-String)
42+
$out[0].type | Should -Be 'Microsoft.DSC.Extension/Bicep'
43+
$out[0].version | Should -Be '0.1.0'
44+
$out[0].capabilities | Should -BeExactly @('import')
45+
$out[0].manifest | Should -Not -BeNullOrEmpty
46+
$out[1].type | Should -BeExactly 'Test/Discover'
47+
$out[1].version | Should -BeExactly '0.1.0'
48+
$out[1].capabilities | Should -BeExactly @('discover')
49+
$out[1].manifest | Should -Not -BeNullOrEmpty
50+
}
2751
}
2852

2953
It 'Filtering works for extension discovered resources' {
@@ -94,12 +118,12 @@ Describe 'Discover extension tests' {
94118
}
95119
}
96120

97-
It 'Table can be not truncated' {
121+
It 'Table can be not truncated' -Skip:($consoleUnavailable) {
98122
$output = dsc extension list --output-format table-no-truncate
99123
$LASTEXITCODE | Should -Be 0
100124
$foundWideLine = $false
101125
foreach ($line in $output) {
102-
if ($line.Length -gt [Console]::WindowWidth) {
126+
if ($line.Length -gt $windowWidth) {
103127
$foundWideLine = $true
104128
}
105129
}

dsc/tests/dsc_function_list.tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Describe 'Tests for function list subcommand' {
1919
$out.name | Should -BeExactly 'resourceId'
2020
$out.minArgs | Should -Be 2
2121
$out.maxArgs | Should -Be 2
22-
$out.acceptedArgTypes | Should -Be @('String')
22+
$out.returnTypes | Should -Be @('String')
2323
$out.description | Should -Not -BeNullOrEmpty
2424
}
2525
}

0 commit comments

Comments
 (0)