1
1
import * as assert from "assert" ;
2
2
import * as fs from "fs" ;
3
+
3
4
import * as Path from "path" ;
4
5
import * as TypeMoq from "typemoq" ;
5
6
6
7
import * as Resources from "./resources" ;
7
8
9
+ import ArduinoContext from "..//src/arduinoContext" ;
8
10
import { ArduinoApp } from "../src/arduino/arduino" ;
9
11
import { ArduinoSettings } from "../src/arduino/arduinoSettings" ;
10
12
import { parseBoardDescriptor } from "../src/arduino/board" ;
@@ -46,7 +48,7 @@ suite("Arduino: Board Manager.", () => {
46
48
assert . equal ( platforms [ 0 ] . name , "Arduino AVR Boards" , "Board Manager should display built Arduino AVR Boards" ) ;
47
49
assert . equal ( platforms [ 0 ] . installedVersion , "1.6.18" , "Arduino IDE built-in AVR board package version should be 1.6.18" ) ;
48
50
assert . equal ( platforms [ 0 ] . rootBoardPath , Path . join ( Resources . mockedIDEPackagePath , "arduino" , "avr" ) ,
49
- "Should be able to index root board path for installed boards" ) ;
51
+ "Should be able to index root board path for installed boards" ) ;
50
52
} ) ;
51
53
52
54
test ( "should be able to load installed platforms" , ( ) => {
@@ -63,7 +65,7 @@ suite("Arduino: Board Manager.", () => {
63
65
assert . equal ( boardManager . installedBoards . size , 46 , "Arduino IDE should contains built-in AVR boards" ) ;
64
66
assert . equal ( boardManager . installedBoards . has ( "arduino:avr:yun" ) , true , "should parse installed boards from Arduino IDE built-in packages" ) ;
65
67
assert . equal ( boardManager . installedBoards . has ( "esp8266:esp8266:huzzah" ) , true ,
66
- "should parse installed boards from custom packages ($sketchbook/hardware directory)" ) ;
68
+ "should parse installed boards from custom packages ($sketchbook/hardware directory)" ) ;
67
69
} ) ;
68
70
69
71
test ( "should parse boards.txt correctly" , ( ) => {
@@ -96,4 +98,44 @@ suite("Arduino: Board Manager.", () => {
96
98
assert . equal ( platformConfig . get ( "name" ) , "ESP8266 Modules" ) ;
97
99
assert . equal ( platformConfig . get ( "version" ) , "2.2.0" ) ;
98
100
} ) ;
101
+
102
+ // Arduino: Board Manager: Manage packages for boards.
103
+ // tslint:disable-next-line: only-arrow-functions
104
+ test ( "should be able to install boards packages" , function ( done ) {
105
+ this . timeout ( 4 * 60 * 1000 ) ;
106
+ try {
107
+ // Board Manager: install boards packages.
108
+ ArduinoContext . arduinoApp . installBoard ( "Microsoft" , "win10" , "1.1.2" , true ) . then ( ( result ) => {
109
+ const arduinoSettings = ArduinoContext . arduinoApp . settings ;
110
+ const packagePath = Path . join ( arduinoSettings . packagePath , "packages" , "Microsoft" ) ;
111
+ // check if the installation succeeds or not
112
+ if ( util . directoryExistsSync ( packagePath ) ) {
113
+ done ( ) ;
114
+ } else {
115
+ done ( new Error ( "Microsoft board package install failure, can't find package path :" + packagePath ) ) ;
116
+ }
117
+ } ) ;
118
+
119
+ } catch ( error ) {
120
+ done ( new Error ( error ) ) ;
121
+ }
122
+ } ) ;
123
+
124
+ // Arduino: Board Manager: remove boards packages.
125
+ // tslint:disable-next-line: only-arrow-functions
126
+ test ( "should be able to remove boards packages" , ( ) => {
127
+ try {
128
+ // Board Manager: remove boards packages.
129
+ const arduinoSettings = ArduinoContext . arduinoApp . settings ;
130
+ const packagePath = Path . join ( arduinoSettings . packagePath , "packages" , "Microsoft" ) ;
131
+ if ( util . directoryExistsSync ( packagePath ) ) {
132
+ ArduinoContext . arduinoApp . uninstallBoard ( "Microsoft" , packagePath ) ;
133
+ assert . equal ( util . directoryExistsSync ( packagePath ) , false ,
134
+ "Package path still exist after calling uninstall package,remove the board package failure" ) ;
135
+ }
136
+ } catch ( error ) {
137
+ assert . fail ( true , false , new Error ( error ) . message , new Error ( error ) . name ) ;
138
+ }
139
+ } ) ;
140
+
99
141
} ) ;
0 commit comments